You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "andreachild (via GitHub)" <gi...@apache.org> on 2024/10/29 22:39:59 UTC
Re: [PR] HTTP connection pooling [tinkerpop]
andreachild commented on code in PR #2860:
URL: https://github.com/apache/tinkerpop/pull/2860#discussion_r1821612969
##########
gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientConnectionIntegrateTest.java:
##########
@@ -292,6 +296,55 @@ public void shouldSucceedWithJitteryConnection() throws Exception {
cluster.close();
}
+ @Test
+ public void shouldCloseIdleConnectionsAndRecreateNewConnections() throws InterruptedException {
+ int idleMillis = 3000;
+ final Cluster cluster = TestClientFactory.build()
+ .idleConnectionTimeoutMillis(idleMillis)
+ .create();
+ final Client.ClusteredClient client = cluster.connect();
+ client.init();
+ final ExecutorService executorServiceForTesting = cluster.executor();
+
+ try {
+ // create or reuse some connections
+ chooseConnections(3, client, executorServiceForTesting);
+
+ // simulate downtime where there is no traffic so that all connections become idle
+ TimeUnit.MILLISECONDS.sleep(idleMillis * 3);
+ assertEquals(1, client.hostConnectionPools.size());
+ // all connections should have been closed due to idle timeout
+ assertTrue(client.hostConnectionPools.values().iterator().next().getPoolInfo().contains("no connections in pool"));
+
+ // create or reuse some more connections
+ chooseConnections(4, client, executorServiceForTesting);
+
+ } finally {
+ executorServiceForTesting.shutdown();
+ client.close();
+ cluster.close();
+ }
+ }
+
+ private static void chooseConnections(int operations, Client.ClusteredClient client, ExecutorService executorServiceForTesting) throws InterruptedException {
+ final RequestMessage.Builder request = client.buildMessage(RequestMessage.build("1+1"));
Review Comment:
Changed to `g.inject(1)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tinkerpop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org