use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class NodeStateImpl method toJson.
@Override
public JsonObject toJson() {
JsonObject root = new JsonObject();
root.add("clusterState", clusterState.name());
root.add("nodeState", nodeState.name());
root.add("clusterVersion", clusterVersion.toString());
root.add("memberVersion", memberVersion.toString());
JsonObject weaknesses = new JsonObject();
for (Map.Entry<String, List<String>> entry : weakSecretsConfigs.entrySet()) {
JsonArray values = new JsonArray();
for (String value : entry.getValue()) {
values.add(value);
}
weaknesses.add(entry.getKey(), values);
}
root.add("weakConfigs", weaknesses);
return root;
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class MemberPartitionStateImpl method toJson.
@Override
public JsonObject toJson() {
JsonObject root = new JsonObject();
JsonArray partitionsArray = new JsonArray();
for (Integer lsPartition : partitions) {
partitionsArray.add(lsPartition);
}
root.add("partitions", partitionsArray);
root.add("memberStateSafe", memberStateSafe);
return root;
}
use of com.hazelcast.internal.json.JsonArray 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.json.JsonArray 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());
}
use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.
the class RestCPSubsystemTest method test_getCPGroupIds.
@Test
public void test_getCPGroupIds() throws IOException {
HazelcastInstance instance1 = Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
Hazelcast.newHazelcastInstance(config);
instance1.getCPSubsystem().getAtomicLong("long1").set(5);
instance1.getCPSubsystem().getAtomicLong("long1@custom").set(5);
HTTPCommunicator communicator = new HTTPCommunicator(instance1);
ConnectionResponse response = communicator.getCPGroupIds();
assertEquals(200, response.responseCode);
JsonArray responseArr = (JsonArray) Json.parse(response.response);
boolean metadataCPGroupExists = false;
boolean defaultCPGroupExists = false;
boolean customCPGroupExists = false;
for (JsonValue val : responseArr) {
JsonObject obj = (JsonObject) val;
String name = obj.getString("name", "");
if (CPGroup.DEFAULT_GROUP_NAME.equals(name)) {
defaultCPGroupExists = true;
} else if (METADATA_CP_GROUP_NAME.equals(name)) {
metadataCPGroupExists = true;
} else if ("custom".equals(name)) {
customCPGroupExists = true;
}
}
assertTrue(metadataCPGroupExists);
assertTrue(defaultCPGroupExists);
assertTrue(customCPGroupExists);
}
Aggregations