Skip to content

Commit

Permalink
Use computation thread pool for getNodeSpecificViews redis#2045
Browse files Browse the repository at this point in the history
Original pull request: redis#2048.
  • Loading branch information
be-hase authored and GilboaAWS committed Apr 3, 2022
1 parent 7fe8c36 commit 3035c3d
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ public CompletionStage<Map<RedisURI, Partitions>> loadViews(Iterable<RedisURI> s
Requests requestedTopology = connections.requestTopology(commandTimeoutNs, TimeUnit.NANOSECONDS);
Requests requestedInfo = connections.requestInfo(commandTimeoutNs, TimeUnit.NANOSECONDS);
return CompletableFuture.allOf(requestedTopology.allCompleted(), requestedInfo.allCompleted())
.thenCompose(ignore -> {

NodeTopologyViews views = getNodeSpecificViews(requestedTopology, requestedInfo);

.thenCompose(ignore -> getNodeSpecificViewsAsync(requestedTopology, requestedInfo))
.thenCompose(views -> {
if (discovery && isEventLoopActive()) {

Set<RedisURI> allKnownUris = views.getClusterNodes();
Expand All @@ -130,10 +128,7 @@ public CompletionStage<Map<RedisURI, Partitions>> loadViews(Iterable<RedisURI> s
.requestInfo(commandTimeoutNs, TimeUnit.NANOSECONDS).mergeWith(requestedInfo);
return CompletableFuture
.allOf(additionalTopology.allCompleted(), additionalClients.allCompleted())
.thenApply(ignore2 -> {

return getNodeSpecificViews(additionalTopology, additionalClients);
});
.thenCompose(ignore2 -> getNodeSpecificViewsAsync(additionalTopology, additionalClients));
});
}

Expand Down Expand Up @@ -286,6 +281,13 @@ NodeTopologyViews getNodeSpecificViews(Requests requestedTopology, Requests requ
return new NodeTopologyViews(views);
}

private CompletableFuture<NodeTopologyViews> getNodeSpecificViewsAsync(Requests requestedTopology, Requests requestedInfo) {
// use computation thread pool
// ref: https://github.com/lettuce-io/lettuce-core/issues/2045
return CompletableFuture.supplyAsync(() -> getNodeSpecificViews(requestedTopology, requestedInfo),
clientResources.eventExecutorGroup());
}

private static boolean validNode(RedisClusterNode redisClusterNode) {

if (redisClusterNode.is(RedisClusterNode.NodeFlag.NOADDR)) {
Expand Down

0 comments on commit 3035c3d

Please sign in to comment.