Search in sources :

Example 11 with JsonObject

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

the class GetCacheEntryRequest method writeResponse.

@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
    InternalSerializationService serializationService = mcs.getHazelcastInstance().getSerializationService();
    HazelcastInstanceCacheManager cacheManager = mcs.getHazelcastInstance().getCacheManager();
    ICache<Object, Object> cache = cacheManager.getCache(cacheName);
    CacheEntryView cacheEntry = null;
    if ("string".equals(type)) {
        cacheEntry = cache.invoke(key, ENTRY_PROCESSOR, cacheEntry);
    } else if ("long".equals(type)) {
        cacheEntry = cache.invoke(Long.valueOf(key), ENTRY_PROCESSOR, cacheEntry);
    } else if ("integer".equals(type)) {
        cacheEntry = cache.invoke(Integer.valueOf(key), ENTRY_PROCESSOR, cacheEntry);
    }
    JsonObject result = new JsonObject();
    if (cacheEntry != null) {
        Object value = serializationService.toObject(cacheEntry.getValue());
        result.add("cacheBrowse_value", value != null ? value.toString() : "null");
        result.add("cacheBrowse_class", value != null ? value.getClass().getName() : "null");
        result.add("date_cache_creation_time", Long.toString(cacheEntry.getCreationTime()));
        result.add("date_cache_expiration_time", Long.toString(cacheEntry.getExpirationTime()));
        result.add("cacheBrowse_hits", Long.toString(cacheEntry.getAccessHit()));
        result.add("date_cache_access_time", Long.toString(cacheEntry.getLastAccessTime()));
    }
    root.add("result", result);
}
Also used : HazelcastInstanceCacheManager(com.hazelcast.instance.HazelcastInstanceCacheManager) CacheEntryView(com.hazelcast.cache.CacheEntryView) JsonObject(com.eclipsesource.json.JsonObject) JsonObject(com.eclipsesource.json.JsonObject) InternalSerializationService(com.hazelcast.internal.serialization.InternalSerializationService)

Example 12 with JsonObject

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

the class MapConfigRequest method writeResponse.

@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) {
    final JsonObject result = new JsonObject();
    result.add("update", update);
    if (update) {
        final Set<Member> members = mcs.getHazelcastInstance().getCluster().getMembers();
        for (Member member : members) {
            mcs.callOnMember(member, new UpdateMapConfigOperation(mapName, config.getMapConfig()));
        }
        result.add("updateResult", "success");
    } else {
        MapConfig cfg = (MapConfig) mcs.callOnThis(new GetMapConfigOperation(mapName));
        if (cfg != null) {
            result.add("hasMapConfig", true);
            result.add("mapConfig", new MapConfigDTO(cfg).toJson());
        } else {
            result.add("hasMapConfig", false);
        }
    }
    root.add("result", result);
}
Also used : GetMapConfigOperation(com.hazelcast.internal.management.operation.GetMapConfigOperation) MapConfigDTO(com.hazelcast.internal.management.dto.MapConfigDTO) JsonObject(com.eclipsesource.json.JsonObject) UpdateMapConfigOperation(com.hazelcast.internal.management.operation.UpdateMapConfigOperation) MapConfig(com.hazelcast.config.MapConfig) Member(com.hazelcast.core.Member)

Example 13 with JsonObject

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

the class ChangeClusterStateRequest method writeResponse.

@Override
public void writeResponse(ManagementCenterService mcs, JsonObject out) throws Exception {
    String resultString = "SUCCESS";
    try {
        Cluster cluster = mcs.getHazelcastInstance().getCluster();
        cluster.changeClusterState(getClusterState(state));
    } catch (Exception e) {
        ILogger logger = mcs.getHazelcastInstance().node.nodeEngine.getLogger(getClass());
        logger.warning("Cluster state can not be changed: ", e);
        resultString = FAILURE + e.getMessage();
    }
    JsonObject result = new JsonObject().add("result", resultString);
    out.add("result", result);
}
Also used : Cluster(com.hazelcast.core.Cluster) JsonObject(com.eclipsesource.json.JsonObject) ILogger(com.hazelcast.logging.ILogger) JsonUtil.getString(com.hazelcast.util.JsonUtil.getString) IOException(java.io.IOException)

Example 14 with JsonObject

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

the class ClearWanQueuesRequest method toJson.

@Override
public JsonObject toJson() {
    JsonObject root = new JsonObject();
    root.add("schemeName", schemeName);
    root.add("publisherName", publisherName);
    return root;
}
Also used : JsonObject(com.eclipsesource.json.JsonObject)

Example 15 with JsonObject

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

the class ConsoleCommandRequest method writeResponse.

@Override
public void writeResponse(ManagementCenterService mcs, JsonObject root) throws Exception {
    ConsoleCommandHandler handler = mcs.getCommandHandler();
    JsonObject result = new JsonObject();
    try {
        final String output = handler.handleCommand(command);
        result.add("output", output);
    } catch (Throwable e) {
        result.add("output", "Error: " + e.getClass().getSimpleName() + "[" + e.getMessage() + "]");
    }
    root.add("result", result);
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) JsonUtil.getString(com.hazelcast.util.JsonUtil.getString) ConsoleCommandHandler(com.hazelcast.internal.management.ConsoleCommandHandler)

Aggregations

JsonObject (com.eclipsesource.json.JsonObject)499 Test (org.junit.Test)157 URL (java.net.URL)145 JsonArray (com.eclipsesource.json.JsonArray)96 JsonValue (com.eclipsesource.json.JsonValue)43 ParallelTest (com.hazelcast.test.annotation.ParallelTest)36 QuickTest (com.hazelcast.test.annotation.QuickTest)36 ArrayList (java.util.ArrayList)33 HashMap (java.util.HashMap)28 IOException (java.io.IOException)17 Map (java.util.Map)17 Matchers.containsString (org.hamcrest.Matchers.containsString)17 Date (java.util.Date)13 JsonUtil.getString (com.hazelcast.util.JsonUtil.getString)12 MalformedURLException (java.net.MalformedURLException)11 WalletCallException (com.vaklinov.zcashui.ZCashClientCaller.WalletCallException)7 URISyntaxException (java.net.URISyntaxException)6 ExecuteScriptRequest (com.hazelcast.internal.management.request.ExecuteScriptRequest)5 Link (org.eclipse.leshan.Link)5 Jedis (redis.clients.jedis.Jedis)5