Search in sources :

Example 91 with JsonObject

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

the class DiscoveryStrategyConfigDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    config = new DiscoveryStrategyConfig();
    JsonValue className = json.get("className");
    if (className != null && !className.isNull()) {
        config.setClassName(className.asString());
    }
    config.setProperties(fromJsonObject((JsonObject) json.get("properties")));
}
Also used : DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) JsonValue(com.hazelcast.internal.json.JsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) JsonUtil.fromJsonObject(com.hazelcast.internal.util.JsonUtil.fromJsonObject) JsonUtil.toJsonObject(com.hazelcast.internal.util.JsonUtil.toJsonObject)

Example 92 with JsonObject

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

the class ClientBwListEntryDTO method toJson.

public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("type", type.toString());
    root.add("value", value);
    return root;
}
Also used : JsonObject(com.hazelcast.internal.json.JsonObject)

Example 93 with JsonObject

use of com.hazelcast.internal.json.JsonObject 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 94 with JsonObject

use of com.hazelcast.internal.json.JsonObject 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 95 with JsonObject

use of com.hazelcast.internal.json.JsonObject 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)

Aggregations

JsonObject (com.hazelcast.internal.json.JsonObject)151 Test (org.junit.Test)56 JsonArray (com.hazelcast.internal.json.JsonArray)41 QuickTest (com.hazelcast.test.annotation.QuickTest)38 JsonValue (com.hazelcast.internal.json.JsonValue)34 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)26 HazelcastJsonValue (com.hazelcast.core.HazelcastJsonValue)23 HazelcastInstance (com.hazelcast.core.HazelcastInstance)11 JsonUtil.getString (com.hazelcast.internal.util.JsonUtil.getString)10 SlowTest (com.hazelcast.test.annotation.SlowTest)9 HashMap (java.util.HashMap)8 CPMember (com.hazelcast.cp.CPMember)7 ArrayList (java.util.ArrayList)7 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)6 NavigableJsonInputAdapter (com.hazelcast.internal.serialization.impl.NavigableJsonInputAdapter)6 JsonUtil.fromJsonObject (com.hazelcast.internal.util.JsonUtil.fromJsonObject)5 JsonUtil.toJsonObject (com.hazelcast.internal.util.JsonUtil.toJsonObject)5 Map (java.util.Map)5 ClusterService (com.hazelcast.internal.cluster.ClusterService)4 Address (com.hazelcast.cluster.Address)3