use of com.hazelcast.instance.StaticMemberNodeContext in project hazelcast by hazelcast.
the class CPMemberAddRemoveTest method testCPMemberIdentityChanges_whenLocalMemberIsRecovered_duringRestart.
@Test
public void testCPMemberIdentityChanges_whenLocalMemberIsRecovered_duringRestart() throws ExecutionException, InterruptedException {
HazelcastInstance[] instances = newInstances(3);
waitAllForLeaderElection(instances, getMetadataGroupId(instances[0]));
Member localMember = instances[0].getCluster().getLocalMember();
CPMember localCpMember = instances[0].getCPSubsystem().getLocalCPMember();
instances[0].getLifecycleService().terminate();
assertClusterSizeEventually(2, instances[1]);
instances[1].getCPSubsystem().getCPSubsystemManagementService().removeCPMember(localCpMember.getUuid()).toCompletableFuture().get();
instances[0] = newHazelcastInstance(initOrCreateConfig(createConfig(3, 3)), randomString(), new StaticMemberNodeContext(factory, localMember));
assertEquals(localMember, instances[0].getCluster().getLocalMember());
assertTrueAllTheTime(() -> assertNull(instances[0].getCPSubsystem().getLocalCPMember()), 5);
instances[0].getCPSubsystem().getCPSubsystemManagementService().promoteToCPMember().toCompletableFuture().get();
assertNotNull(instances[0].getCPSubsystem().getLocalCPMember());
assertNotEquals(localCpMember, instances[0].getCPSubsystem().getLocalCPMember());
}
use of com.hazelcast.instance.StaticMemberNodeContext in project hazelcast by hazelcast.
the class MembershipUpdateTest method memberListOrder_shouldBeSame_whenMemberRestartedWithSameIdentity.
@Test
public void memberListOrder_shouldBeSame_whenMemberRestartedWithSameIdentity() {
ruleStaleJoinPreventionDuration.setOrClearProperty("5");
Config configMaster = new Config();
configMaster.setProperty(ClusterProperty.MEMBER_LIST_PUBLISH_INTERVAL_SECONDS.getName(), "5");
HazelcastInstance hz1 = factory.newHazelcastInstance(configMaster);
HazelcastInstance hz2 = factory.newHazelcastInstance();
HazelcastInstance hz3 = factory.newHazelcastInstance();
HazelcastInstance hz4 = factory.newHazelcastInstance();
assertClusterSizeEventually(4, hz2, hz3);
rejectOperationsBetween(hz1, hz2, F_ID, singletonList(MEMBER_INFO_UPDATE));
MemberImpl member3 = getNode(hz3).getLocalMember();
hz3.getLifecycleService().terminate();
assertClusterSizeEventually(3, hz1, hz4);
assertClusterSize(4, hz2);
hz3 = newHazelcastInstance(initOrCreateConfig(new Config()), randomName(), new StaticMemberNodeContext(factory, member3));
assertClusterSizeEventually(4, hz1, hz4);
resetPacketFiltersFrom(hz1);
assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz3));
assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz4));
assertTrueEventually(() -> assertMemberViewsAreSame(getMemberMap(hz1), getMemberMap(hz2)));
}
use of com.hazelcast.instance.StaticMemberNodeContext in project hazelcast by hazelcast.
the class FrozenPartitionTableTest method partitionTable_shouldBeFixed_whenMemberRestarts_usingUuidOfAnotherMissingMember.
@Test
public void partitionTable_shouldBeFixed_whenMemberRestarts_usingUuidOfAnotherMissingMember() {
ruleStaleJoinPreventionDuration.setOrClearProperty("5");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz1 = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
HazelcastInstance hz3 = factory.newHazelcastInstance();
HazelcastInstance hz4 = factory.newHazelcastInstance();
assertClusterSizeEventually(4, hz2, hz3);
warmUpPartitions(hz1, hz2, hz3, hz4);
changeClusterStateEventually(hz4, ClusterState.FROZEN);
int member3PartitionId = getPartitionId(hz3);
int member4PartitionId = getPartitionId(hz4);
MemberImpl member3 = getNode(hz3).getLocalMember();
MemberImpl member4 = getNode(hz4).getLocalMember();
hz3.shutdown();
hz4.shutdown();
assertClusterSizeEventually(2, hz1, hz2);
newHazelcastInstance(initOrCreateConfig(new Config()), randomName(), new StaticMemberNodeContext(factory, member4.getUuid(), member3.getAddress()));
assertClusterSizeEventually(3, hz1, hz2);
waitAllForSafeState(hz1, hz2);
OperationServiceImpl operationService = getOperationService(hz1);
operationService.invokeOnPartition(null, new NonRetryablePartitionOperation(), member3PartitionId).join();
try {
operationService.invokeOnPartition(null, new NonRetryablePartitionOperation(), member4PartitionId).joinInternal();
fail("Invocation to missing member should have failed!");
} catch (TargetNotMemberException ignored) {
}
}
use of com.hazelcast.instance.StaticMemberNodeContext in project hazelcast by hazelcast.
the class FrozenPartitionTableTest method partitionTable_shouldBeFixed_whenMemberRestarts_usingNewUuid.
@Test
public void partitionTable_shouldBeFixed_whenMemberRestarts_usingNewUuid() {
ruleStaleJoinPreventionDuration.setOrClearProperty("5");
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
HazelcastInstance hz1 = factory.newHazelcastInstance();
HazelcastInstance hz2 = factory.newHazelcastInstance();
HazelcastInstance hz3 = factory.newHazelcastInstance();
assertClusterSizeEventually(3, hz2, hz3);
warmUpPartitions(hz1, hz2, hz3);
changeClusterStateEventually(hz3, ClusterState.FROZEN);
int member3PartitionId = getPartitionId(hz3);
MemberImpl member3 = getNode(hz3).getLocalMember();
hz3.shutdown();
assertClusterSizeEventually(2, hz1, hz2);
hz3 = newHazelcastInstance(initOrCreateConfig(new Config()), randomName(), new StaticMemberNodeContext(factory, newUnsecureUUID(), member3.getAddress()));
assertClusterSizeEventually(3, hz1, hz2);
waitAllForSafeState(hz1, hz2, hz3);
OperationServiceImpl operationService = getOperationService(hz1);
operationService.invokeOnPartition(null, new NonRetryablePartitionOperation(), member3PartitionId).join();
}
use of com.hazelcast.instance.StaticMemberNodeContext in project hazelcast by hazelcast.
the class MembershipUpdateTest method memberJoinsEventually_whenMemberRestartedWithSameUuid_butMasterDoesNotNoticeItsLeave.
@Test
public void memberJoinsEventually_whenMemberRestartedWithSameUuid_butMasterDoesNotNoticeItsLeave() throws Exception {
ruleStaleJoinPreventionDuration.setOrClearProperty("5");
Config configMaster = new Config();
HazelcastInstance hz1 = factory.newHazelcastInstance(configMaster);
HazelcastInstance hz2 = factory.newHazelcastInstance();
HazelcastInstance hz3 = factory.newHazelcastInstance();
assertClusterSizeEventually(3, hz2, hz3);
MemberImpl member3 = getNode(hz3).getLocalMember();
// A new member is restarted with member3's UUID.
// Then after some time, member3 is terminated.
// This is to emulate the case, member3 is restarted with preserving its UUID (using hot-restart),
// but master does not realize its leave in time.
// When master realizes, member3 is terminated,
// new member should eventually join the cluster.
Future<HazelcastInstance> future = spawn(() -> {
NodeContext nodeContext = new StaticMemberNodeContext(factory, member3.getUuid(), factory.nextAddress());
return newHazelcastInstance(initOrCreateConfig(new Config()), randomName(), nodeContext);
});
spawn(() -> {
sleepSeconds(5);
hz3.getLifecycleService().terminate();
});
HazelcastInstance hz4 = future.get();
assertClusterSize(3, hz1, hz4);
assertClusterSizeEventually(3, hz2);
}
Aggregations