void readMetadata ( DataInputStream in , VersionAndOpcode versionAndOpcode ) throws IOException { ReadMetadataHeader readMetadataHeader = new ReadMetadataHeader ( versionAndOpcode ) ; readMetadataHeader . readFields ( in ) ; final int namespaceId = readMetadataHeader . getNamespaceId ( ) ; Block block = new Block ( readMetadataHeader . getBlockId ( ) , 0 , readMetadataHeader . getGenStamp ( ) ) ; ReplicaToRead rtr ; if ( ( rtr = datanode . data . getReplicaToRead ( namespaceId , block ) ) == null || rtr . isInlineChecksum ( ) ) { throw new IOException ( "Read metadata from inline checksum file is not supported" ) ; } DataOutputStream out = null ; try { updateCurrentThreadName ( "reading metadata for block " + block ) ; out = new DataOutputStream ( NetUtils . getOutputStream ( s , datanode . socketWriteTimeout ) ) ; byte [ ] buf = BlockWithChecksumFileReader . getMetaData ( datanode . data , namespaceId , block ) ; out . writeByte ( DataTransferProtocol . OP_STATUS_SUCCESS ) ; out . writeInt ( buf . length ) ; out . write ( buf ) ; //last DATA_CHUNK out . writeInt ( 0 ) ; } finally { IOUtils . closeStream ( out ) ; } }
Reads the metadata and sends the data in one DATA_CHUNK .