/// <exception cref="System.IO.IOException"/> public virtual void ReadFields(ByteBuffer buf) { packetLen = buf.GetInt(); short protoLen = buf.GetShort(); byte[] data = new byte[protoLen]; buf.Get(data); proto = DataTransferProtos.PacketHeaderProto.ParseFrom(data); }
/// <exception cref="System.IO.IOException"/> public virtual void ReadFields(DataInputStream @in) { this.packetLen = @in.ReadInt(); short protoLen = @in.ReadShort(); byte[] data = new byte[protoLen]; @in.ReadFully(data); proto = DataTransferProtos.PacketHeaderProto.ParseFrom(data); }
public PacketHeader(int packetLen, long offsetInBlock, long seqno, bool lastPacketInBlock , int dataLen, bool syncBlock) { this.packetLen = packetLen; Preconditions.CheckArgument(packetLen >= Ints.Bytes, "packet len %s should always be at least 4 bytes" , packetLen); DataTransferProtos.PacketHeaderProto.Builder builder = DataTransferProtos.PacketHeaderProto .NewBuilder().SetOffsetInBlock(offsetInBlock).SetSeqno(seqno).SetLastPacketInBlock (lastPacketInBlock).SetDataLen(dataLen); if (syncBlock) { // Only set syncBlock if it is specified. // This is wire-incompatible with Hadoop 2.0.0-alpha due to HDFS-3721 // because it changes the length of the packet header, and BlockReceiver // in that version did not support variable-length headers. builder.SetSyncBlock(syncBlock); } proto = ((DataTransferProtos.PacketHeaderProto)builder.Build()); }
/// <exception cref="Com.Google.Protobuf.InvalidProtocolBufferException"/> public virtual void SetFieldsFromData(int packetLen, byte[] headerData) { this.packetLen = packetLen; proto = DataTransferProtos.PacketHeaderProto.ParseFrom(headerData); }