Search in sources :

Example 1 with CannotRemoveCPMemberException

use of com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException in project hazelcast by hazelcast.

the class RaftService method removeCPMember.

public InternalCompletableFuture<Void> removeCPMember(UUID cpMemberUuid) {
    ClusterService clusterService = nodeEngine.getClusterService();
    InternalCompletableFuture<Void> future = newCompletableFuture();
    BiConsumer<Void, Throwable> removeMemberCallback = (response, t) -> {
        if (t == null) {
            future.complete(null);
        } else {
            if (t instanceof CannotRemoveCPMemberException) {
                t = new IllegalStateException(t.getMessage());
            }
            complete(future, t);
        }
    };
    invocationManager.<Collection<CPMember>>invoke(getMetadataGroupId(), new GetActiveCPMembersOp()).whenCompleteAsync((cpMembers, t) -> {
        if (t == null) {
            CPMemberInfo cpMemberToRemove = null;
            for (CPMember cpMember : cpMembers) {
                if (cpMember.getUuid().equals(cpMemberUuid)) {
                    cpMemberToRemove = (CPMemberInfo) cpMember;
                    break;
                }
            }
            if (cpMemberToRemove == null) {
                complete(future, new IllegalArgumentException("No CPMember found with uuid: " + cpMemberUuid));
                return;
            } else {
                Member member = clusterService.getMember(cpMemberToRemove.getAddress());
                if (member != null) {
                    logger.warning("Only unreachable/crashed CP members should be removed. " + member + " is alive but " + cpMemberToRemove + " with the same address is being removed.");
                }
            }
            invokeTriggerRemoveMember(cpMemberToRemove).whenCompleteAsync(removeMemberCallback);
        } else {
            complete(future, t);
        }
    });
    return future;
}
Also used : RaftNodeStatus(com.hazelcast.cp.internal.raft.impl.RaftNodeStatus) AppendSuccessResponse(com.hazelcast.cp.internal.raft.impl.dto.AppendSuccessResponse) Clock(com.hazelcast.internal.util.Clock) CP_METRIC_RAFT_SERVICE_TERMINATED_RAFT_NODE_GROUP_IDS(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_METRIC_RAFT_SERVICE_TERMINATED_RAFT_NODE_GROUP_IDS) InstallSnapshot(com.hazelcast.cp.internal.raft.impl.dto.InstallSnapshot) RaftIntegration(com.hazelcast.cp.internal.raft.impl.RaftIntegration) ManagedService(com.hazelcast.internal.services.ManagedService) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) VoteResponse(com.hazelcast.cp.internal.raft.impl.dto.VoteResponse) ClusterService(com.hazelcast.internal.cluster.ClusterService) Future(java.util.concurrent.Future) CPGroup(com.hazelcast.cp.CPGroup) CPGroupDestroyedException(com.hazelcast.cp.exception.CPGroupDestroyedException) RaftNodeImpl(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl) Map(java.util.Map) CPSubsystemConfig(com.hazelcast.config.cp.CPSubsystemConfig) RaftAlgorithmConfig(com.hazelcast.config.cp.RaftAlgorithmConfig) StringUtil.equalsIgnoreCase(com.hazelcast.internal.util.StringUtil.equalsIgnoreCase) CP_PREFIX_RAFT_METADATA(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_PREFIX_RAFT_METADATA) ReadWriteLock(java.util.concurrent.locks.ReadWriteLock) RaftRemoteService(com.hazelcast.cp.internal.datastructures.spi.RaftRemoteService) CPPersistenceService(com.hazelcast.cp.internal.persistence.CPPersistenceService) ExceptionUtil(com.hazelcast.internal.util.ExceptionUtil) Set(java.util.Set) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) CP_PREFIX_RAFT_GROUP(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_PREFIX_RAFT_GROUP) EventListener(java.util.EventListener) PartitionReplicationEvent(com.hazelcast.internal.partition.PartitionReplicationEvent) CPMember(com.hazelcast.cp.CPMember) CP_DISCRIMINATOR_GROUPID(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_DISCRIMINATOR_GROUPID) GetActiveRaftGroupIdsOp(com.hazelcast.cp.internal.raftop.metadata.GetActiveRaftGroupIdsOp) CPGroupAvailabilityEventImpl(com.hazelcast.cp.event.impl.CPGroupAvailabilityEventImpl) Versions(com.hazelcast.internal.cluster.Versions) GetInitialRaftGroupMembersIfCurrentGroupMemberOp(com.hazelcast.cp.internal.raftop.GetInitialRaftGroupMembersIfCurrentGroupMemberOp) CP_METRIC_RAFT_SERVICE_NODES(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_METRIC_RAFT_SERVICE_NODES) RaftManagedService(com.hazelcast.cp.internal.datastructures.spi.RaftManagedService) VoteRequest(com.hazelcast.cp.internal.raft.impl.dto.VoteRequest) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) ArrayList(java.util.ArrayList) MigrationEndpoint(com.hazelcast.internal.partition.MigrationEndpoint) CP_PREFIX_RAFT(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_PREFIX_RAFT) SYSTEM_EXECUTOR(com.hazelcast.spi.impl.executionservice.ExecutionService.SYSTEM_EXECUTOR) RestoredRaftState(com.hazelcast.cp.internal.raft.impl.persistence.RestoredRaftState) LINEARIZABLE(com.hazelcast.cp.internal.raft.QueryPolicy.LINEARIZABLE) BiConsumer(java.util.function.BiConsumer) CPMembershipListener(com.hazelcast.cp.event.CPMembershipListener) RaftNode(com.hazelcast.cp.internal.raft.impl.RaftNode) GetRaftGroupIdsOp(com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupIdsOp) MembershipServiceEvent(com.hazelcast.internal.services.MembershipServiceEvent) DEFAULT_GROUP_NAME(com.hazelcast.cp.CPGroup.DEFAULT_GROUP_NAME) NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) RaftState(com.hazelcast.cp.internal.raft.impl.state.RaftState) InternalCompletableFuture.newCompletedFuture(com.hazelcast.spi.impl.InternalCompletableFuture.newCompletedFuture) Properties(java.util.Properties) RaftLog(com.hazelcast.cp.internal.raft.impl.log.RaftLog) MetricsCollectionContext(com.hazelcast.internal.metrics.MetricsCollectionContext) MembershipAwareService(com.hazelcast.internal.services.MembershipAwareService) Preconditions.checkNotNull(com.hazelcast.internal.util.Preconditions.checkNotNull) GetActiveCPMembersOp(com.hazelcast.cp.internal.raftop.metadata.GetActiveCPMembersOp) ExecutionException(java.util.concurrent.ExecutionException) AddCPMemberOp(com.hazelcast.cp.internal.raftop.metadata.AddCPMemberOp) CPGroupAvailabilityEvent(com.hazelcast.cp.event.CPGroupAvailabilityEvent) ManagedExecutorService(com.hazelcast.internal.util.executor.ManagedExecutorService) RaftStateStore(com.hazelcast.cp.internal.raft.impl.persistence.RaftStateStore) Member(com.hazelcast.cluster.Member) ResetCPMemberOp(com.hazelcast.cp.internal.operation.ResetCPMemberOp) PreVoteRequest(com.hazelcast.cp.internal.raft.impl.dto.PreVoteRequest) ForceDestroyRaftGroupOp(com.hazelcast.cp.internal.raftop.metadata.ForceDestroyRaftGroupOp) SnapshotAwareService(com.hazelcast.cp.internal.raft.SnapshotAwareService) RaftServicePreJoinOp(com.hazelcast.cp.internal.raftop.metadata.RaftServicePreJoinOp) InternalCompletableFuture(com.hazelcast.spi.impl.InternalCompletableFuture) AppendFailureResponse(com.hazelcast.cp.internal.raft.impl.dto.AppendFailureResponse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CPGroupAvailabilityListener(com.hazelcast.cp.event.CPGroupAvailabilityListener) CannotRemoveCPMemberException(com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException) DynamicMetricsProvider(com.hazelcast.internal.metrics.DynamicMetricsProvider) GetRaftGroupOp(com.hazelcast.cp.internal.raftop.metadata.GetRaftGroupOp) ProbeLevel(com.hazelcast.internal.metrics.ProbeLevel) CP_METRIC_RAFT_SERVICE_DESTROYED_GROUP_IDS(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_METRIC_RAFT_SERVICE_DESTROYED_GROUP_IDS) Preconditions.checkTrue(com.hazelcast.internal.util.Preconditions.checkTrue) ResponseAlreadySentException(com.hazelcast.spi.exception.ResponseAlreadySentException) UnsafeStateReplicationOp(com.hazelcast.cp.internal.operation.unsafe.UnsafeStateReplicationOp) RaftEndpoint(com.hazelcast.cp.internal.raft.impl.RaftEndpoint) ServiceInfo(com.hazelcast.spi.impl.servicemanager.ServiceInfo) LogFileStructure(com.hazelcast.cp.internal.raft.impl.persistence.LogFileStructure) Probe(com.hazelcast.internal.metrics.Probe) Collection(java.util.Collection) METADATA_CP_GROUP_NAME(com.hazelcast.cp.CPGroup.METADATA_CP_GROUP_NAME) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) TriggerLeaderElection(com.hazelcast.cp.internal.raft.impl.dto.TriggerLeaderElection) RaftRole(com.hazelcast.cp.internal.raft.impl.RaftRole) MetricsPlugin(com.hazelcast.internal.diagnostics.MetricsPlugin) UUID(java.util.UUID) RaftNodeImpl.newRaftNode(com.hazelcast.cp.internal.raft.impl.RaftNodeImpl.newRaftNode) List(java.util.List) LEADER_LOCAL(com.hazelcast.cp.internal.raft.QueryPolicy.LEADER_LOCAL) Entry(java.util.Map.Entry) Preconditions.checkFalse(com.hazelcast.internal.util.Preconditions.checkFalse) CP_METRIC_RAFT_SERVICE_MISSING_MEMBERS(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_METRIC_RAFT_SERVICE_MISSING_MEMBERS) PartitionMigrationEvent(com.hazelcast.internal.partition.PartitionMigrationEvent) MetricsRegistry(com.hazelcast.internal.metrics.MetricsRegistry) ExecutionService(com.hazelcast.spi.impl.executionservice.ExecutionService) UuidUtil.newUnsecureUUID(com.hazelcast.internal.util.UuidUtil.newUnsecureUUID) MigrationAwareService(com.hazelcast.internal.partition.MigrationAwareService) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) PartitionOperationThread(com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread) ConcurrentMap(java.util.concurrent.ConcurrentMap) AppendRequest(com.hazelcast.cp.internal.raft.impl.dto.AppendRequest) MetricDescriptor(com.hazelcast.internal.metrics.MetricDescriptor) Collections.newSetFromMap(java.util.Collections.newSetFromMap) CPMembershipEvent(com.hazelcast.cp.event.CPMembershipEvent) ILogger(com.hazelcast.logging.ILogger) Operation(com.hazelcast.spi.impl.operationservice.Operation) EventPublishingService(com.hazelcast.spi.impl.eventservice.EventPublishingService) CPGroupId(com.hazelcast.cp.CPGroupId) Timer(com.hazelcast.internal.util.Timer) NodeEngine(com.hazelcast.spi.impl.NodeEngine) GetActiveRaftGroupByNameOp(com.hazelcast.cp.internal.raftop.metadata.GetActiveRaftGroupByNameOp) Data(com.hazelcast.internal.serialization.Data) NON_LOCAL_MEMBER_SELECTOR(com.hazelcast.cluster.memberselector.MemberSelectors.NON_LOCAL_MEMBER_SELECTOR) RemoveCPMemberOp(com.hazelcast.cp.internal.raftop.metadata.RemoveCPMemberOp) Preconditions.checkState(com.hazelcast.internal.util.Preconditions.checkState) ConfigValidator.checkCPSubsystemConfig(com.hazelcast.internal.config.ConfigValidator.checkCPSubsystemConfig) CP_TAG_NAME(com.hazelcast.internal.metrics.MetricDescriptorConstants.CP_TAG_NAME) TimeUnit(java.util.concurrent.TimeUnit) PreVoteResponse(com.hazelcast.cp.internal.raft.impl.dto.PreVoteResponse) GracefulShutdownAwareService(com.hazelcast.internal.services.GracefulShutdownAwareService) PreJoinAwareService(com.hazelcast.internal.services.PreJoinAwareService) Collections(java.util.Collections) SECONDS(java.util.concurrent.TimeUnit.SECONDS) MANAGEMENT_TASK_PERIOD_IN_MILLIS(com.hazelcast.cp.internal.RaftGroupMembershipManager.MANAGEMENT_TASK_PERIOD_IN_MILLIS) CannotRemoveCPMemberException(com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException) GetActiveCPMembersOp(com.hazelcast.cp.internal.raftop.metadata.GetActiveCPMembersOp) CPMember(com.hazelcast.cp.CPMember) ClusterService(com.hazelcast.internal.cluster.ClusterService) CPMember(com.hazelcast.cp.CPMember) Member(com.hazelcast.cluster.Member)

