Search in sources :

Example 36 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class ClusterWANInfoService 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
    ArrayNode connectedClusterListJson = mapper.createArrayNode();
    for (Map.Entry<String, Boolean> entry : cluster.getWanInformation().entrySet()) {
        ObjectNode clusterJSON = mapper.createObjectNode();
        clusterJSON.put("clusterId", entry.getKey());
        clusterJSON.put("name", entry.getKey());
        clusterJSON.put("status", entry.getValue());
        connectedClusterListJson.add(clusterJSON);
    }
    // Response JSON
    responseJSON.put("connectedClusters", connectedClusterListJson);
    // 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) Map(java.util.Map)

Example 37 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class MemberAsynchEventQueuesService 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("MemberAsynchEventQueues").get("memberName").textValue();
    Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
    if (clusterMember != null) {
        // response
        Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember.getMemberAsyncEventQueueList();
        ArrayNode asyncEventQueueJsonList = mapper.createArrayNode();
        if (asyncEventQueues != null && asyncEventQueues.length > 0) {
            responseJSON.put("isAsyncEventQueuesPresent", true);
            for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) {
                ObjectNode asyncEventQueueJSON = mapper.createObjectNode();
                asyncEventQueueJSON.put("id", asyncEventQueue.getId());
                asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary());
                asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel());
                asyncEventQueueJSON.put("batchSize", asyncEventQueue.getBatchSize());
                asyncEventQueueJSON.put("batchTimeInterval", asyncEventQueue.getBatchTimeInterval());
                asyncEventQueueJSON.put("batchConflationEnabled", asyncEventQueue.isBatchConflationEnabled());
                asyncEventQueueJSON.put("asyncEventListener", asyncEventQueue.getAsyncEventListener());
                asyncEventQueueJSON.put("queueSize", asyncEventQueue.getEventQueueSize());
                asyncEventQueueJsonList.add(asyncEventQueueJSON);
            }
            responseJSON.put("asyncEventQueues", asyncEventQueueJsonList);
        } else {
            responseJSON.put("isAsyncEventQueuesPresent", false);
        }
    }
    // 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) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 38 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class MemberClientsService 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("MemberClients").get("memberName").textValue();
    ArrayNode clientListJson = mapper.createArrayNode();
    Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
    if (clusterMember != null) {
        responseJSON.put("memberId", clusterMember.getId());
        responseJSON.put(this.NAME, clusterMember.getName());
        responseJSON.put(this.HOST, clusterMember.getHost());
        // member's clients
        Cluster.Client[] memberClients = clusterMember.getMemberClients();
        for (Cluster.Client memberClient : memberClients) {
            ObjectNode regionJSON = mapper.createObjectNode();
            regionJSON.put("clientId", memberClient.getId());
            regionJSON.put(this.NAME, memberClient.getName());
            regionJSON.put(this.HOST, memberClient.getHost());
            regionJSON.put("queueSize", memberClient.getQueueSize());
            regionJSON.put("clientCQCount", memberClient.getClientCQCount());
            regionJSON.put("isConnected", memberClient.isConnected() ? "Yes" : "No");
            regionJSON.put("isSubscriptionEnabled", memberClient.isSubscriptionEnabled() ? "Yes" : "No");
            regionJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(memberClient.getUptime()));
            regionJSON.put("cpuUsage", String.format("%.4f", memberClient.getCpuUsage()));
            // regionJSON.put("cpuUsage", memberClient.getCpuUsage());
            regionJSON.put("threads", memberClient.getThreads());
            regionJSON.put("gets", memberClient.getGets());
            regionJSON.put("puts", memberClient.getPuts());
            clientListJson.add(regionJSON);
        }
        responseJSON.put("memberClients", clientListJson);
    }
    // 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) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 39 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class MemberGatewayHubService 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("MemberGatewayHub").get("memberName").textValue();
    Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
    if (clusterMember != null) {
        // response
        // get gateway receiver
        Cluster.GatewayReceiver gatewayReceiver = clusterMember.getGatewayReceiver();
        Boolean isGateway = false;
        if (gatewayReceiver != null) {
            responseJSON.put("isGatewayReceiver", true);
            responseJSON.put("listeningPort", gatewayReceiver.getListeningPort());
            responseJSON.put("linkTroughput", gatewayReceiver.getLinkThroughput());
            responseJSON.put("avgBatchLatency", gatewayReceiver.getAvgBatchProcessingTime());
        } else {
            responseJSON.put("isGatewayReceiver", false);
        }
        // get gateway senders
        Cluster.GatewaySender[] gatewaySenders = clusterMember.getMemberGatewaySenders();
        if (gatewaySenders.length > 0) {
            isGateway = true;
        }
        responseJSON.put("isGatewaySender", isGateway);
        // Senders
        ArrayNode gatewaySendersJsonList = mapper.createArrayNode();
        for (Cluster.GatewaySender gatewaySender : gatewaySenders) {
            ObjectNode gatewaySenderJSON = mapper.createObjectNode();
            gatewaySenderJSON.put("id", gatewaySender.getId());
            gatewaySenderJSON.put("queueSize", gatewaySender.getQueueSize());
            gatewaySenderJSON.put("status", gatewaySender.getStatus());
            gatewaySenderJSON.put("primary", gatewaySender.getPrimary());
            gatewaySenderJSON.put("senderType", gatewaySender.getSenderType());
            gatewaySenderJSON.put("batchSize", gatewaySender.getBatchSize());
            gatewaySenderJSON.put("PersistenceEnabled", gatewaySender.getPersistenceEnabled());
            gatewaySenderJSON.put("remoteDSId", gatewaySender.getRemoteDSId());
            gatewaySenderJSON.put("eventsExceedingAlertThreshold", gatewaySender.getEventsExceedingAlertThreshold());
            gatewaySendersJsonList.add(gatewaySenderJSON);
        }
        // senders response
        responseJSON.put("gatewaySenders", gatewaySendersJsonList);
        // async event queues
        Cluster.AsyncEventQueue[] asyncEventQueues = clusterMember.getMemberAsyncEventQueueList();
        ArrayNode asyncEventQueueJsonList = mapper.createArrayNode();
        for (Cluster.AsyncEventQueue asyncEventQueue : asyncEventQueues) {
            ObjectNode asyncEventQueueJSON = mapper.createObjectNode();
            asyncEventQueueJSON.put("id", asyncEventQueue.getId());
            asyncEventQueueJSON.put("primary", asyncEventQueue.getPrimary());
            asyncEventQueueJSON.put("senderType", asyncEventQueue.isParallel());
            asyncEventQueueJSON.put("batchSize", asyncEventQueue.getBatchSize());
            asyncEventQueueJSON.put("batchTimeInterval", asyncEventQueue.getBatchTimeInterval());
            asyncEventQueueJSON.put("batchConflationEnabled", asyncEventQueue.isBatchConflationEnabled());
            asyncEventQueueJSON.put("asyncEventListener", asyncEventQueue.getAsyncEventListener());
            asyncEventQueueJSON.put("queueSize", asyncEventQueue.getEventQueueSize());
            asyncEventQueueJsonList.add(asyncEventQueueJSON);
        }
        responseJSON.put("asyncEventQueues", asyncEventQueueJsonList);
        Map<String, Cluster.Region> clusterRegions = cluster.getClusterRegions();
        List<Cluster.Region> clusterRegionsList = new ArrayList<Cluster.Region>();
        clusterRegionsList.addAll(clusterRegions.values());
        ArrayNode regionsList = mapper.createArrayNode();
        for (Cluster.Region region : clusterRegionsList) {
            if (region.getWanEnabled()) {
                ObjectNode regionJSON = mapper.createObjectNode();
                regionJSON.put("name", region.getName());
                regionsList.add(regionJSON);
            }
        }
        responseJSON.put("regionsInvolved", regionsList);
    }
    // Send json response
    return responseJSON;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayList(java.util.ArrayList) Cluster(org.apache.geode.tools.pulse.internal.data.Cluster) JsonNode(com.fasterxml.jackson.databind.JsonNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 40 with Cluster

use of org.apache.geode.tools.pulse.internal.data.Cluster in project geode by apache.

the class MemberHeapUsageService 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("MemberHeapUsage").get("memberName").textValue();
    Cluster.Member clusterMember = cluster.getMember(makeCompliantName(memberName));
    if (clusterMember != null) {
        // response
        responseJSON.put("heapUsageTrend", mapper.valueToTree(clusterMember.getMemberStatisticTrend(Cluster.Member.MEMBER_STAT_HEAP_USAGE_SAMPLE)));
        responseJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
    }
    // 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)

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