Search in sources :

Example 86 with ArrayNode

use of com.fasterxml.jackson.databind.node.ArrayNode in project asterixdb by apache.

the class JobStatusAPIIntegrationTest method checkActivityCluster.

protected void checkActivityCluster(ObjectNode result) {
    Assert.assertTrue(result.has("activity-clusters"));
    ArrayNode actClusters = (ArrayNode) result.get("activity-clusters");
    Assert.assertEquals(1, actClusters.size());
    ObjectNode actCluster = (ObjectNode) actClusters.get(0);
    Assert.assertTrue(actCluster.has("activities"));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Example 87 with ArrayNode

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

Example 88 with ArrayNode

use of 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;
}
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 89 with ArrayNode

use of 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;
}
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 90 with ArrayNode

use of 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;
}
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

ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)277 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)167 JsonNode (com.fasterxml.jackson.databind.JsonNode)97 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)57 ArrayList (java.util.ArrayList)32 HashMap (java.util.HashMap)27 Test (org.junit.Test)25 Deployment (org.activiti.engine.test.Deployment)23 StringEntity (org.apache.http.entity.StringEntity)20 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)19 Cluster (org.apache.geode.tools.pulse.internal.data.Cluster)18 IOException (java.io.IOException)16 Map (java.util.Map)16 HttpPost (org.apache.http.client.methods.HttpPost)16 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)14 Task (org.activiti.engine.task.Task)13 GraphicInfo (org.activiti.bpmn.model.GraphicInfo)10 TextNode (com.fasterxml.jackson.databind.node.TextNode)8 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)7 MissingNode (com.fasterxml.jackson.databind.node.MissingNode)7