use of org.infinispan.client.hotrod.FailoverRequestBalancingStrategy in project infinispan by infinispan.
the class ChannelFactory method fetchChannelAndInvoke.
public <T extends ChannelOperation> T fetchChannelAndInvoke(Set<SocketAddress> failedServers, byte[] cacheName, T operation) {
SocketAddress server;
// Need the write lock because FailoverRequestBalancingStrategy is not thread-safe
lock.writeLock().lock();
try {
if (failedServers != null) {
CompletableFuture<Void> switchStage = this.clusterSwitchStage;
if (switchStage != null) {
switchStage.whenComplete((__, t) -> fetchChannelAndInvoke(failedServers, cacheName, operation));
return operation;
}
}
CacheInfo cacheInfo = topologyInfo.getCacheInfo(wrapBytes(cacheName));
FailoverRequestBalancingStrategy balancer = cacheInfo.getBalancer();
server = balancer.nextServer(failedServers);
} finally {
lock.writeLock().unlock();
}
return fetchChannelAndInvoke(server, operation);
}
Aggregations