use of org.infinispan.commands.topology.RebalanceStatusRequestCommand in project infinispan by infinispan.
the class LocalCacheStatus method isCacheRebalancingEnabled.
@Override
public boolean isCacheRebalancingEnabled(String cacheName) {
int viewId = transport.getViewId();
ReplicableCommand command = new RebalanceStatusRequestCommand(cacheName);
RebalancingStatus status = (RebalancingStatus) CompletionStages.join(executeOnCoordinatorRetry(command, viewId, timeService.expectedEndTime(getGlobalTimeout(), MILLISECONDS)));
return status != RebalancingStatus.SUSPENDED;
}
use of org.infinispan.commands.topology.RebalanceStatusRequestCommand in project infinispan by infinispan.
the class ClusterTopologyManagerImpl method fetchRebalancingStatusFromCoordinator.
private CompletionStage<Boolean> fetchRebalancingStatusFromCoordinator(int attempts) {
if (transport.isCoordinator()) {
return CompletableFutures.completedTrue();
}
ReplicableCommand command = new RebalanceStatusRequestCommand();
Address coordinator = transport.getCoordinator();
return helper.executeOnCoordinator(transport, command, getGlobalTimeout() / INITIAL_CONNECTION_ATTEMPTS).handle((rebalancingStatus, throwable) -> {
if (throwable == null)
return CompletableFuture.completedFuture(rebalancingStatus != RebalancingStatus.SUSPENDED);
if (attempts == 1 || !(throwable instanceof TimeoutException)) {
log.errorReadingRebalancingStatus(coordinator, throwable);
return CompletableFutures.completedTrue();
}
// Assume any timeout is because the coordinator doesn't have a CommandAwareRpcDispatcher yet
// (possible with ForkChannels or JGroupsChannelLookup and shouldConnect = false), and retry.
log.debug("Timed out waiting for rebalancing status from coordinator, trying again");
return fetchRebalancingStatusFromCoordinator(attempts - 1);
}).thenCompose(Function.identity());
}
Aggregations