Module SimpleHttpServer
Class ServerSessionThrottler
java.lang.Object
dev.katsute.simplehttpserver.handler.throttler.ServerSessionThrottler
A throttler that limits the amount of simultaneous connections based on individual and total sessions.
- Since:
- 5.0.0
- Version:
- 5.0.0
- Author:
- Katsute
- See Also:
-
Constructor Summary
ConstructorDescriptionServerSessionThrottler
(HttpSessionHandler sessionHandler) Creates a throttler with no total connection limit.ServerSessionThrottler
(HttpSessionHandler sessionHandler, int maxConnections) Creates a throttler with a limit on max total connections. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canIgnoreConnectionLimit
(HttpSession session, SimpleHttpExchange exchange) If true, a session does not contribute to the total server connections and can bypass the maximum limit.int
getMaxConnections
(HttpSession session, SimpleHttpExchange exchange) Returns the maximum number of connections allowed for a session.final int
getMaxConnections
(SimpleHttpExchange exchange) Returns the maximum number of connections allowed for an exchange.final int
Returns the maximum amount of server connections that is allowed.final void
setMaxServerConnections
(int connections) Sets the maximum amount of server connections that is allowed.toString()
-
Constructor Details
-
ServerSessionThrottler
Creates a throttler with no total connection limit.- Parameters:
sessionHandler
- session handler- Since:
- 5.0.0
- See Also:
-
ServerSessionThrottler
Creates a throttler with a limit on max total connections.- Parameters:
sessionHandler
- session handlermaxConnections
- max total connections- Since:
- 5.0.0
- See Also:
-
-
Method Details
-
getMaxConnections
Returns the maximum number of connections allowed for an exchange. Return-1
for unlimited connections.- Parameters:
exchange
- exchange- Returns:
- maximum connections
- See Also:
-
getMaxConnections
Returns the maximum number of connections allowed for a session. Return-1
for unlimited connections.- Parameters:
session
- sessionexchange
- exchange- Returns:
- maximum connections
- Since:
- 5.0.0
- See Also:
-
canIgnoreConnectionLimit
If true, a session does not contribute to the total server connections and can bypass the maximum limit. Still limited bygetMaxConnections(SimpleHttpExchange)
.- Parameters:
session
- sessionexchange
- exchange- Returns:
- if exchange can bypass limit
- Since:
- 5.0.0
- See Also:
-
setMaxServerConnections
public final void setMaxServerConnections(int connections) Sets the maximum amount of server connections that is allowed.- Parameters:
connections
- max connections- Since:
- 5.0.0
- See Also:
-
getMaxServerConnections
public final int getMaxServerConnections()Returns the maximum amount of server connections that is allowed.- Returns:
- max connections
- Since:
- 5.0.0
- See Also:
-
toString
-