java.lang.Object
org.miaixz.bus.http.accord.ConnectionPool
Manages reuse of HTTP and HTTP/2 connections for reduced network latency. HTTP requests that share the same
Address may share a Connection. This class implements the policy of which connections to keep open
for future use.- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal RealConnectionPoolThe real connection pool implementation. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new connection pool with tuning parameters appropriate for a single-user application.ConnectionPool(int maxIdleConnections, long keepAliveDuration, TimeUnit timeUnit) -
Method Summary
Modifier and TypeMethodDescriptionintReturns the total number of connections in the pool.voidevictAll()Closes and removes all idle connections in the pool.intReturns the number of idle connections in the pool.
-
Field Details
-
delegate
The real connection pool implementation.
-
-
Constructor Details
-
ConnectionPool
public ConnectionPool()Create a new connection pool with tuning parameters appropriate for a single-user application. The tuning parameters in this pool may change in future Httpd releases. Currently this pool holds up to 5 idle connections which will be evicted after 5 minutes of inactivity. -
ConnectionPool
-
-
Method Details
-
idleConnectionCount
public int idleConnectionCount()Returns the number of idle connections in the pool.- Returns:
- The number of idle connections.
-
connectionCount
public int connectionCount()Returns the total number of connections in the pool. Note that prior to Httpd 2.7 this included only idle connections and HTTP/2 connections. Since Httpd 2.7 this includes all connections, both active and inactive. UseidleConnectionCount()to count connections that are currently unused.- Returns:
- The total number of connections.
-
evictAll
public void evictAll()Closes and removes all idle connections in the pool.
-