use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project geode by apache.
the class ClusterRegionService method getRegionJson.
/**
* This method is used to get various regions associated with the given cluster and create json
* for each region fields and returns Array List for all the regions associated with given cluster
*
* @param cluster
* @return ArrayNode Array List
*/
private ArrayNode getRegionJson(Cluster cluster) {
Long totalHeapSize = cluster.getTotalHeapSize();
Long totalDiskUsage = cluster.getTotalBytesOnDisk();
Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions();
List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
clusterRegionsList.addAll(clusterRegions.values());
Collections.sort(clusterRegionsList, regionEntryCountComparator);
ArrayNode regionListJson = mapper.createArrayNode();
for (int count = 0; count < clusterRegionsList.size(); count++) {
Cluster.Region reg = clusterRegionsList.get(count);
ObjectNode regionJSON = mapper.createObjectNode();
regionJSON.put("name", reg.getName());
regionJSON.put("totalMemory", totalHeapSize);
regionJSON.put("systemRegionEntryCount", reg.getSystemRegionEntryCount());
regionJSON.put("memberCount", reg.getMemberCount());
final String regionType = reg.getRegionType();
regionJSON.put("type", regionType);
regionJSON.put("getsRate", reg.getGetsRate());
regionJSON.put("putsRate", reg.getPutsRate());
Cluster.Member[] clusterMembersList = cluster.getMembers();
ArrayNode memberNameArray = mapper.createArrayNode();
for (String memberName : reg.getMemberName()) {
for (Cluster.Member member : clusterMembersList) {
String name = member.getName();
name = name.replace(":", "-");
String id = member.getId();
id = id.replace(":", "-");
if ((memberName.equals(id)) || (memberName.equals(name))) {
ObjectNode regionMember = mapper.createObjectNode();
regionMember.put("id", member.getId());
regionMember.put("name", member.getName());
memberNameArray.add(regionMember);
break;
}
}
}
regionJSON.put("memberNames", memberNameArray);
regionJSON.put("entryCount", reg.getSystemRegionEntryCount());
Boolean persistent = reg.getPersistentEnabled();
if (persistent) {
regionJSON.put("persistence", VALUE_ON);
} else {
regionJSON.put("persistence", VALUE_OFF);
}
Boolean isEnableOffHeapMemory = reg.isEnableOffHeapMemory();
if (isEnableOffHeapMemory) {
regionJSON.put("isEnableOffHeapMemory", VALUE_ON);
} else {
regionJSON.put("isEnableOffHeapMemory", VALUE_OFF);
}
String regCompCodec = reg.getCompressionCodec();
if (StringUtils.isNotBlank(regCompCodec)) {
regionJSON.put("compressionCodec", reg.getCompressionCodec());
} else {
regionJSON.put("compressionCodec", VALUE_NA);
}
regionJSON.put("regionPath", reg.getFullPath());
regionJSON.put("memoryReadsTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_GETS_PER_SEC_TREND)));
regionJSON.put("memoryWritesTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_PUTS_PER_SEC_TREND)));
regionJSON.put("diskReadsTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_READS_PER_SEC_TREND)));
regionJSON.put("diskWritesTrend", mapper.valueToTree(reg.getRegionStatisticTrend(Cluster.Region.REGION_STAT_DISK_WRITES_PER_SEC_TREND)));
regionJSON.put("emptyNodes", reg.getEmptyNode());
Long entrySize = reg.getEntrySize();
DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2);
String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
if (entrySize < 0) {
regionJSON.put(this.ENTRY_SIZE, VALUE_NA);
} else {
regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
}
regionJSON.put("dataUsage", reg.getDiskUsage());
regionJSON.put("wanEnabled", reg.getWanEnabled());
regionJSON.put("totalDataUsage", totalDiskUsage);
regionJSON.put("memoryUsage", entrySizeInMB);
regionListJson.add(regionJSON);
}
return regionListJson;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project geode by apache.
the class MemberRegionsService method execute.
public ObjectNode execute(final HttpServletRequest request) throws Exception {
// get cluster object
Cluster cluster = Repository.get().getCluster();
// json object to be sent as response
ObjectNode responseJSON = mapper.createObjectNode();
JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
String memberName = requestDataJSON.get("MemberRegions").get("memberName").textValue();
Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
if (clusterMember != null) {
responseJSON.put("memberId", clusterMember.getId());
responseJSON.put(this.NAME, clusterMember.getName());
responseJSON.put("host", clusterMember.getHost());
// member's regions
Cluster.Region[] memberRegions = clusterMember.getMemberRegionsList();
ArrayNode regionsListJson = mapper.createArrayNode();
for (Cluster.Region memberRegion : memberRegions) {
ObjectNode regionJSON = mapper.createObjectNode();
regionJSON.put(this.NAME, memberRegion.getName());
regionJSON.put("fullPath", memberRegion.getFullPath());
regionJSON.put("type", memberRegion.getRegionType());
regionJSON.put("entryCount", memberRegion.getSystemRegionEntryCount());
Long entrySize = memberRegion.getEntrySize();
DecimalFormat form = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN_2);
String entrySizeInMB = form.format(entrySize / (1024f * 1024f));
if (entrySize < 0) {
regionJSON.put(this.ENTRY_SIZE, VALUE_NA);
} else {
regionJSON.put(this.ENTRY_SIZE, entrySizeInMB);
}
regionJSON.put("scope", memberRegion.getScope());
String diskStoreName = memberRegion.getDiskStoreName();
if (StringUtils.isNotBlank(diskStoreName)) {
regionJSON.put(this.DISC_STORE_NAME, diskStoreName);
regionJSON.put(this.DISC_SYNCHRONOUS, memberRegion.isDiskSynchronous());
} else {
regionJSON.put(this.DISC_SYNCHRONOUS, VALUE_NA);
regionJSON.put(this.DISC_STORE_NAME, "");
}
regionJSON.put("gatewayEnabled", memberRegion.getWanEnabled());
regionsListJson.add(regionJSON);
}
responseJSON.put("memberRegions", regionsListJson);
// response
responseJSON.put("status", "Normal");
}
// Send json response
return responseJSON;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project geode by apache.
the class ClusterMemberService method execute.
public ObjectNode execute(final HttpServletRequest request) throws Exception {
// get cluster object
Cluster cluster = Repository.get().getCluster();
// json object to be sent as response
ObjectNode responseJSON = mapper.createObjectNode();
Cluster.Member[] clusterMembersList = cluster.getMembers();
// create members json
ArrayNode memberListJson = mapper.createArrayNode();
for (Cluster.Member clusterMember : clusterMembersList) {
ObjectNode memberJSON = mapper.createObjectNode();
// getting members detail
memberJSON.put("gemfireVersion", clusterMember.getGemfireVersion());
memberJSON.put("memberId", clusterMember.getId());
memberJSON.put("name", clusterMember.getName());
memberJSON.put("host", clusterMember.getHost());
List<String> serverGroups = clusterMember.getServerGroups();
if (serverGroups.size() == 0) {
serverGroups = new ArrayList<>();
serverGroups.add(PulseConstants.DEFAULT_SERVER_GROUP);
}
memberJSON.put("serverGroups", mapper.valueToTree(serverGroups));
List<String> redundancyZones = clusterMember.getRedundancyZones();
if (redundancyZones.size() == 0) {
redundancyZones = new ArrayList<String>();
redundancyZones.add(PulseConstants.DEFAULT_REDUNDANCY_ZONE);
}
memberJSON.put("redundancyZones", mapper.valueToTree(redundancyZones));
long usedHeapSize = cluster.getUsedHeapSize();
long currentHeap = clusterMember.getCurrentHeapSize();
if (usedHeapSize > 0) {
double heapUsage = ((double) currentHeap / (double) usedHeapSize) * 100;
memberJSON.put(this.HEAP_USAGE, truncate(heapUsage, 2));
} else {
memberJSON.put(this.HEAP_USAGE, 0);
}
double currentCPUUsage = clusterMember.getCpuUsage();
double loadAvg = clusterMember.getLoadAverage();
memberJSON.put("cpuUsage", truncate(currentCPUUsage, 2));
memberJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
memberJSON.put("isManager", clusterMember.isManager());
memberJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(clusterMember.getUptime()));
memberJSON.put("loadAvg", truncate(loadAvg, 2));
memberJSON.put("sockets", clusterMember.getTotalFileDescriptorOpen());
memberJSON.put("threads", clusterMember.getNumThreads());
// Number of member clients
memberJSON.put("clients", clusterMember.getMemberClientsHMap().size());
memberJSON.put("queues", clusterMember.getQueueBacklog());
memberListJson.add(memberJSON);
}
// cluster's Members
responseJSON.put("members", memberListJson);
// Send json response
return responseJSON;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project geode by apache.
the class QueryStatisticsService method execute.
@Override
public ObjectNode execute(final HttpServletRequest request) throws Exception {
// get cluster object
Cluster cluster = Repository.get().getCluster();
// json object to be sent as response
ObjectNode responseJSON = mapper.createObjectNode();
Cluster.Statement[] stmts = cluster.getStatements();
ArrayNode queryListJson = mapper.createArrayNode();
for (int i = 0; i < stmts.length; ++i) {
ObjectNode queryJSON = mapper.createObjectNode();
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QUERYDEFINITION, stmts[i].getQueryDefinition());
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESCOMPILED, mapper.valueToTree(stmts[i].getNumTimesCompiled() < 0 ? this.VALUE_NA : stmts[i].getNumTimesCompiled()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTION, mapper.valueToTree(stmts[i].getNumExecution() < 0 ? this.VALUE_NA : stmts[i].getNumExecution()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMEXECUTIONSINPROGRESS, mapper.valueToTree(stmts[i].getNumExecutionsInProgress() < 0 ? this.VALUE_NA : stmts[i].getNumExecutionsInProgress()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMTIMESGLOBALINDEXLOOKUP, mapper.valueToTree(stmts[i].getNumTimesGlobalIndexLookup() < 0 ? this.VALUE_NA : stmts[i].getNumTimesGlobalIndexLookup()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_NUMROWSMODIFIED, mapper.valueToTree(stmts[i].getNumRowsModified() < 0 ? this.VALUE_NA : stmts[i].getNumRowsModified()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PARSETIME, mapper.valueToTree(stmts[i].getParseTime() < 0 ? this.VALUE_NA : stmts[i].getParseTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_BINDTIME, mapper.valueToTree(stmts[i].getBindTime() < 0 ? this.VALUE_NA : stmts[i].getBindTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_OPTIMIZETIME, mapper.valueToTree(stmts[i].getOptimizeTime() < 0 ? this.VALUE_NA : stmts[i].getOptimizeTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROUTINGINFOTIME, mapper.valueToTree(stmts[i].getRoutingInfoTime() < 0 ? this.VALUE_NA : stmts[i].getRoutingInfoTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_GENERATETIME, mapper.valueToTree(stmts[i].getGenerateTime() < 1 ? this.VALUE_NA : stmts[i].getGenerateTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALCOMPILATIONTIME, mapper.valueToTree(stmts[i].getTotalCompilationTime() < 0 ? this.VALUE_NA : stmts[i].getTotalCompilationTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_EXECUTIONTIME, mapper.valueToTree(stmts[i].getExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getExecutionTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_PROJECTIONTIME, mapper.valueToTree(stmts[i].getProjectionTime() < 0 ? this.VALUE_NA : stmts[i].getProjectionTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_TOTALEXECUTIONTIME, mapper.valueToTree(stmts[i].getTotalExecutionTime() < 0 ? this.VALUE_NA : stmts[i].getTotalExecutionTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_ROWSMODIFICATIONTIME, mapper.valueToTree(stmts[i].getRowsModificationTime() < 0 ? this.VALUE_NA : stmts[i].getRowsModificationTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNNUMROWSSEEN, mapper.valueToTree(stmts[i].getqNNumRowsSeen() < 0 ? this.VALUE_NA : stmts[i].getqNNumRowsSeen()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSENDTIME, mapper.valueToTree(stmts[i].getqNMsgSendTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSendTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNMSGSERTIME, mapper.valueToTree(stmts[i].getqNMsgSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNMsgSerTime()));
queryJSON.put(PulseConstants.MBEAN_ATTRIBUTE_QNRESPDESERTIME, mapper.valueToTree(stmts[i].getqNRespDeSerTime() < 0 ? this.VALUE_NA : stmts[i].getqNRespDeSerTime()));
queryListJson.add(queryJSON);
}
responseJSON.put("queriesList", queryListJson);
// return jmx status
responseJSON.put("connectedFlag", cluster.isConnectedFlag());
responseJSON.put("connectedErrorMsg", cluster.getConnectionErrorMsg());
// Send json response
return responseJSON;
}
use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project geode by apache.
the class SystemAlertsService method getAlertsJson.
/**
* function used for getting all members details in format of JSON Object array defined under a
* cluster
*
* @param cluster
* @return JSONObject Array list
*/
public static ObjectNode getAlertsJson(Cluster cluster, int pageNumber) {
// getting list of all types of alerts
Cluster.Alert[] alertsList = cluster.getAlertsList();
// create alerts json
ObjectNode alertsJsonObject = mapper.createObjectNode();
if ((alertsList != null) && (alertsList.length > 0)) {
ArrayNode errorJsonArray = mapper.createArrayNode();
ArrayNode severeJsonArray = mapper.createArrayNode();
ArrayNode warningJsonArray = mapper.createArrayNode();
ArrayNode infoJsonArray = mapper.createArrayNode();
cluster.setNotificationPageNumber(pageNumber);
for (Cluster.Alert alert : alertsList) {
ObjectNode objAlertJson = mapper.createObjectNode();
objAlertJson.put("description", alert.getDescription());
objAlertJson.put("memberName", alert.getMemberName());
objAlertJson.put("severity", alert.getSeverity());
objAlertJson.put("isAcknowledged", alert.isAcknowledged());
objAlertJson.put("timestamp", alert.getTimestamp().toString());
objAlertJson.put("iso8601Ts", alert.getIso8601Ts());
objAlertJson.put("id", alert.getId());
if (alert.getSeverity() == Cluster.Alert.SEVERE) {
severeJsonArray.add(objAlertJson);
} else if (alert.getSeverity() == Cluster.Alert.ERROR) {
errorJsonArray.add(objAlertJson);
} else if (alert.getSeverity() == Cluster.Alert.WARNING) {
warningJsonArray.add(objAlertJson);
} else {
infoJsonArray.add(objAlertJson);
}
}
alertsJsonObject.put("info", infoJsonArray);
alertsJsonObject.put("warnings", warningJsonArray);
alertsJsonObject.put("errors", errorJsonArray);
alertsJsonObject.put("severe", severeJsonArray);
}
return alertsJsonObject;
}
Aggregations