Search in sources :

Example 1 with LimitedExecutor

use of org.infinispan.executors.LimitedExecutor in project infinispan by infinispan.

the class StateConsumerImpl method start.

// Must run after the PersistenceManager
@Start(priority = 20)
public void start() {
    cacheName = cache.wired().getName();
    isInvalidationMode = configuration.clustering().cacheMode().isInvalidation();
    isTransactional = configuration.transaction().transactionMode().isTransactional();
    timeout = configuration.clustering().stateTransfer().timeout();
    numSegments = configuration.clustering().hash().numSegments();
    isFetchEnabled = isFetchEnabled(configuration.persistence().fetchPersistentState());
    rpcOptions = new RpcOptions(DeliverOrder.NONE, timeout, TimeUnit.MILLISECONDS);
    stateRequestExecutor = new LimitedExecutor("StateRequest-" + cacheName, nonBlockingExecutor, 1);
    persistenceManager.addStoreListener(storeChangeListener);
    running = true;
}
Also used : RpcOptions(org.infinispan.remoting.rpc.RpcOptions) LimitedExecutor(org.infinispan.executors.LimitedExecutor) Start(org.infinispan.factories.annotations.Start)

Example 2 with LimitedExecutor

use of org.infinispan.executors.LimitedExecutor in project infinispan by infinispan.

the class ClusterTopologyManagerImpl method recoverClusterStatus.

private CompletionStage<Void> recoverClusterStatus(int newViewId) {
    // Clean up leftover cache status information from the last time we were coordinator.
    // E.g. if the local node was coordinator, started a rebalance, and then lost coordinator
    // status because of a merge, the existing cache statuses may have a rebalance in progress.
    cacheStatusMap.clear();
    recoveryAttemptCount.set(0);
    return fetchClusterStatus(newViewId).thenCompose(responseCollector -> {
        Map<String, Map<Address, CacheStatusResponse>> responsesByCache = responseCollector.getResponsesByCache();
        log.debugf("Cluster recovery found %d caches, members are %s", responsesByCache.size(), transport.getMembers());
        // Compute the new consistent hashes on separate threads
        int maxThreads = ProcessorInfo.availableProcessors() / 2 + 1;
        AggregateCompletionStage<Void> mergeStage = CompletionStages.aggregateCompletionStage();
        LimitedExecutor cs = new LimitedExecutor("Merge-" + newViewId, nonBlockingExecutor, maxThreads);
        for (final Entry<String, Map<Address, CacheStatusResponse>> e : responsesByCache.entrySet()) {
            CacheJoinInfo joinInfo = e.getValue().values().iterator().next().getCacheJoinInfo();
            ClusterCacheStatus cacheStatus = initCacheStatusIfAbsent(e.getKey(), joinInfo.getCacheMode());
            mergeStage.dependsOn(runAsync(() -> cacheStatus.doMergePartitions(e.getValue()), cs));
        }
        return mergeStage.freeze().thenRun(() -> {
            acquireUpdateLock();
            try {
                if (viewId != newViewId) {
                    log.debugf("View updated while we were recovering the cluster for view %d", newViewId);
                    return;
                }
                clusterManagerStatus = ClusterManagerStatus.COORDINATOR;
                globalRebalancingEnabled = responseCollector.getRebalancingEnabled();
            } finally {
                releaseUpdateLock();
            }
            for (ClusterCacheStatus cacheStatus : cacheStatusMap.values()) {
                orderOnCache(cacheStatus.getCacheName(), () -> {
                    try {
                        cacheStatus.doHandleClusterView(newViewId);
                    } catch (Throwable throwable) {
                        if (clusterManagerStatus.isRunning()) {
                            log.errorUpdatingMembersList(newViewId, throwable);
                        }
                    }
                });
            }
            // Unblock any joiners waiting for the view
            joinViewFuture.updateAsync(this, nonBlockingExecutor);
        });
    });
}
Also used : LimitedExecutor(org.infinispan.executors.LimitedExecutor) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Example 3 with LimitedExecutor

use of org.infinispan.executors.LimitedExecutor in project infinispan by infinispan.

the class StateReceiverImpl method start.

@Start
public void start() {
    cacheNotifier.addListener(this);
    stateReceiverExecutor = new LimitedExecutor("StateReceiver-" + cacheName, nonBlockingExecutor, 1);
}
Also used : LimitedExecutor(org.infinispan.executors.LimitedExecutor) Start(org.infinispan.factories.annotations.Start)

Aggregations

LimitedExecutor (org.infinispan.executors.LimitedExecutor)3 Start (org.infinispan.factories.annotations.Start)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 RpcOptions (org.infinispan.remoting.rpc.RpcOptions)1