Search in sources :

Example 31 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.

the class ClusterServiceImpl method removeMember.

private void removeMember(MemberImpl deadMember) {
    logger.info("Removing " + deadMember);
    lock.lock();
    try {
        MemberMap currentMembers = memberMapRef.get();
        final Address deadAddress = deadMember.getAddress();
        if (currentMembers.contains(deadAddress)) {
            clusterHeartbeatManager.removeMember(deadMember);
            MemberMap newMembers = MemberMap.cloneExcluding(currentMembers, deadMember);
            memberMapRef.set(newMembers);
            if (node.isMaster()) {
                if (logger.isFineEnabled()) {
                    logger.fine(deadMember + " is dead, sending remove to all other members...");
                }
                sendMemberRemoveOperation(deadMember);
            }
            final ClusterState clusterState = clusterStateManager.getState();
            if (clusterState != ClusterState.ACTIVE) {
                if (logger.isFineEnabled()) {
                    logger.fine(deadMember + " is dead, added to members left while cluster is " + clusterState + " state");
                }
                final InternalHotRestartService hotRestartService = node.getNodeExtension().getInternalHotRestartService();
                if (!hotRestartService.isMemberExcluded(deadAddress, deadMember.getUuid())) {
                    MemberMap membersRemovedInNotActiveState = membersRemovedInNotActiveStateRef.get();
                    membersRemovedInNotActiveStateRef.set(MemberMap.cloneAdding(membersRemovedInNotActiveState, deadMember));
                }
                InternalPartitionServiceImpl partitionService = node.partitionService;
                partitionService.cancelReplicaSyncRequestsTo(deadAddress);
            } else {
                onMemberRemove(deadMember, newMembers);
            }
            // async events
            sendMembershipEventNotifications(deadMember, unmodifiableSet(new LinkedHashSet<Member>(newMembers.getMembers())), false);
        }
    } finally {
        lock.unlock();
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ClusterState(com.hazelcast.cluster.ClusterState) Address(com.hazelcast.nio.Address) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) InternalHotRestartService(com.hazelcast.hotrestart.InternalHotRestartService)

Example 32 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.

the class ShutdownRequestOperation method run.

@Override
public void run() {
    InternalPartitionServiceImpl partitionService = getService();
    final ILogger logger = getLogger();
    final Address caller = getCallerAddress();
    final NodeEngine nodeEngine = getNodeEngine();
    final ClusterService clusterService = nodeEngine.getClusterService();
    if (clusterService.isMaster()) {
        if (clusterService.getMember(caller) != null) {
            if (logger.isFinestEnabled()) {
                logger.finest("Received shutdown request from " + caller);
            }
            partitionService.onShutdownRequest(caller);
        } else {
            logger.warning("Ignoring shutdown request from " + caller + " because it is not a member");
        }
    } else {
        logger.warning("Received shutdown request from " + caller + " but this node is not master.");
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.nio.Address) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) ILogger(com.hazelcast.logging.ILogger)

Example 33 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.

the class ShutdownResponseOperation method run.

@Override
public void run() {
    InternalPartitionServiceImpl partitionService = getService();
    final ILogger logger = getLogger();
    final Address caller = getCallerAddress();
    final NodeEngine nodeEngine = getNodeEngine();
    final ClusterService clusterService = nodeEngine.getClusterService();
    final Address masterAddress = clusterService.getMasterAddress();
    if (nodeEngine.isRunning()) {
        logger.severe("Received a shutdown response from " + caller + ", but this node is not shutting down!");
        return;
    }
    boolean fromMaster = masterAddress.equals(caller);
    if (fromMaster) {
        if (logger.isFinestEnabled()) {
            logger.finest("Received shutdown response from " + caller);
        }
        partitionService.onShutdownResponse();
    } else {
        logger.warning("Received shutdown response from " + caller + " but known master is: " + masterAddress);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.nio.Address) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) ILogger(com.hazelcast.logging.ILogger)

Example 34 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.

the class PartitionLostListenerTest method test_allPartitionLostListenersInvoked.

@Test
public void test_allPartitionLostListenersInvoked() {
    HazelcastInstance instance1 = instances[0];
    HazelcastInstance instance2 = instances[1];
    final EventCollectingPartitionLostListener listener1 = new EventCollectingPartitionLostListener();
    final EventCollectingPartitionLostListener listener2 = new EventCollectingPartitionLostListener();
    instance1.getPartitionService().addPartitionLostListener(listener1);
    instance2.getPartitionService().addPartitionLostListener(listener2);
    final IPartitionLostEvent internalEvent = new IPartitionLostEvent(1, 0, null);
    NodeEngineImpl nodeEngine = getNode(instance1).getNodeEngine();
    InternalPartitionServiceImpl partitionService = (InternalPartitionServiceImpl) nodeEngine.getPartitionService();
    partitionService.onPartitionLost(internalEvent);
    assertEventEventually(listener1, internalEvent);
    assertEventEventually(listener2, internalEvent);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) HazelcastInstance(com.hazelcast.core.HazelcastInstance) EventCollectingPartitionLostListener(com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener) InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 35 with InternalPartitionServiceImpl

use of com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl in project hazelcast by hazelcast.

the class ScheduledExecutorServiceBasicTest method schedule_whenPartitionLost.

@Test()
public void schedule_whenPartitionLost() throws ExecutionException, InterruptedException {
    int delay = 1;
    HazelcastInstance[] instances = createClusterWithCount(2);
    IScheduledExecutorService executorService = getScheduledExecutor(instances, "s");
    final IScheduledFuture future = executorService.schedule(new PlainCallableTask(), delay, SECONDS);
    ScheduledTaskHandler handler = future.getHandler();
    int partitionOwner = handler.getPartitionId();
    IPartitionLostEvent internalEvent = new IPartitionLostEvent(partitionOwner, 1, null);
    ((InternalPartitionServiceImpl) getNodeEngineImpl(instances[0]).getPartitionService()).onPartitionLost(internalEvent);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            try {
                future.get();
            } catch (IllegalStateException ex) {
                assertEquals("Partition holding this Scheduled task was lost along with all backups.", ex.getMessage());
            }
        }
    });
}
Also used : InternalPartitionServiceImpl(com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl) TimeoutException(java.util.concurrent.TimeoutException) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) ExpectedException(org.junit.rules.ExpectedException) CancellationException(java.util.concurrent.CancellationException) ExecutionException(java.util.concurrent.ExecutionException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) IPartitionLostEvent(com.hazelcast.spi.partition.IPartitionLostEvent) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

InternalPartitionServiceImpl (com.hazelcast.internal.partition.impl.InternalPartitionServiceImpl)35 Address (com.hazelcast.nio.Address)11 ILogger (com.hazelcast.logging.ILogger)10 PartitionStateManager (com.hazelcast.internal.partition.impl.PartitionStateManager)7 NodeEngine (com.hazelcast.spi.NodeEngine)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)5 IPartitionLostEvent (com.hazelcast.spi.partition.IPartitionLostEvent)5 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 Test (org.junit.Test)5 InternalPartitionImpl (com.hazelcast.internal.partition.impl.InternalPartitionImpl)4 PartitionReplicaManager (com.hazelcast.internal.partition.impl.PartitionReplicaManager)4 EventCollectingPartitionLostListener (com.hazelcast.partition.PartitionLostListenerStressTest.EventCollectingPartitionLostListener)4 MigrationInfo (com.hazelcast.internal.partition.MigrationInfo)3 InternalMigrationListener (com.hazelcast.internal.partition.impl.InternalMigrationListener)3 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)3 MigrationEndpoint (com.hazelcast.spi.partition.MigrationEndpoint)3 ClusterService (com.hazelcast.internal.cluster.ClusterService)2 Operation (com.hazelcast.spi.Operation)2