Search in sources :

Example 11 with Cluster

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 12 with Cluster

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DecimalFormat(java.text.DecimalFormat) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 13 with Cluster

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 14 with Cluster

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 15 with Cluster

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)43 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)39 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)18 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 IOException (java.io.IOException)7 DecimalFormat (java.text.DecimalFormat)7 ArrayList (java.util.ArrayList)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Repository (org.apache.geode.tools.pulse.internal.data.Repository)2 File (java.io.File)1 Random (java.util.Random)1 CircularFifoBuffer (org.apache.commons.collections.buffer.CircularFifoBuffer)1 Client (org.apache.geode.tools.pulse.internal.data.Cluster.Client)1 Member (org.apache.geode.tools.pulse.internal.data.Cluster.Member)1 Region (org.apache.geode.tools.pulse.internal.data.Cluster.Region)1