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);
}
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);
}
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);
}
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;
}
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);
}
Aggregations