| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_FRAGMENTS |
| Constructor and Description |
|---|
InboundMessageState(RouterContext ctx,
long messageId,
Hash from)
Constructs a new InboundMessageState with no fragments.
|
InboundMessageState(RouterContext ctx,
long messageId,
Hash from,
byte[] data,
int off,
int len,
int fragmentNum,
boolean isLast)
Constructs and initializes by receiving one fragment.
|
| Modifier and Type | Method and Description |
|---|---|
ACKBitfield |
createACKBitfield()
Creates a bitfield representing received fragments.
|
void |
drop()
Drops and releases resources.
|
int |
getCompleteSize()
Returns the total size of the complete message in bytes.
|
long |
getEnqueueTime()
Gets the enqueue time.
|
int |
getFragmentCount()
Returns number of fragments received or expected.
|
ByteArray[] |
getFragments()
Returns the array of fragments, throws if already released.
|
Hash |
getFrom()
Returns the Hash of the sender.
|
long |
getLifetime()
Returns the message lifetime in milliseconds.
|
long |
getMessageId()
Returns the message ID.
|
boolean |
hasFragment(int fragmentNum)
Returns whether the specified fragment has been received.
|
boolean |
isComplete()
Returns true if all fragments up to last have been received.
|
boolean |
isExpired()
Returns true if message has expired (received more than 10s ago).
|
boolean |
receiveFragment(byte[] data,
int off,
int len,
int fragmentNum,
boolean isLast)
Receives and stores a fragment.
|
void |
releaseResources()
Releases all cached fragments and marks this state as released.
|
void |
setEnqueueTime(long now)
Sets enqueue time for queueing.
|
String |
toString()
Returns a string summary of this message state.
|
public static final int MAX_FRAGMENTS
public InboundMessageState(RouterContext ctx, long messageId, Hash from)
public InboundMessageState(RouterContext ctx, long messageId, Hash from, byte[] data, int off, int len, int fragmentNum, boolean isLast) throws DataFormatException
DataFormatException - if fragment is invalidpublic ACKBitfield createACKBitfield()
public int getCompleteSize()
IllegalStateException - if message incomplete or releasedpublic long getEnqueueTime()
getEnqueueTime in interface CDQEntrypublic int getFragmentCount()
public ByteArray[] getFragments()
public Hash getFrom()
public long getLifetime()
public long getMessageId()
public boolean hasFragment(int fragmentNum)
public boolean isComplete()
public boolean isExpired()
public boolean receiveFragment(byte[] data,
int off,
int len,
int fragmentNum,
boolean isLast)
throws DataFormatException
DataFormatExceptionpublic void releaseResources()
public void setEnqueueTime(long now)
setEnqueueTime in interface CDQEntry