Search in sources :

Example 46 with JsonValue

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

the class TimedMemberState method fromJson.

@Override
public void fromJson(JsonObject json) {
    time = getLong(json, "time");
    master = getBoolean(json, "master");
    clusterName = getString(json, "clusterName");
    JsonArray jsonMemberList = getArray(json, "memberList");
    memberList = new ArrayList<String>(jsonMemberList.size());
    for (JsonValue member : jsonMemberList.values()) {
        memberList.add(member.asString());
    }
    JsonObject jsonMemberState = getObject(json, "memberState");
    memberState = new MemberStateImpl();
    memberState.fromJson(jsonMemberState);
    sslEnabled = getBoolean(json, "sslEnabled", false);
    lite = getBoolean(json, "lite");
    socketInterceptorEnabled = getBoolean(json, "socketInterceptorEnabled");
    scriptingEnabled = getBoolean(json, "scriptingEnabled");
    consoleEnabled = getBoolean(json, "consoleEnabled");
    mcDataAccessEnabled = getBoolean(json, "mcDataAccessEnabled");
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) MemberStateImpl(com.hazelcast.internal.monitor.impl.MemberStateImpl) JsonValue(com.hazelcast.internal.json.JsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) JsonUtil.getString(com.hazelcast.internal.util.JsonUtil.getString)

Example 47 with JsonValue

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

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

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

the class DiscoveryConfigDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    config = new DiscoveryConfig();
    JsonValue nodeFilterClass = json.get("nodeFilterClass");
    if (nodeFilterClass != null && !nodeFilterClass.isNull()) {
        config.setNodeFilterClass(nodeFilterClass.asString());
    }
    JsonValue discoveryStrategies = json.get("discoveryStrategy");
    if (discoveryStrategies != null && !discoveryStrategies.isNull()) {
        Collection<DiscoveryStrategyConfig> strategyConfigs = config.getDiscoveryStrategyConfigs();
        for (JsonValue strategy : discoveryStrategies.asArray()) {
            DiscoveryStrategyConfigDTO strategyDTO = new DiscoveryStrategyConfigDTO();
            strategyDTO.fromJson(strategy.asObject());
            strategyConfigs.add(strategyDTO.getConfig());
        }
    }
}
Also used : DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) JsonValue(com.hazelcast.internal.json.JsonValue) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig)

Example 50 with JsonValue

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

the class EvictionConfigDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    evictionConfig = new EvictionConfig();
    evictionConfig.setSize(getInt(json, "size"));
    evictionConfig.setMaxSizePolicy(MaxSizePolicy.valueOf(getString(json, "maxSizePolicy")));
    evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(getString(json, "evictionPolicy")));
    JsonValue comparatorClassName = json.get("comparatorClassName");
    if (comparatorClassName != null && !comparatorClassName.isNull()) {
        evictionConfig.setComparatorClassName(comparatorClassName.asString());
    }
}
Also used : EvictionConfig(com.hazelcast.config.EvictionConfig) JsonValue(com.hazelcast.internal.json.JsonValue)

Aggregations

JsonValue (com.hazelcast.internal.json.JsonValue)85 Test (org.junit.Test)36 JsonObject (com.hazelcast.internal.json.JsonObject)35 QuickTest (com.hazelcast.test.annotation.QuickTest)30 JsonArray (com.hazelcast.internal.json.JsonArray)28 HazelcastJsonValue (com.hazelcast.core.HazelcastJsonValue)25 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)20 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 HazelcastInstance (com.hazelcast.core.HazelcastInstance)6 KubernetesApiProvider.convertToString (com.hazelcast.kubernetes.KubernetesApiProvider.convertToString)6 EndpointAddress (com.hazelcast.kubernetes.KubernetesClient.EndpointAddress)6 HashSet (java.util.HashSet)6 ConnectionResponse (com.hazelcast.internal.ascii.HTTPCommunicator.ConnectionResponse)5 SlowTest (com.hazelcast.test.annotation.SlowTest)5 Address (com.hazelcast.cluster.Address)4 CPMember (com.hazelcast.cp.CPMember)4 IOException (java.io.IOException)4 JsonUtil.fromJsonObject (com.hazelcast.internal.util.JsonUtil.fromJsonObject)3 JsonUtil.getString (com.hazelcast.internal.util.JsonUtil.getString)3