Search in sources :

Example 1 with StaticMemberNodeContext

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) Member(com.hazelcast.cluster.Member) CPMember(com.hazelcast.cp.CPMember) CPMember(com.hazelcast.cp.CPMember) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 2 with StaticMemberNodeContext

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)));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with StaticMemberNodeContext

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) {
    }
}
Also used : TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Config(com.hazelcast.config.Config) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with StaticMemberNodeContext

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();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) Config(com.hazelcast.config.Config) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with StaticMemberNodeContext

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);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastInstanceFactory.newHazelcastInstance(com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) NodeContext(com.hazelcast.instance.impl.NodeContext) StaticMemberNodeContext(com.hazelcast.instance.StaticMemberNodeContext) TestHazelcastInstanceFactory.initOrCreateConfig(com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig) Config(com.hazelcast.config.Config) ServiceConfig(com.hazelcast.config.ServiceConfig) MemberImpl(com.hazelcast.cluster.impl.MemberImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

StaticMemberNodeContext (com.hazelcast.instance.StaticMemberNodeContext)6 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)6 Test (org.junit.Test)6 Config (com.hazelcast.config.Config)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 MemberImpl (com.hazelcast.cluster.impl.MemberImpl)4 TestHazelcastInstanceFactory.initOrCreateConfig (com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig)4 ServiceConfig (com.hazelcast.config.ServiceConfig)2 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 Member (com.hazelcast.cluster.Member)1 CPMember (com.hazelcast.cp.CPMember)1 NodeContext (com.hazelcast.instance.impl.NodeContext)1 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1