use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_getCPGroupByInvalidName.
@Test
public void test_getCPGroupByInvalidName() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
HTTPCommunicator communicator = new HTTPCommunicator(instance1);
ConnectionResponse response = communicator.getCPGroupByName("custom");
assertEquals(404, response.responseCode);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_forceCloseCPSessionOfInvalidCPGroup.
@Test
public void test_forceCloseCPSessionOfInvalidCPGroup() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
ConnectionResponse response1 = new HTTPCommunicator(instance1).forceCloseCPSession(DEFAULT_GROUP_NAME, 1, clusterName, null);
assertEquals(400, response1.responseCode);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_getCPMembers.
@Test
public void test_getCPMembers() throws IOException {
final HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
final HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
waitUntilCPDiscoveryCompleted(instance1, instance2, instance3);
ConnectionResponse response = new HTTPCommunicator(instance1).getCPMembers();
CPMember cpMember1 = instance1.getCPSubsystem().getLocalCPMember();
CPMember cpMember2 = instance2.getCPSubsystem().getLocalCPMember();
CPMember cpMember3 = instance3.getCPSubsystem().getLocalCPMember();
boolean cpMember1Found = false;
boolean cpMember2Found = false;
boolean cpMember3Found = false;
JsonArray arr = (JsonArray) Json.parse(response.response);
for (JsonValue val : arr) {
JsonObject mem = (JsonObject) val;
cpMember1Found |= cpMember1.getUuid().equals(UUID.fromString(mem.getString("uuid", "")));
cpMember2Found |= cpMember2.getUuid().equals(UUID.fromString(mem.getString("uuid", "")));
cpMember3Found |= cpMember3.getUuid().equals(UUID.fromString(mem.getString("uuid", "")));
}
assertTrue(cpMember1Found);
assertTrue(cpMember2Found);
assertTrue(cpMember3Found);
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse 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());
}
use of com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_getCPSessions.
@Test
public void test_getCPSessions() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(config);
HazelcastInstance instance3 = Hazelcast.newHazelcastInstance(config);
instance1.getCPSubsystem().getLock("lock1").lock();
instance1.getCPSubsystem().getLock("lock1").unlock();
instance2.getCPSubsystem().getLock("lock1").lock();
instance2.getCPSubsystem().getLock("lock1").unlock();
instance3.getCPSubsystem().getLock("lock1").lock();
instance3.getCPSubsystem().getLock("lock1").unlock();
ConnectionResponse response = new HTTPCommunicator(instance1).getCPSessions(DEFAULT_GROUP_NAME);
assertEquals(200, response.responseCode);
JsonArray sessions = (JsonArray) Json.parse(response.response);
assertEquals(3, sessions.size());
}
Aggregations