net.i2p.router.transport.udp
Class InboundMessageState

java.lang.Object
  extended by net.i2p.router.transport.udp.InboundMessageState
All Implemented Interfaces:
CDQEntry

 class InboundMessageState
extends Object
implements CDQEntry

Hold the raw data fragments of an inbound message. Warning - there is no synchronization in this class, take care in InboundMessageFragments to avoid use-after-release, etc.


Field Summary
static int MAX_FRAGMENTS
           
 
Constructor Summary
InboundMessageState(RouterContext ctx, long messageId, Hash from)
           
 
Method Summary
 ACKBitfield createACKBitfield()
           
 void drop()
          For CDQ
 int getCompleteSize()
           
 long getEnqueueTime()
          For CDQ
 int getFragmentCount()
           
 ByteArray[] getFragments()
           
 Hash getFrom()
           
 long getLifetime()
           
 long getMessageId()
           
 boolean isComplete()
          May not be valid after released.
 boolean isExpired()
           
 boolean receiveFragment(UDPPacketReader.DataReader data, int dataFragment)
          Read in the data from the fragment.
 void releaseResources()
           
 void setEnqueueTime(long now)
          For CDQ
 String toString()
          May not be valid if released, or may NPE on race with release, use with care in exception text
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_FRAGMENTS

public static final int MAX_FRAGMENTS
See Also:
Constant Field Values
Constructor Detail

InboundMessageState

public InboundMessageState(RouterContext ctx,
                           long messageId,
                           Hash from)
Method Detail

receiveFragment

public boolean receiveFragment(UDPPacketReader.DataReader data,
                               int dataFragment)
Read in the data from the fragment. Caller should synchronize.

Returns:
true if the data was ok, false if it was corrupt

isComplete

public boolean isComplete()
May not be valid after released. Probably doesn't need to be synced by caller, given the order of events in receiveFragment() above, but you might want to anyway to be safe.


isExpired

public boolean isExpired()

getLifetime

public long getLifetime()

setEnqueueTime

public void setEnqueueTime(long now)
For CDQ

Specified by:
setEnqueueTime in interface CDQEntry
Since:
0.9.3

getEnqueueTime

public long getEnqueueTime()
For CDQ

Specified by:
getEnqueueTime in interface CDQEntry
Since:
0.9.3

drop

public void drop()
For CDQ

Specified by:
drop in interface CDQEntry
Since:
0.9.3

getFrom

public Hash getFrom()

getMessageId

public long getMessageId()

getCompleteSize

public int getCompleteSize()
Throws:
IllegalStateException - if released or not isComplete()

createACKBitfield

public ACKBitfield createACKBitfield()

releaseResources

public void releaseResources()

getFragments

public ByteArray[] getFragments()
Throws:
IllegalStateException - if released

getFragmentCount

public int getFragmentCount()

toString

public String toString()
May not be valid if released, or may NPE on race with release, use with care in exception text

Overrides:
toString in class Object