Search in sources :

Example 56 with CPMember

use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.

the class RestCPSubsystemTest method test_promoteAPMemberToCPMember.

@Test
public void test_promoteAPMemberToCPMember() throws ExecutionException, InterruptedException {
    final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
    final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
    final HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
    final HazelcastInstance instance4 = Hazelcast.newHazelcastInstance(config);
    waitUntilCPDiscoveryCompleted(instance1, instance2, instance3, instance4);
    assertTrueEventually(() -> {
        ConnectionResponse response = new HTTPCommunicator(instance4).promoteCPMember(clusterName, null);
        assertEquals(200, response.responseCode);
    });
    Collection<CPMember> cpMembers = instance1.getCPSubsystem().getCPSubsystemManagementService().getCPMembers().toCompletableFuture().get();
    assertEquals(4, cpMembers.size());
    assertNotNull(instance4.getCPSubsystem().getLocalCPMember());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) CPMember(com.hazelcast.cp.CPMember) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 57 with CPMember

use of com.hazelcast.cp.CPMember in project hazelcast by hazelcast.

the class RestCPSubsystemTest method test_removeCPMemberFromNonMaster.

@Test
public void test_removeCPMemberFromNonMaster() throws IOException {
    Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
    HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
    waitUntilCPDiscoveryCompleted(instance2, instance3);
    CPMember crashedCPMember = instance2.getCPSubsystem().getLocalCPMember();
    instance2.getLifecycleService().terminate();
    ConnectionResponse response = new HTTPCommunicator(instance3).removeCPMember(crashedCPMember.getUuid(), clusterName, null);
    assertEquals(200, response.responseCode);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ConnectionResponse(com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse) CPMember(com.hazelcast.cp.CPMember) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Aggregations

CPMember (com.hazelcast.cp.CPMember)57 HazelcastInstance (com.hazelcast.core.HazelcastInstance)40 Test (org.junit.Test)38 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)27 SlowTest (com.hazelcast.test.annotation.SlowTest)27 CPGroup (com.hazelcast.cp.CPGroup)17 HazelcastInstanceFactory.newHazelcastInstance (com.hazelcast.instance.impl.HazelcastInstanceFactory.newHazelcastInstance)16 CPGroupId (com.hazelcast.cp.CPGroupId)14 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 ArrayList (java.util.ArrayList)11 Config (com.hazelcast.config.Config)10 RaftNodeImpl (com.hazelcast.cp.internal.raft.impl.RaftNodeImpl)10 RaftEndpoint (com.hazelcast.cp.internal.raft.impl.RaftEndpoint)7 GetActiveCPMembersOp (com.hazelcast.cp.internal.raftop.metadata.GetActiveCPMembersOp)6 JsonArray (com.hazelcast.internal.json.JsonArray)6 JsonObject (com.hazelcast.internal.json.JsonObject)6 TestHazelcastInstanceFactory.initOrCreateConfig (com.hazelcast.test.TestHazelcastInstanceFactory.initOrCreateConfig)6 CPSubsystemManagementService (com.hazelcast.cp.CPSubsystemManagementService)4 JsonValue (com.hazelcast.internal.json.JsonValue)4