Search in sources :

Example 1 with OpWriteBlockProto

use of org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto in project hbase by apache.

the class FanOutOneBlockAsyncDFSOutputHelper method requestWriteBlock.

private static void requestWriteBlock(Channel channel, Enum<?> storageType, OpWriteBlockProto.Builder writeBlockProtoBuilder) throws IOException {
    OpWriteBlockProto proto = STORAGE_TYPE_SETTER.set(writeBlockProtoBuilder, 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);
}
Also used : ByteBufOutputStream(io.netty.buffer.ByteBufOutputStream) OpWriteBlockProto(org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto) ByteBuf(io.netty.buffer.ByteBuf)

Example 2 with OpWriteBlockProto

use of org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto in project hadoop by apache.

the class Receiver method opWriteBlock.

/** Receive OP_WRITE_BLOCK */
private void opWriteBlock(DataInputStream in) throws IOException {
    final OpWriteBlockProto proto = OpWriteBlockProto.parseFrom(vintPrefixed(in));
    final DatanodeInfo[] targets = PBHelperClient.convert(proto.getTargetsList());
    TraceScope traceScope = continueTraceSpan(proto.getHeader(), proto.getClass().getSimpleName());
    try {
        writeBlock(PBHelperClient.convert(proto.getHeader().getBaseHeader().getBlock()), PBHelperClient.convertStorageType(proto.getStorageType()), PBHelperClient.convert(proto.getHeader().getBaseHeader().getToken()), proto.getHeader().getClientName(), targets, PBHelperClient.convertStorageTypes(proto.getTargetStorageTypesList(), targets.length), PBHelperClient.convert(proto.getSource()), fromProto(proto.getStage()), proto.getPipelineSize(), proto.getMinBytesRcvd(), proto.getMaxBytesRcvd(), proto.getLatestGenerationStamp(), fromProto(proto.getRequestedChecksum()), (proto.hasCachingStrategy() ? getCachingStrategy(proto.getCachingStrategy()) : CachingStrategy.newDefaultStrategy()), (proto.hasAllowLazyPersist() ? proto.getAllowLazyPersist() : false), (proto.hasPinning() ? proto.getPinning() : false), (PBHelperClient.convertBooleanList(proto.getTargetPinningsList())));
    } finally {
        if (traceScope != null)
            traceScope.close();
    }
}
Also used : DatanodeInfo(org.apache.hadoop.hdfs.protocol.DatanodeInfo) TraceScope(org.apache.htrace.core.TraceScope) OpWriteBlockProto(org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto)

Aggregations

OpWriteBlockProto (org.apache.hadoop.hdfs.protocol.proto.DataTransferProtos.OpWriteBlockProto)2 ByteBuf (io.netty.buffer.ByteBuf)1 ByteBufOutputStream (io.netty.buffer.ByteBufOutputStream)1 DatanodeInfo (org.apache.hadoop.hdfs.protocol.DatanodeInfo)1 TraceScope (org.apache.htrace.core.TraceScope)1