Skip to content

Commit 2c7fe0f

Browse files
arturobernalgok2c
authored andcommitted
Add OFFLOCK pool concurrency policy backed by RouteSegmentedConnPool (#765)
Wire PoolingHttpClientConnectionManager to use RouteSegmentedConnPool when OFFLOCK is selected.
1 parent 1f4dea7 commit 2c7fe0f

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/PoolingHttpClientConnectionManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
import org.apache.hc.core5.pool.PoolEntry;
8080
import org.apache.hc.core5.pool.PoolReusePolicy;
8181
import org.apache.hc.core5.pool.PoolStats;
82+
import org.apache.hc.core5.pool.RouteSegmentedConnPool;
8283
import org.apache.hc.core5.pool.StrictConnPool;
8384
import org.apache.hc.core5.util.Args;
8485
import org.apache.hc.core5.util.Deadline;
@@ -272,6 +273,14 @@ public void closeExpired() {
272273

273274
};
274275
break;
276+
case OFFLOCK:
277+
this.pool = new RouteSegmentedConnPool<>(
278+
DEFAULT_MAX_CONNECTIONS_PER_ROUTE,
279+
DEFAULT_MAX_TOTAL_CONNECTIONS,
280+
timeToLive,
281+
poolReusePolicy,
282+
new DefaultDisposalCallback<>());
283+
break;
275284
default:
276285
throw new IllegalArgumentException("Unexpected PoolConcurrencyPolicy value: " + poolConcurrencyPolicy);
277286
}

httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/PoolingAsyncClientConnectionManager.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
import org.apache.hc.core5.pool.PoolEntry;
8787
import org.apache.hc.core5.pool.PoolReusePolicy;
8888
import org.apache.hc.core5.pool.PoolStats;
89+
import org.apache.hc.core5.pool.RouteSegmentedConnPool;
8990
import org.apache.hc.core5.pool.StrictConnPool;
9091
import org.apache.hc.core5.reactor.Command;
9192
import org.apache.hc.core5.reactor.ConnectionInitiator;
@@ -208,6 +209,14 @@ public void closeExpired() {
208209

209210
};
210211
break;
212+
case OFFLOCK:
213+
managedConnPool = new RouteSegmentedConnPool<>(
214+
DEFAULT_MAX_CONNECTIONS_PER_ROUTE,
215+
DEFAULT_MAX_TOTAL_CONNECTIONS,
216+
timeToLive,
217+
poolReusePolicy,
218+
new DefaultDisposalCallback<>());
219+
break;
211220
default:
212221
throw new IllegalArgumentException("Unexpected PoolConcurrencyPolicy value: " + poolConcurrencyPolicy);
213222
}

0 commit comments

Comments
 (0)