net.i2p.router.tunnel
Class TrivialPreprocessor
java.lang.Object
net.i2p.router.tunnel.TrivialPreprocessor
- All Implemented Interfaces:
- TunnelGateway.QueuePreprocessor
- Direct Known Subclasses:
- BatchedPreprocessor, TrivialRouterPreprocessor
public class TrivialPreprocessor
- extends java.lang.Object
- implements TunnelGateway.QueuePreprocessor
Do the simplest thing possible for preprocessing - for each message available,
turn it into the minimum number of fragmented preprocessed blocks, sending
each of those out. This does not coallesce message fragments or delay for more
optimal throughput.
Method Summary |
long |
getDelayAmount()
how long do we want to wait before flushing |
protected int |
getInstructionAugmentationSize(TunnelGateway.Pending msg,
int offset,
int instructionsSize)
|
protected int |
getInstructionsSize(TunnelGateway.Pending msg)
|
protected void |
notePreprocessing(long messageId,
int numFragments,
int totalLength,
java.util.List messageIds,
java.lang.String msg)
|
protected void |
preprocess(byte[] fragments,
int fragmentLength)
Wrap the preprocessed fragments with the necessary padding / checksums
to act as a tunnel message. |
boolean |
preprocessQueue(java.util.List pending,
TunnelGateway.Sender sender,
TunnelGateway.Receiver rec)
Return true if there were messages remaining, and we should queue up
a delayed flush to clear them |
protected int |
writeFirstFragment(TunnelGateway.Pending msg,
byte[] target,
int offset)
|
protected int |
writeSubsequentFragment(TunnelGateway.Pending msg,
byte[] target,
int offset)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_context
protected I2PAppContext _context
PREPROCESSED_SIZE
public static final int PREPROCESSED_SIZE
- See Also:
- Constant Field Values
IV_SIZE
protected static final int IV_SIZE
- See Also:
- Constant Field Values
_dataCache
protected static final ByteCache _dataCache
_ivCache
protected static final ByteCache _ivCache
_hashCache
protected static final ByteCache _hashCache
TrivialPreprocessor
public TrivialPreprocessor(I2PAppContext ctx)
getDelayAmount
public long getDelayAmount()
- how long do we want to wait before flushing
- Specified by:
getDelayAmount
in interface TunnelGateway.QueuePreprocessor
preprocessQueue
public boolean preprocessQueue(java.util.List pending,
TunnelGateway.Sender sender,
TunnelGateway.Receiver rec)
- Return true if there were messages remaining, and we should queue up
a delayed flush to clear them
- Specified by:
preprocessQueue
in interface TunnelGateway.QueuePreprocessor
- Parameters:
pending
- list of Pending objects for messages either unsent
or partly sent. This list should be update with any
values removed (the preprocessor owns the lock)
- Returns:
- true if we should delay before preprocessing again
notePreprocessing
protected void notePreprocessing(long messageId,
int numFragments,
int totalLength,
java.util.List messageIds,
java.lang.String msg)
preprocess
protected void preprocess(byte[] fragments,
int fragmentLength)
- Wrap the preprocessed fragments with the necessary padding / checksums
to act as a tunnel message.
- Parameters:
fragmentLength
- fragments[0:fragmentLength] is used
writeFirstFragment
protected int writeFirstFragment(TunnelGateway.Pending msg,
byte[] target,
int offset)
writeSubsequentFragment
protected int writeSubsequentFragment(TunnelGateway.Pending msg,
byte[] target,
int offset)
getInstructionsSize
protected int getInstructionsSize(TunnelGateway.Pending msg)
getInstructionAugmentationSize
protected int getInstructionAugmentationSize(TunnelGateway.Pending msg,
int offset,
int instructionsSize)