java.lang.Object
net.i2p.router.transport.ntcp.EventPumper.InboundFloodDecision
- Enclosing class:
EventPumper
Outcome of
EventPumper.evaluateInboundFlood(long, int, int, long, boolean, int, int, RandomSource): whether to reject the incoming connection plus the numbers used in the warn log, so the caller stays side-effect free.Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intInbound connections per minute right now.private final booleanWhether the throttle drops connections outright.private final intConnection count used to compute the current rate.private final intPercent of connections the throttle allows through.(package private) static final EventPumper.InboundFloodDecisionConstant for "accept, nothing to report", reused on every non-drop path.Constructor Summary
ConstructorsModifierConstructorDescriptionprivateInboundFloodDecision(boolean drop, int percent, int lastConnections, int currentConnectionsPerMinute) Freeze one accept decision: whether to drop, the nominal rejection chance to render, and the counts it was projected from.Method Summary
All MethodsModifier and TypeMethodDescription(package private) intThe accept rate the decision was projected from.(package private) intThe accept count the rate was measured against.(package private) intThe nominal share of inbound connections to refuse.(package private) booleanisDrop()Whether to refuse the connection, per the flood decision.
Field Details
ALLOW
Constant for "accept, nothing to report", reused on every non-drop path._drop
private final boolean _dropWhether the throttle drops connections outright._percent
private final int _percentPercent of connections the throttle allows through._lastConnections
private final int _lastConnectionsConnection count used to compute the current rate._currentConnectionsPerMinute
private final int _currentConnectionsPerMinuteInbound connections per minute right now.
Constructor Details
InboundFloodDecision
private InboundFloodDecision(boolean drop, int percent, int lastConnections, int currentConnectionsPerMinute) Freeze one accept decision: whether to drop, the nominal rejection chance to render, and the counts it was projected from.- Parameters:
drop- true to reject the connectionpercent- nominal rejection chance, 0-100 (0 renders as "1%")lastConnections- baseline connections in the previous periodcurrentConnectionsPerMinute- projected current accept rate
Method Details
isDrop
boolean isDrop()Whether to refuse the connection, per the flood decision.- Returns:
- true if the connection should be rejected
getPercent
int getPercent()The nominal share of inbound connections to refuse.- Returns:
- nominal rejection chance percent (0 renders as "1%")
getLastConnections
int getLastConnections()The accept count the rate was measured against.- Returns:
- baseline connections in the previous full rate period
getCurrentConnectionsPerMinute
int getCurrentConnectionsPerMinute()The accept rate the decision was projected from.- Returns:
- projected current accept rate in connections per minute