Package net.i2p.router.transport.udp
Class InboundMessageState
- java.lang.Object
-
- net.i2p.router.transport.udp.InboundMessageState
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAX_FRAGMENTS
static int
MAX_PARTIAL_BITFIELD_BYTES
10
-
Constructor Summary
Constructors Constructor Description InboundMessageState(RouterContext ctx, long messageId, Hash from)
InboundMessageState(RouterContext ctx, long messageId, Hash from, UDPPacketReader.DataReader data, int dataFragment)
Create a new IMS and read in the data from the fragment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ACKBitfield
createACKBitfield()
Only call this if not complete.void
drop()
For CDQint
getCompleteSize()
long
getEnqueueTime()
For CDQint
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 CDQString
toString()
May not be valid if released, or may NPE on race with release, use with care in exception text
-
-
-
Field Detail
-
MAX_FRAGMENTS
public static final int MAX_FRAGMENTS
- See Also:
- Constant Field Values
-
MAX_PARTIAL_BITFIELD_BYTES
public static final int MAX_PARTIAL_BITFIELD_BYTES
10- See Also:
- Constant Field Values
-
-
Constructor Detail
-
InboundMessageState
public InboundMessageState(RouterContext ctx, long messageId, Hash from)
-
InboundMessageState
public InboundMessageState(RouterContext ctx, long messageId, Hash from, UDPPacketReader.DataReader data, int dataFragment) throws DataFormatException
Create a new IMS and read in the data from the fragment. Do NOT call receiveFragment for the same fragment afterwards. This is more efficient if the fragment is the last (and probably only) fragment. The main savings is not allocating ByteArray[64].- Throws:
DataFormatException
- if the fragment was corrupt- Since:
- 0.9.9
-
-
Method Detail
-
receiveFragment
public boolean receiveFragment(UDPPacketReader.DataReader data, int dataFragment) throws DataFormatException
Read in the data from the fragment. Caller should synchronize.- Returns:
- true if the data was ok, false if it was corrupt
- Throws:
DataFormatException
-
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 interfaceCDQEntry
- Since:
- 0.9.3
-
getEnqueueTime
public long getEnqueueTime()
For CDQ- Specified by:
getEnqueueTime
in interfaceCDQEntry
- 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()
Only call this if not complete. TODO remove this, have InboundMessageState implement ACKBitfield. FIXME synch here or PeerState.fetchPartialACKs()
-
releaseResources
public void releaseResources()
-
getFragments
public ByteArray[] getFragments()
- Throws:
IllegalStateException
- if released
-
getFragmentCount
public int getFragmentCount()
-
-