Search in sources :

Example 1 with RaftManagedService

use of com.hazelcast.cp.internal.datastructures.spi.RaftManagedService in project hazelcast by hazelcast.

the class RaftService method resetLocalRaftState.

private void resetLocalRaftState() {
    // node.forceSetTerminatedStatus() will trigger RaftNodeLifecycleAwareService.onRaftGroupDestroyed()
    // which will attempt to acquire the read lock on nodeLock. In order to prevent it, we first
    // add group ids into destroyedGroupIds to short-cut RaftNodeLifecycleAwareService.onRaftGroupDestroyed()
    List<InternalCompletableFuture> futures = new ArrayList<>(nodes.size());
    destroyedGroupIds.addAll(nodes.keySet());
    for (RaftNode node : nodes.values()) {
        InternalCompletableFuture f = node.forceSetTerminatedStatus();
        futures.add(f);
    }
    for (InternalCompletableFuture future : futures) {
        try {
            future.get();
        } catch (Exception e) {
            logger.warning(e);
        }
    }
    nodes.clear();
    for (ServiceInfo serviceInfo : nodeEngine.getServiceInfos(RaftRemoteService.class)) {
        if (serviceInfo.getService() instanceof RaftManagedService) {
            ((RaftManagedService) serviceInfo.getService()).onCPSubsystemRestart();
        }
    }
    nodeMetrics.clear();
    missingMembers.clear();
    invocationManager.reset();
}
Also used : ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) ArrayList(java.util.ArrayList) RaftManagedService(com.hazelcast.cp.internal.datastructures.spi.RaftManagedService) RaftNode(com.hazelcast.cp.internal.raft.impl.RaftNode) RaftNodeImpl.newRaftNode(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl.newRaftNode) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException) CPGroupDestroyedException(com.hazelcast.cp.exception.CPGroupDestroyedException) ExecutionException(java.util.concurrent.ExecutionException) CannotRemoveCPMemberException(com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException) ResponseAlreadySentException(com.hazelcast.spi.exception.ResponseAlreadySentException)

Aggregations

CPGroupDestroyedException (com.hazelcast.cp.exception.CPGroupDestroyedException)1 RaftManagedService (com.hazelcast.cp.internal.datastructures.spi.RaftManagedService)1 CannotRemoveCPMemberException (com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException)1 RaftNode (com.hazelcast.cp.internal.raft.impl.RaftNode)1 RaftNodeImpl.newRaftNode (com.hazelcast.cp.internal.raft.impl.RaftNodeImpl.newRaftNode)1 PartitionMigratingException (com.hazelcast.spi.exception.PartitionMigratingException)1 ResponseAlreadySentException (com.hazelcast.spi.exception.ResponseAlreadySentException)1 InternalCompletableFuture (com.hazelcast.spi.impl.InternalCompletableFuture)1 ServiceInfo (com.hazelcast.spi.impl.servicemanager.ServiceInfo)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1