Search in sources :

Example 1 with RebalanceStatusRequestCommand

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;
}
Also used : ReplicableCommand(org.infinispan.commands.ReplicableCommand) RebalanceStatusRequestCommand(org.infinispan.commands.topology.RebalanceStatusRequestCommand)

Example 2 with RebalanceStatusRequestCommand

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());
}
Also used : CompletionStages.join(org.infinispan.util.concurrent.CompletionStages.join) GlobalStateManager(org.infinispan.globalstate.GlobalStateManager) ComponentName(org.infinispan.factories.annotations.ComponentName) LogFactory(org.infinispan.util.logging.LogFactory) GlobalConfiguration(org.infinispan.configuration.global.GlobalConfiguration) PartitionHandling(org.infinispan.partitionhandling.PartitionHandling) ViewChangedEvent(org.infinispan.notifications.cachemanagerlistener.event.ViewChangedEvent) Stop(org.infinispan.factories.annotations.Stop) Scopes(org.infinispan.factories.scopes.Scopes) ActionSequencer(org.infinispan.util.concurrent.ActionSequencer) CompletableFutures(org.infinispan.util.concurrent.CompletableFutures) CacheShutdownCommand(org.infinispan.commands.topology.CacheShutdownCommand) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) Scope(org.infinispan.factories.scopes.Scope) InfinispanCollections(org.infinispan.commons.util.InfinispanCollections) LostDataCheck(org.infinispan.partitionhandling.impl.LostDataCheck) EventLogger(org.infinispan.util.logging.events.EventLogger) Listener(org.infinispan.notifications.Listener) ConsistentHash(org.infinispan.distribution.ch.ConsistentHash) GlobalComponentRegistry(org.infinispan.factories.GlobalComponentRegistry) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ValidResponseCollector(org.infinispan.remoting.transport.ValidResponseCollector) Set(java.util.Set) PreferAvailabilityStrategy(org.infinispan.partitionhandling.impl.PreferAvailabilityStrategy) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) PreferConsistencyStrategy(org.infinispan.partitionhandling.impl.PreferConsistencyStrategy) ProcessorInfo(org.infinispan.commons.util.ProcessorInfo) RebalanceType(org.infinispan.statetransfer.RebalanceType) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) CLUSTER(org.infinispan.util.logging.Log.CLUSTER) Entry(java.util.Map.Entry) GuardedBy(net.jcip.annotations.GuardedBy) Optional(java.util.Optional) ConditionFuture(org.infinispan.util.concurrent.ConditionFuture) AvailabilityStrategy(org.infinispan.partitionhandling.impl.AvailabilityStrategy) RebalanceStatusRequestCommand(org.infinispan.commands.topology.RebalanceStatusRequestCommand) AvailabilityMode(org.infinispan.partitionhandling.AvailabilityMode) TimeoutException(org.infinispan.util.concurrent.TimeoutException) TIMEOUT_SCHEDULE_EXECUTOR(org.infinispan.factories.KnownComponentNames.TIMEOUT_SCHEDULE_EXECUTOR) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) CompletableFuture(java.util.concurrent.CompletableFuture) CompletionStages(org.infinispan.util.concurrent.CompletionStages) Function(java.util.function.Function) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) Start(org.infinispan.factories.annotations.Start) HashSet(java.util.HashSet) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) EventLogCategory(org.infinispan.util.logging.events.EventLogCategory) Log(org.infinispan.util.logging.Log) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) VoidResponseCollector(org.infinispan.remoting.transport.impl.VoidResponseCollector) CacheStatusRequestCommand(org.infinispan.commands.topology.CacheStatusRequestCommand) ExecutorService(java.util.concurrent.ExecutorService) Merged(org.infinispan.notifications.cachemanagerlistener.annotation.Merged) Address(org.infinispan.remoting.transport.Address) ResponseCollectors(org.infinispan.remoting.transport.ResponseCollectors) ConfigurationManager(org.infinispan.configuration.ConfigurationManager) CompletableFuture.runAsync(java.util.concurrent.CompletableFuture.runAsync) ReplicableCommand(org.infinispan.commands.ReplicableCommand) Transport(org.infinispan.remoting.transport.Transport) ReentrantLock(java.util.concurrent.locks.ReentrantLock) ScopedPersistentState(org.infinispan.globalstate.ScopedPersistentState) EventLogManager(org.infinispan.util.logging.events.EventLogManager) TopologyUpdateCommand(org.infinispan.commands.topology.TopologyUpdateCommand) TopologyUpdateStableCommand(org.infinispan.commands.topology.TopologyUpdateStableCommand) MESSAGES(org.infinispan.util.logging.events.Messages.MESSAGES) ValidResponse(org.infinispan.remoting.responses.ValidResponse) NON_BLOCKING_EXECUTOR(org.infinispan.factories.KnownComponentNames.NON_BLOCKING_EXECUTOR) Inject(org.infinispan.factories.annotations.Inject) CacheManagerNotifier(org.infinispan.notifications.cachemanagerlistener.CacheManagerNotifier) ViewChanged(org.infinispan.notifications.cachemanagerlistener.annotation.ViewChanged) IllegalLifecycleStateException(org.infinispan.commons.IllegalLifecycleStateException) Lock(java.util.concurrent.locks.Lock) CacheMode(org.infinispan.configuration.cache.CacheMode) RebalanceStartCommand(org.infinispan.commands.topology.RebalanceStartCommand) Configuration(org.infinispan.configuration.cache.Configuration) DeliverOrder(org.infinispan.remoting.inboundhandler.DeliverOrder) TimeService(org.infinispan.commons.time.TimeService) LimitedExecutor(org.infinispan.executors.LimitedExecutor) AggregateCompletionStage(org.infinispan.util.concurrent.AggregateCompletionStage) Address(org.infinispan.remoting.transport.Address) ReplicableCommand(org.infinispan.commands.ReplicableCommand) RebalanceStatusRequestCommand(org.infinispan.commands.topology.RebalanceStatusRequestCommand) TimeoutException(org.infinispan.util.concurrent.TimeoutException)

Aggregations

ReplicableCommand (org.infinispan.commands.ReplicableCommand)2 RebalanceStatusRequestCommand (org.infinispan.commands.topology.RebalanceStatusRequestCommand)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Callable (java.util.concurrent.Callable)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 CompletableFuture.runAsync (java.util.concurrent.CompletableFuture.runAsync)1 CompletionStage (java.util.concurrent.CompletionStage)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1