Search in sources :

Example 1 with JsonObject

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

the class HazelcastJsonUpsertTarget method conclude.

@Override
public Object conclude() {
    JsonObject json = this.json;
    this.json = null;
    return new HazelcastJsonValue(json.toString());
}
Also used : HazelcastJsonValue(com.hazelcast.core.HazelcastJsonValue) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 2 with JsonObject

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

the class HotRestartStateImpl method toJson.

@Override
public JsonObject toJson() {
    final JsonObject root = new JsonObject();
    if (backupTaskStatus != null) {
        root.add("backupTaskState", backupTaskStatus.getState().name());
        root.add("backupTaskCompleted", backupTaskStatus.getCompleted());
        root.add("backupTaskTotal", backupTaskStatus.getTotal());
        root.add("isHotBackupEnabled", isHotBackupEnabled);
        root.add("backupDirectory", backupDirectory);
    }
    return root;
}
Also used : JsonObject(com.hazelcast.internal.json.JsonObject)

Example 3 with JsonObject

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

the class LocalOperationStatsImpl method toJson.

@Override
public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("maxVisibleSlowOperationCount", maxVisibleSlowOperationCount);
    JsonArray slowOperationArray = new JsonArray();
    int logCount = 0;
    for (SlowOperationDTO slowOperation : slowOperations) {
        if (logCount++ < maxVisibleSlowOperationCount) {
            slowOperationArray.add(slowOperation.toJson());
        }
    }
    root.add("slowOperations", slowOperationArray);
    root.add("creationTime", creationTime);
    return root;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonObject(com.hazelcast.internal.json.JsonObject) SlowOperationDTO(com.hazelcast.internal.management.dto.SlowOperationDTO)

Example 4 with JsonObject

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

the class LocalWanStatsImpl method fromJson.

@Override
public void fromJson(JsonObject json) {
    for (JsonObject.Member next : json) {
        LocalWanPublisherStats localPublisherStats = new LocalWanPublisherStatsImpl();
        localPublisherStats.fromJson(next.getValue().asObject());
        localPublisherStatsMap.put(next.getName(), localPublisherStats);
    }
}
Also used : LocalWanPublisherStats(com.hazelcast.internal.monitor.LocalWanPublisherStats) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 5 with JsonObject

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

the class MemberStateImpl method fromJson.

@Override
@SuppressWarnings({ "checkstyle:cyclomaticcomplexity", "checkstyle:npathcomplexity", "checkstyle:methodlength" })
public void fromJson(JsonObject json) {
    address = getString(json, "address");
    String uuidString = getString(json, "uuid", null);
    uuid = uuidString != null ? UUID.fromString(uuidString) : null;
    String cpMemberUuidString = getString(json, "cpMemberUuid", null);
    cpMemberUuid = cpMemberUuidString != null ? UUID.fromString(cpMemberUuidString) : null;
    name = getString(json, "name", null);
    JsonArray jsonEndpoints = getArray(json, "endpoints");
    endpoints = new HashMap<>();
    for (JsonValue obj : jsonEndpoints) {
        JsonObject endpoint = obj.asObject();
        String id = endpoint.getString("id", null);
        ProtocolType type = ProtocolType.valueOf(endpoint.getString("protocol", "MEMBER"));
        JsonValue addr = endpoint.get("address");
        String host = addr.asObject().getString("host", "");
        int port = addr.asObject().getInt("port", 0);
        EndpointQualifier qualifier = EndpointQualifier.resolve(type, id);
        Address address = null;
        try {
            address = new Address(host, port);
        } catch (UnknownHostException e) {
            // ignore
            ignore(e);
        }
        endpoints.put(qualifier, address);
    }
    mapsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "mapStats")) {
        mapsWithStats.add(next.getName());
    }
    multiMapsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "multiMapStats")) {
        multiMapsWithStats.add(next.getName());
    }
    replicatedMapsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "replicatedMapStats")) {
        replicatedMapsWithStats.add(next.getName());
    }
    queuesWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "queueStats")) {
        queuesWithStats.add(next.getName());
    }
    topicsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "topicStats")) {
        topicsWithStats.add(next.getName());
    }
    reliableTopicsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "reliableTopicStats")) {
        reliableTopicsWithStats.add(next.getName());
    }
    pnCountersWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "pnCounterStats")) {
        pnCountersWithStats.add(next.getName());
    }
    executorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "executorStats")) {
        executorsWithStats.add(next.getName());
    }
    scheduledExecutorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "scheduledExecutorStats")) {
        scheduledExecutorsWithStats.add(next.getName());
    }
    durableExecutorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "durableExecutorStats")) {
        durableExecutorsWithStats.add(next.getName());
    }
    cachesWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "cacheStats")) {
        cachesWithStats.add(next.getName());
    }
    flakeIdGeneratorsWithStats = new HashSet<>();
    for (JsonObject.Member next : getObject(json, "flakeIdStats")) {
        flakeIdGeneratorsWithStats.add(next.getName());
    }
    for (JsonObject.Member next : getObject(json, "wanStats", new JsonObject())) {
        putDeserializedIfSerializable(wanStats, next.getName(), next.getValue().asObject(), new LocalWanStatsImpl());
    }
    JsonArray jsonClients = getArray(json, "clients");
    clients = new ArrayList<>();
    for (JsonValue jsonClient : jsonClients) {
        final ClientEndPointDTO client = new ClientEndPointDTO();
        client.fromJson(jsonClient.asObject());
        clients.add(client);
    }
    JsonObject jsonOperationStats = getObject(json, "operationStats", null);
    if (jsonOperationStats != null) {
        operationStats = readJsonIfDeserializable(jsonOperationStats, operationStats);
    }
    JsonObject jsonMemberPartitionState = getObject(json, "memberPartitionState", null);
    if (jsonMemberPartitionState != null) {
        memberPartitionState = new MemberPartitionStateImpl();
        memberPartitionState.fromJson(jsonMemberPartitionState);
    }
    JsonObject jsonNodeState = getObject(json, "nodeState", null);
    if (jsonNodeState != null) {
        nodeState = new NodeStateImpl();
        nodeState.fromJson(jsonNodeState);
    }
    JsonObject jsonHotRestartState = getObject(json, "hotRestartState", null);
    if (jsonHotRestartState != null) {
        hotRestartState = new HotRestartStateImpl();
        hotRestartState.fromJson(jsonHotRestartState);
    }
    JsonObject jsonClusterHotRestartStatus = getObject(json, "clusterHotRestartStatus", null);
    if (jsonClusterHotRestartStatus != null) {
        clusterHotRestartStatus = new ClusterHotRestartStatusDTO();
        clusterHotRestartStatus.fromJson(jsonClusterHotRestartStatus);
    }
    clientStats = new HashMap<>();
    for (JsonObject.Member next : getObject(json, "clientStats")) {
        clientStats.put(UUID.fromString(next.getName()), next.getValue().asString());
    }
}
Also used : Address(com.hazelcast.cluster.Address) UnknownHostException(java.net.UnknownHostException) ClientEndPointDTO(com.hazelcast.internal.management.dto.ClientEndPointDTO) JsonValue(com.hazelcast.internal.json.JsonValue) JsonObject(com.hazelcast.internal.json.JsonObject) EndpointQualifier(com.hazelcast.instance.EndpointQualifier) JsonUtil.getString(com.hazelcast.internal.util.JsonUtil.getString) JsonArray(com.hazelcast.internal.json.JsonArray) ProtocolType(com.hazelcast.instance.ProtocolType) ClusterHotRestartStatusDTO(com.hazelcast.internal.management.dto.ClusterHotRestartStatusDTO)

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