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();
}
}
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.");
}
}
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);
}
}
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);
}
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());
}
}
});
}
Aggregations