use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.
the class MemberGCPausesService 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();
// members list
JsonNode requestDataJSON = mapper.readTree(request.getParameter("pulseData"));
String memberName = requestDataJSON.get("MemberGCPauses").get("memberName").textValue();
Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
if (clusterMember != null) {
// response
responseJSON.put("gcPausesTrend", mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_GARBAGE_COLLECTION)));
responseJSON.put("gcPausesCount", clusterMember.getGarbageCollectionCount());
}
// Send json response
return responseJSON;
}
use of org.apache.geode.tools.pulse.internal.data.Cluster 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.geode.tools.pulse.internal.data.Cluster 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.geode.tools.pulse.internal.data.Cluster 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.geode.tools.pulse.internal.data.Cluster 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