java.lang.Object
net.i2p.router.tunnel.TunnelGateway
net.i2p.router.tunnel.PumpedTunnelGateway
net.i2p.router.tunnel.TunnelGatewayPumper.PoisonPTG
- Enclosing class:
TunnelGatewayPumper
Special poison pill PumpedTunnelGateway to signal thread shutdown.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classNo-op receiver for poison pill to avoid null pointer issues.Nested classes/interfaces inherited from class TunnelGateway
TunnelGateway.DelayedFlush, TunnelGateway.QueuePreprocessor, TunnelGateway.Receiver, TunnelGateway.SenderModifier and TypeClassDescriptionprotected classDelayed flush timer event.static interfaceInterface for preprocessing queued tunnel messages.static interfaceInterface for receiving encrypted tunnel data.static interfaceInterface for sending preprocessed tunnel data.Field Summary
Fields inherited from class PumpedTunnelGateway
_isInbound, PROP_INITIAL_OB_QUEUE, PROP_MAX_IB_MSGS_PER_PUMP, PROP_MAX_IB_QUEUE, PROP_MAX_OB_MSGS_PER_PUMPModifier and TypeFieldDescriptionfinal booleanWhether this gateway is inbound (vs outbound).static final StringProperty key for initial outbound queue size.static final StringProperty key for max inbound messages per pump.static final StringProperty key for max inbound queue size.static final StringProperty key for max outbound messages per pump.Fields inherited from class TunnelGateway
_context, _delayedFlush, _lastFlush, _log, _messagesSent, _preprocessor, _queue, _receiver, _senderModifier and TypeFieldDescriptionprotected final RouterContextThe router context.protected final TunnelGateway.DelayedFlushThe delayed flush timer.protected longThe last flush time.protected final LogThe log instance.protected intThe messages sent count.protected final TunnelGateway.QueuePreprocessorThe queue preprocessor.protected final List<PendingGatewayMessage> The message queue.protected final TunnelGateway.ReceiverThe message receiver, consuming encrypted messages for forwarding.protected final TunnelGateway.SenderThe message sender, encrypting and forwarding preprocessed messages.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionintThe number of messages sent.booleanpump(List<PendingGatewayMessage> queueBuf) Pumps messages from the internal prequeue into the processing queue.Methods inherited from class PumpedTunnelGateway
add, add, getMaxIbMsgsPerPump, getMaxObMsgsPerPump, setMaxIbMsgsPerPump, setMaxObMsgsPerPumpModifier and TypeMethodDescriptionbooleanadd(I2NPMessage msg, Hash toRouter, TunnelId toTunnel) Adds a message to be sent down the tunnel.protected booleanadd(PendingGatewayMessage cur) Adds a PendingGatewayMessage to the prequeue and notifies the pumper to process it.static intThe maximum inbound messages per pump.static intThe cap the pump applies to outbound messages, read once per pump pass so a single busy iteration cannot monopolise the thread.static voidsetMaxIbMsgsPerPump(int val) The maximum inbound messages per pump.static voidsetMaxObMsgsPerPump(int val) The maximum outbound messages per pump.Methods inherited from class TunnelGateway
addModifier and TypeMethodDescriptionbooleanadd(TunnelGatewayMessage msg) Add a message to be sent down the tunnel, where we are the inbound gateway.
Constructor Details
PoisonPTG
Builds the gateway that stops a pump thread.- Parameters:
ctx- the router context
Method Details
getMessagesSent
public int getMessagesSent()Description copied from class:TunnelGatewayThe number of messages sent.- Overrides:
getMessagesSentin classTunnelGateway- Returns:
- the number of messages sent
pump
Description copied from class:PumpedTunnelGatewayPumps messages from the internal prequeue into the processing queue.This method tries to drain a bounded number of messages from _prequeue into the provided queueBuf, then adds them to the internal _queue for preprocessing and fragmentation.
Expired messages are removed after preprocessing, outside the synchronization block, to reduce contention.
- Overrides:
pumpin classPumpedTunnelGateway- Parameters:
queueBuf- an empty list used as a temporary buffer for messages (will be cleared before return)- Returns:
- true if there are still messages remaining in _prequeue and the caller should requeue this gateway