Aggregations

Member (com.hazelcast.cluster.Member)1 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)1 NON_LOCAL_MEMBER_SELECTOR (com.hazelcast.cluster.memberselector.MemberSelectors.NON_LOCAL_MEMBER_SELECTOR)1 CPSubsystemConfig (com.hazelcast.config.cp.CPSubsystemConfig)1 RaftAlgorithmConfig (com.hazelcast.config.cp.RaftAlgorithmConfig)1 CPGroup (com.hazelcast.cp.CPGroup)1 DEFAULT_GROUP_NAME (com.hazelcast.cp.CPGroup.DEFAULT_GROUP_NAME)1 METADATA_CP_GROUP_NAME (com.hazelcast.cp.CPGroup.METADATA_CP_GROUP_NAME)1 CPGroupId (com.hazelcast.cp.CPGroupId)1 CPMember (com.hazelcast.cp.CPMember)1 CPGroupAvailabilityEvent (com.hazelcast.cp.event.CPGroupAvailabilityEvent)1 CPGroupAvailabilityListener (com.hazelcast.cp.event.CPGroupAvailabilityListener)1 CPMembershipEvent (com.hazelcast.cp.event.CPMembershipEvent)1 CPMembershipListener (com.hazelcast.cp.event.CPMembershipListener)1 CPGroupAvailabilityEventImpl (com.hazelcast.cp.event.impl.CPGroupAvailabilityEventImpl)1 CPGroupDestroyedException (com.hazelcast.cp.exception.CPGroupDestroyedException)1 MANAGEMENT_TASK_PERIOD_IN_MILLIS (com.hazelcast.cp.internal.RaftGroupMembershipManager.MANAGEMENT_TASK_PERIOD_IN_MILLIS)1 RaftManagedService (com.hazelcast.cp.internal.datastructures.spi.RaftManagedService)1 RaftRemoteService (com.hazelcast.cp.internal.datastructures.spi.RaftRemoteService)1 CannotRemoveCPMemberException (com.hazelcast.cp.internal.exception.CannotRemoveCPMemberException)1