Search in sources :

Example 11 with JsonValue

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

the class KubernetesClient method extractContainerPort.

private static Integer extractContainerPort(JsonValue podItemJson) {
    JsonArray containers = toJsonArray(podItemJson.asObject().get("spec").asObject().get("containers"));
    // If multiple containers are in one POD, then use the default Hazelcast port from the configuration.
    if (containers.size() == 1) {
        JsonValue container = containers.get(0);
        JsonArray ports = toJsonArray(container.asObject().get("ports"));
        // If multiple ports are exposed by a container, then use the default Hazelcast port from the configuration.
        if (ports.size() == 1) {
            JsonValue port = ports.get(0);
            JsonValue containerPort = port.asObject().get("containerPort");
            if (containerPort != null && containerPort.isNumber()) {
                return containerPort.asInt();
            }
        }
    }
    return null;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonValue(com.hazelcast.internal.json.JsonValue)

Example 12 with JsonValue

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

the class SlowOperationDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    operation = getString(json, "operation");
    stackTrace = getString(json, "stackTrace");
    totalInvocations = getInt(json, "totalInvocations");
    invocations = new ArrayList<SlowOperationInvocationDTO>();
    for (JsonValue jsonValue : getArray(json, "invocations")) {
        SlowOperationInvocationDTO slowOperationInvocationDTO = new SlowOperationInvocationDTO();
        slowOperationInvocationDTO.fromJson(jsonValue.asObject());
        invocations.add(slowOperationInvocationDTO);
    }
}
Also used : JsonValue(com.hazelcast.internal.json.JsonValue)

Example 13 with JsonValue

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

the class AliasedDiscoveryConfigDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    config = AliasedDiscoveryConfigUtils.newConfigFor(tag);
    JsonValue enabled = json.get("enabled");
    if (enabled != null && !enabled.isNull()) {
        config.setEnabled(enabled.asBoolean());
    }
    JsonValue usePublicIp = json.get("usePublicIp");
    if (usePublicIp != null && !usePublicIp.isNull()) {
        config.setUsePublicIp(usePublicIp.asBoolean());
    }
    Map<String, Comparable> properties = fromJsonObject((JsonObject) json.get("properties"));
    for (Entry<String, Comparable> property : properties.entrySet()) {
        config.setProperty(property.getKey(), (String) property.getValue());
    }
}
Also used : JsonValue(com.hazelcast.internal.json.JsonValue)

Example 14 with JsonValue

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

the class ClientBwListDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    String modeStr = getString(json, "mode");
    mode = Mode.valueOf(modeStr);
    entries = new ArrayList<>();
    JsonArray entriesArray = getArray(json, "entries");
    for (JsonValue jsonValue : entriesArray) {
        ClientBwListEntryDTO entryDTO = new ClientBwListEntryDTO();
        entryDTO.fromJson(jsonValue.asObject());
        entries.add(entryDTO);
    }
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonValue(com.hazelcast.internal.json.JsonValue) JsonUtil.getString(com.hazelcast.internal.util.JsonUtil.getString)

Example 15 with JsonValue

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

the class ClientEndPointDTO method fromJson.

@Override
public void fromJson(JsonObject json) {
    uuid = UUID.fromString(getString(json, "uuid"));
    address = getString(json, "address");
    clientType = getString(json, "clientType");
    name = getString(json, "name");
    JsonArray labelsArray = getArray(json, "labels");
    labels = new HashSet<>();
    for (JsonValue labelValue : labelsArray) {
        labels.add(labelValue.asString());
    }
    ipAddress = getString(json, "ipAddress", null);
    canonicalHostName = getString(json, "canonicalHostName", null);
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) 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