org.apache.hadoop.hdfs.protocol.datatransfer.DataTransferProtocol Java Examples

The following examples show how to use org.apache.hadoop.hdfs.protocol.datatransfer.DataTransferProtocol. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DataNode.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Connect to the first item in the target list.  Pass along the 
 * entire target list, the block, and the data.
 */
DataTransfer(DatanodeInfo targets[], StorageType[] targetStorageTypes,
    ExtendedBlock b, BlockConstructionStage stage,
    final String clientname)  {
  if (DataTransferProtocol.LOG.isDebugEnabled()) {
    DataTransferProtocol.LOG.debug(getClass().getSimpleName() + ": "
        + b + " (numBytes=" + b.getNumBytes() + ")"
        + ", stage=" + stage
        + ", clientname=" + clientname
        + ", targets=" + Arrays.asList(targets)
        + ", target storage types=" + (targetStorageTypes == null ? "[]" :
        Arrays.asList(targetStorageTypes)));
  }
  this.targets = targets;
  this.targetStorageTypes = targetStorageTypes;
  this.b = b;
  this.stage = stage;
  BPOfferService bpos = blockPoolManager.get(b.getBlockPoolId());
  bpReg = bpos.bpRegistration;
  this.clientname = clientname;
  this.cachingStrategy =
      new CachingStrategy(true, getDnConf().readaheadLength);
}
 
Example #2
Source File: DataNode.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Connect to the first item in the target list.  Pass along the 
 * entire target list, the block, and the data.
 */
DataTransfer(DatanodeInfo targets[], StorageType[] targetStorageTypes,
    ExtendedBlock b, BlockConstructionStage stage,
    final String clientname)  {
  if (DataTransferProtocol.LOG.isDebugEnabled()) {
    DataTransferProtocol.LOG.debug(getClass().getSimpleName() + ": "
        + b + " (numBytes=" + b.getNumBytes() + ")"
        + ", stage=" + stage
        + ", clientname=" + clientname
        + ", targets=" + Arrays.asList(targets)
        + ", target storage types=" + (targetStorageTypes == null ? "[]" :
        Arrays.asList(targetStorageTypes)));
  }
  this.targets = targets;
  this.targetStorageTypes = targetStorageTypes;
  this.b = b;
  this.stage = stage;
  BPOfferService bpos = blockPoolManager.get(b.getBlockPoolId());
  bpReg = bpos.bpRegistration;
  this.clientname = clientname;
  this.cachingStrategy =
      new CachingStrategy(true, getDnConf().readaheadLength);
}
 
Example #3
Source File: TestPread.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testPreadDFSNoChecksum() throws IOException {
  Configuration conf = new Configuration();
  ((Log4JLogger)DataTransferProtocol.LOG).getLogger().setLevel(Level.ALL);
  dfsPreadTest(conf, false, false);
  dfsPreadTest(conf, true, false);
}
 
Example #4
Source File: TestPread.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testPreadDFSNoChecksum() throws IOException {
  Configuration conf = new Configuration();
  ((Log4JLogger)DataTransferProtocol.LOG).getLogger().setLevel(Level.ALL);
  dfsPreadTest(conf, false, false);
  dfsPreadTest(conf, true, false);
}
 
Example #5
Source File: FanOutOneBlockAsyncDFSOutputHelper.java    From hbase with Apache License 2.0 5 votes vote down vote up
private static void requestWriteBlock(Channel channel, StorageType storageType,
    OpWriteBlockProto.Builder writeBlockProtoBuilder) throws IOException {
  OpWriteBlockProto proto =
    writeBlockProtoBuilder.setStorageType(PBHelperClient.convertStorageType(storageType)).build();
  int protoLen = proto.getSerializedSize();
  ByteBuf buffer =
    channel.alloc().buffer(3 + CodedOutputStream.computeRawVarint32Size(protoLen) + protoLen);
  buffer.writeShort(DataTransferProtocol.DATA_TRANSFER_VERSION);
  buffer.writeByte(Op.WRITE_BLOCK.code);
  proto.writeDelimitedTo(new ByteBufOutputStream(buffer));
  channel.writeAndFlush(buffer);
}