Search in sources :

Example 46 with JsonArray

use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.

the class ClusterHotRestartStatusDTO method fromJson.

@Override
public void fromJson(JsonObject root) {
    String dataRecoveryPolicyStr = root.getString("dataRecoveryPolicy", FULL_RECOVERY_ONLY.toString());
    dataRecoveryPolicy = HotRestartClusterDataRecoveryPolicy.valueOf(dataRecoveryPolicyStr);
    String hotRestartStatusStr = root.getString("hotRestartStatus", ClusterHotRestartStatus.UNKNOWN.toString());
    hotRestartStatus = ClusterHotRestartStatus.valueOf(hotRestartStatusStr);
    remainingValidationTimeMillis = root.getLong("remainingValidationTimeMillis", -1);
    remainingDataLoadTimeMillis = root.getLong("remainingDataLoadTimeMillis", -1);
    JsonArray memberStatuses = (JsonArray) root.get("memberHotRestartStatuses");
    memberHotRestartStatusMap = createHashMap(memberStatuses.size());
    for (JsonValue value : memberStatuses) {
        JsonObject memberStatus = (JsonObject) value;
        String member = memberStatus.getString("member", "<unknown>");
        MemberHotRestartStatus status = MemberHotRestartStatus.valueOf(memberStatus.getString("status", MemberHotRestartStatus.PENDING.toString()));
        memberHotRestartStatusMap.put(member, status);
    }
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonValue(com.hazelcast.internal.json.JsonValue) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 47 with JsonArray

use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.

the class ClusterHotRestartStatusDTO method toJson.

@Override
public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("dataRecoveryPolicy", dataRecoveryPolicy.toString());
    root.add("hotRestartStatus", hotRestartStatus.toString());
    root.add("remainingValidationTimeMillis", remainingValidationTimeMillis);
    root.add("remainingDataLoadTimeMillis", remainingDataLoadTimeMillis);
    JsonArray memberStatuses = new JsonArray();
    for (Map.Entry<String, MemberHotRestartStatus> entry : memberHotRestartStatusMap.entrySet()) {
        String member = entry.getKey();
        MemberHotRestartStatus status = entry.getValue();
        JsonObject pair = new JsonObject();
        pair.add("member", member);
        pair.add("status", status.toString());
        memberStatuses.add(pair);
    }
    root.add("memberHotRestartStatuses", memberStatuses);
    return root;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonObject(com.hazelcast.internal.json.JsonObject) Map(java.util.Map) MapUtil.createHashMap(com.hazelcast.internal.util.MapUtil.createHashMap)

Example 48 with JsonArray

use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.

the class DiscoveryConfigDTO method toJson.

@Override
public JsonObject toJson() {
    JsonObject root = new JsonObject().add("nodeFilterClass", config.getNodeFilterClass());
    JsonArray strategies = new JsonArray();
    for (DiscoveryStrategyConfig strategyConfig : config.getDiscoveryStrategyConfigs()) {
        DiscoveryStrategyConfigDTO dto = new DiscoveryStrategyConfigDTO(strategyConfig);
        strategies.add(dto.toJson());
    }
    root.add("discoveryStrategy", strategies);
    return root;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 49 with JsonArray

use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.

the class WanConfigurationExtendedEvent method toJson.

@Override
public JsonObject toJson() {
    JsonObject json = super.toJson();
    JsonArray publisherIds = new JsonArray();
    for (String publisherId : wanPublisherIds) {
        publisherIds.add(publisherId);
    }
    json.add("wanPublisherIds", publisherIds);
    return json;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 50 with JsonArray

use of com.hazelcast.internal.json.JsonArray in project hazelcast by hazelcast.

the class MemberStateImpl method toJson.

@Override
public JsonObject toJson() {
    final JsonObject root = new JsonObject();
    root.add("address", address);
    String uuidString = uuid != null ? uuid.toString() : null;
    root.add("uuid", uuidString);
    String cpMemberUuidString = cpMemberUuid != null ? cpMemberUuid.toString() : null;
    root.add("cpMemberUuid", cpMemberUuidString);
    root.add("name", name);
    final JsonArray endpoints = new JsonArray();
    for (Entry<EndpointQualifier, Address> entry : this.endpoints.entrySet()) {
        JsonObject address = new JsonObject();
        address.set("host", entry.getValue().getHost());
        address.set("port", entry.getValue().getPort());
        JsonObject endpoint = new JsonObject();
        endpoint.set("protocol", entry.getKey().getType().name());
        endpoint.set("address", address);
        if (entry.getKey().getIdentifier() != null) {
            endpoint.set("id", entry.getKey().getIdentifier());
        }
        endpoints.add(endpoint);
    }
    root.add("endpoints", endpoints);
    serializeAsMap(root, "mapStats", mapsWithStats);
    serializeAsMap(root, "multiMapStats", multiMapsWithStats);
    serializeAsMap(root, "replicatedMapStats", replicatedMapsWithStats);
    serializeAsMap(root, "queueStats", queuesWithStats);
    serializeAsMap(root, "topicStats", topicsWithStats);
    serializeAsMap(root, "reliableTopicStats", reliableTopicsWithStats);
    serializeAsMap(root, "pnCounterStats", pnCountersWithStats);
    serializeAsMap(root, "executorStats", executorsWithStats);
    serializeAsMap(root, "scheduledExecutorStats", scheduledExecutorsWithStats);
    serializeAsMap(root, "durableExecutorStats", durableExecutorsWithStats);
    serializeAsMap(root, "cacheStats", cachesWithStats);
    serializeAsMap(root, "flakeIdStats", flakeIdGeneratorsWithStats);
    serializeMap(root, "wanStats", wanStats);
    final JsonArray clientsArray = new JsonArray();
    for (ClientEndPointDTO client : clients) {
        clientsArray.add(client.toJson());
    }
    root.add("clients", clientsArray);
    addJsonIfSerializable(root, "operationStats", operationStats);
    root.add("memberPartitionState", memberPartitionState.toJson());
    root.add("nodeState", nodeState.toJson());
    root.add("hotRestartState", hotRestartState.toJson());
    root.add("clusterHotRestartStatus", clusterHotRestartStatus.toJson());
    JsonObject clientStatsObject = new JsonObject();
    for (Map.Entry<UUID, String> entry : clientStats.entrySet()) {
        clientStatsObject.add(entry.getKey().toString(), entry.getValue());
    }
    root.add("clientStats", clientStatsObject);
    return root;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) Address(com.hazelcast.cluster.Address) ClientEndPointDTO(com.hazelcast.internal.management.dto.ClientEndPointDTO) JsonObject(com.hazelcast.internal.json.JsonObject) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) JsonUtil.getString(com.hazelcast.internal.util.JsonUtil.getString) UUID(java.util.UUID) HashMap(java.util.HashMap) Map(java.util.Map) Collections.emptyMap(java.util.Collections.emptyMap)

Aggregations

JsonArray (com.hazelcast.internal.json.JsonArray)74 JsonObject (com.hazelcast.internal.json.JsonObject)42 Test (org.junit.Test)39 QuickTest (com.hazelcast.test.annotation.QuickTest)31 JsonValue (com.hazelcast.internal.json.JsonValue)28 HazelcastJsonValue (com.hazelcast.core.HazelcastJsonValue)10 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)10 CPMember (com.hazelcast.cp.CPMember)7 JsonUtil.getString (com.hazelcast.internal.util.JsonUtil.getString)7 SlowTest (com.hazelcast.test.annotation.SlowTest)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)6 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)4 Address (com.hazelcast.cluster.Address)3 JetException (com.hazelcast.jet.JetException)3 InputStreamReader (java.io.InputStreamReader)3 Collection (java.util.Collection)3 Map (java.util.Map)3 Request (org.elasticsearch.client.Request)3