@PrivateApi public final class Packet extends HeapData implements OutboundFrame
Modifier and Type | Class and Description |
---|---|
static class |
Packet.Type |
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_JET_FLOW_CONTROL
Marks a Jet packet as Flow control
|
static int |
FLAG_OP_CONTROL
Marks an Operation packet as Operation control (like invocation-heartbeats)
|
static int |
FLAG_OP_RESPONSE
Marks an Operation packet as Response
|
static int |
FLAG_URGENT
Marks the packet as Urgent
|
static byte |
VERSION |
DATA_OFFSET, HEAP_DATA_OVERHEAD, PARTITION_HASH_OFFSET, payload, TYPE_OFFSET
Constructor and Description |
---|
Packet() |
Packet(byte[] payload) |
Packet(byte[] payload,
int partitionId) |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
Connection |
getConn()
Gets the Connection this Packet was send with.
|
char |
getFlags() |
Packet.Type |
getPacketType() |
int |
getPartitionId()
Returns the partition ID of this packet.
|
int |
hashCode() |
boolean |
isFlagRaised(int flagsToCheck)
Returns
true if any of the flags supplied in the argument are set. |
boolean |
isUrgent()
Checks if this Frame is urgent.
|
int |
packetSize()
Returns an estimation of the packet, including its payload, in bytes.
|
Packet |
raiseFlags(int flagsToRaise)
Raises all the flags raised in the argument.
|
boolean |
readFrom(ByteBuffer src)
Reads the packet data from the supplied
ByteBuffer . |
void |
reset()
The methods
readFrom(ByteBuffer) and writeTo(ByteBuffer) do not complete their I/O operation
within a single call, and between calls there is some progress state to keep within this instance. |
Packet |
resetFlagsTo(int flagsToSet)
Resets the entire
flags bitfield to the supplied value. |
Packet |
setConn(Connection conn)
Sets the Connection this Packet is send with.
|
Packet |
setPacketType(Packet.Type type)
Sets the packet type by updating the packet type bits in the
flags bitfield. |
String |
toString() |
boolean |
writeTo(ByteBuffer dst)
Writes the packet data to the supplied
ByteBuffer , up to the buffer's limit. |
copyTo, dataSize, getHeapCost, getPartitionHash, getType, hash64, hasPartitionHash, isPortable, toByteArray, totalSize
public static final byte VERSION
public static final int FLAG_URGENT
public static final int FLAG_OP_RESPONSE
public static final int FLAG_OP_CONTROL
public static final int FLAG_JET_FLOW_CONTROL
public Packet()
public Packet(byte[] payload)
public Packet(byte[] payload, int partitionId)
public Connection getConn()
public Packet setConn(Connection conn)
conn
- the connection.this
(for fluent interface)public Packet.Type getPacketType()
public Packet setPacketType(Packet.Type type)
flags
bitfield. Other bits
are unaffected.type
- the type to setthis
(for fluent interface)public Packet raiseFlags(int flagsToRaise)
flagsToRaise
- the flags to raisethis
(for fluent interface)public Packet resetFlagsTo(int flagsToSet)
flags
bitfield to the supplied value. This also affects the packet type bits.flagsToSet
- the flags. Only the least significant two bytes of the argument are used.this
(for fluent interface)public boolean isFlagRaised(int flagsToCheck)
true
if any of the flags supplied in the argument are set.flagsToCheck
- the flags to checktrue
if any of the flags is set, false
otherwise.public char getFlags()
char
.public int getPartitionId()
public boolean isUrgent()
OutboundFrame
isUrgent
in interface OutboundFrame
public void reset()
readFrom(ByteBuffer)
and writeTo(ByteBuffer)
do not complete their I/O operation
within a single call, and between calls there is some progress state to keep within this instance.
Calling this method resets the state back to "no bytes read/written yet".public boolean writeTo(ByteBuffer dst)
ByteBuffer
, up to the buffer's limit. If it returns false
,
it should be called again to write the remaining data.dst
- the destination byte buffertrue
if all the packet's data is now written out; false
otherwise.public boolean readFrom(ByteBuffer src)
ByteBuffer
. The buffer may not contain the complete packet.
If this method returns false
, it should be called again to read more packet data.src
- the source byte buffertrue
if all the packet's data is now read; false
otherwise.public int packetSize()
Copyright © 2017 Hazelcast, Inc.. All Rights Reserved.