Search in sources :

Example 41 with JsonArray

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

the class ClientBwListDTO method toJson.

@Override
public JsonObject toJson() {
    JsonObject object = new JsonObject();
    object.add("mode", mode.toString());
    if (entries != null) {
        JsonArray entriesArray = new JsonArray();
        for (ClientBwListEntryDTO entry : entries) {
            JsonObject json = entry.toJson();
            if (json != null) {
                entriesArray.add(json);
            }
        }
        object.add("entries", entriesArray);
    }
    return object;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 42 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 43 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 44 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 45 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)

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