Class PacketReceiver
java.lang.Object
org.apache.hadoop.hdfs.protocol.datatransfer.PacketReceiver
- All Implemented Interfaces:
Closeable,AutoCloseable
Class to handle reading packets one-at-a-time from the wire.
These packets are used both for reading and writing data to/from
DataNodes.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe max size of any single packet. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()protected voidfinalize()voidmirrorPacketTo(DataOutputStream mirrorOut) Rewrite the last-read packet on the wire to the given output stream.voidvoidReads all of the data for the next packet into the appropriate buffers.
-
Field Details
-
MAX_PACKET_SIZE
public static final int MAX_PACKET_SIZEThe max size of any single packet. This prevents OOMEs when invalid data is sent.
-
-
Constructor Details
-
PacketReceiver
public PacketReceiver(boolean useDirectBuffers)
-
-
Method Details
-
getHeader
-
getDataSlice
-
getChecksumSlice
-
receiveNextPacket
Reads all of the data for the next packet into the appropriate buffers. The data slice and checksum slice members will be set to point to the user data and corresponding checksums. The header will be parsed and set.- Throws:
IOException
-
receiveNextPacket
- Throws:
IOException- See Also:
-
mirrorPacketTo
Rewrite the last-read packet on the wire to the given output stream.- Throws:
IOException
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
finalize
-