Search in sources :

Example 81 with JsonObject

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

the class HttpGetCommandProcessor method handleLogLevel.

private void handleLogLevel(HttpGetCommand command) {
    LoggingServiceImpl loggingService = (LoggingServiceImpl) getNode().getLoggingService();
    Level level = loggingService.getLevel();
    prepareResponse(command, new JsonObject().add("logLevel", level == null ? null : level.getName()));
}
Also used : LoggingServiceImpl(com.hazelcast.logging.impl.LoggingServiceImpl) JsonObject(com.hazelcast.internal.json.JsonObject) Level(java.util.logging.Level)

Example 82 with JsonObject

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

the class HttpGetCommandProcessor method handleCluster.

/**
 * Sets the HTTP response to a string containing basic cluster information:
 * <ul>
 * <li>Member list</li>
 * <li>Client connection count</li>
 * <li>Connection count</li>
 * </ul>
 *
 * @param command the HTTP request
 */
private void handleCluster(HttpGetCommand command) {
    Node node = textCommandService.getNode();
    Server server = node.getServer();
    ClusterServiceImpl clusterService = node.getClusterService();
    JsonArray membersArray = new JsonArray();
    clusterService.getMembers().stream().map(m -> new JsonObject().add("address", m.getAddress().toString()).add("liteMember", m.isLiteMember()).add("localMember", m.localMember()).add("uuid", m.getUuid().toString()).add("memberVersion", m.getVersion().toString())).forEach(membersArray::add);
    ServerConnectionManager cm = server.getConnectionManager(CLIENT);
    int clientCount = cm == null ? 0 : cm.connectionCount(ServerConnection::isClient);
    JsonObject response = new JsonObject().add("members", membersArray).add("connectionCount", clientCount).add("allConnectionCount", server.connectionCount());
    prepareResponse(command, response);
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) Address(com.hazelcast.cluster.Address) LoggingServiceImpl(com.hazelcast.logging.impl.LoggingServiceImpl) ServerConnection(com.hazelcast.internal.server.ServerConnection) JsonArray(com.hazelcast.internal.json.JsonArray) Level(java.util.logging.Level) Json(com.hazelcast.internal.json.Json) ClusterService(com.hazelcast.internal.cluster.ClusterService) SC_500(com.hazelcast.internal.ascii.rest.HttpStatusCode.SC_500) CPGroup(com.hazelcast.cp.CPGroup) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) StringUtil.equalsIgnoreCase(com.hazelcast.internal.util.StringUtil.equalsIgnoreCase) CPSession(com.hazelcast.cp.session.CPSession) JsonObject(com.hazelcast.internal.json.JsonObject) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) CPGroupId(com.hazelcast.cp.CPGroupId) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) TextCommandService(com.hazelcast.internal.ascii.TextCommandService) StringUtil(com.hazelcast.internal.util.StringUtil) ExceptionUtil.peel(com.hazelcast.internal.util.ExceptionUtil.peel) CPSubsystemManagementService(com.hazelcast.cp.CPSubsystemManagementService) Collection(java.util.Collection) Server(com.hazelcast.internal.server.Server) NodeState(com.hazelcast.instance.impl.NodeState) MAP(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.MAP) Node(com.hazelcast.instance.impl.Node) CLIENT(com.hazelcast.instance.EndpointQualifier.CLIENT) CompletionStage(java.util.concurrent.CompletionStage) CPMember(com.hazelcast.cp.CPMember) ClusterState(com.hazelcast.cluster.ClusterState) CPSubsystem(com.hazelcast.cp.CPSubsystem) QUEUE(com.hazelcast.internal.ascii.rest.RestCallExecution.ObjectType.QUEUE) Server(com.hazelcast.internal.server.Server) ServerConnectionManager(com.hazelcast.internal.server.ServerConnectionManager) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 83 with JsonObject

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

the class ConfigUpdateResult method toJson.

public JsonObject toJson() {
    JsonObject json = new JsonObject();
    JsonArray addedConfigsAsJson = toJsonArray(addedConfigs);
    JsonArray ignoredConfigsAsJson = toJsonArray(ignoredConfigs);
    json.add("addedConfigs", addedConfigsAsJson);
    json.add("ignoredConfigs", ignoredConfigsAsJson);
    return json;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 84 with JsonObject

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

the class ConfigUpdateResult method toJsonArray.

private JsonArray toJsonArray(Set<ConfigNamespace> configs) {
    JsonArray configsAsJson = new JsonArray();
    for (ConfigNamespace ns : configs) {
        JsonObject namespaceAsJson = new JsonObject();
        namespaceAsJson.add("sectionName", ns.getSectionName());
        namespaceAsJson.add("configName", ns.getConfigName());
        configsAsJson.add(namespaceAsJson);
    }
    return configsAsJson;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) ConfigNamespace(com.hazelcast.internal.config.ConfigNamespace) JsonObject(com.hazelcast.internal.json.JsonObject)

Example 85 with JsonObject

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

the class SlowOperationDTO method toJson.

@Override
public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("operation", operation);
    root.add("stackTrace", stackTrace);
    root.add("totalInvocations", totalInvocations);
    JsonArray invocationArray = new JsonArray();
    for (SlowOperationInvocationDTO invocation : invocations) {
        JsonObject json = invocation.toJson();
        if (json != null) {
            invocationArray.add(json);
        }
    }
    root.add("invocations", invocationArray);
    return root;
}
Also used : JsonArray(com.hazelcast.internal.json.JsonArray) 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