You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by GitBox <gi...@apache.org> on 2021/09/21 13:28:48 UTC

[GitHub] [tinkerpop] spmallette commented on a change in pull request #1465: TINKERPOP-2486 Fix load balancing across connections

spmallette commented on a change in pull request #1465:
URL: https://github.com/apache/tinkerpop/pull/1465#discussion_r713040532



##########
File path: gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/driver/ClientConnectionIntegrateTest.java
##########
@@ -107,4 +116,102 @@ public void shouldCloseConnectionDeadDueToUnRecoverableError() throws Exception
         assertThat(recordingAppender.logContainsAny("^(?!.*(isDead=false)).*isDead=true.*destroyed successfully.$"), is(true));
 
     }
+
+    @Test
+    public void shouldBalanceConcurrentRequestsAcrossConnections() throws InterruptedException {
+        final int connPoolSize = 16;
+        final Cluster cluster = TestClientFactory.build()
+                .minConnectionPoolSize(connPoolSize)
+                .maxConnectionPoolSize(connPoolSize)
+                .create();
+        final Client.ClusteredClient client = cluster.connect();
+        client.init();
+        final ExecutorService executorServiceForTesting = cluster.executor();
+
+        try {
+            final RequestMessage.Builder request = client.buildMessage(RequestMessage.build(Tokens.OPS_EVAL))
+                    .add(Tokens.ARGS_GREMLIN, "Thread.sleep(5000)");
+            final Callable<Connection> sendQueryCallable = () -> client.chooseConnection(request.create());
+            final List<Callable<Connection>> listOfTasks = new ArrayList<>();
+            for (int i = 0; i < connPoolSize; i++) {
+                listOfTasks.add(sendQueryCallable);
+            }
+
+            HashMap<String, Integer> channelsSize = new HashMap<>();
+
+            final List<Future<Connection>> executorSubmitFutures = executorServiceForTesting.invokeAll(listOfTasks);
+            executorSubmitFutures.parallelStream().map(fut -> {
+                try {
+                    return fut.get();
+                } catch (InterruptedException | ExecutionException e) {
+                    e.printStackTrace();

Review comment:
       do we explicitly need the stacktrace printed here? could the exception just be ignored or perhaps you could use `log.debug()`? for travis' sake it's nice to keep the console output limited.




-- 
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