Search in sources :

Example 91 with ArrayNode

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

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

the class PulseController method getQueryStatisticsGridModel.

@RequestMapping(value = "/getQueryStatisticsGridModel", method = RequestMethod.GET)
public void getQueryStatisticsGridModel(HttpServletRequest request, HttpServletResponse response) throws IOException {
    ObjectNode responseJSON = mapper.createObjectNode();
    // get cluster object
    Cluster cluster = Repository.get().getCluster();
    String userName = request.getUserPrincipal().getName();
    try {
        String[] arrColNames = Cluster.Statement.getGridColumnNames();
        String[] arrColAttribs = Cluster.Statement.getGridColumnAttributes();
        int[] arrColWidths = Cluster.Statement.getGridColumnWidths();
        ArrayNode colNamesList = mapper.createArrayNode();
        for (int i = 0; i < arrColNames.length; ++i) {
            colNamesList.add(arrColNames[i]);
        }
        ArrayNode colModelList = mapper.createArrayNode();
        for (int i = 0; i < arrColAttribs.length; ++i) {
            ObjectNode columnJSON = mapper.createObjectNode();
            columnJSON.put("name", arrColAttribs[i]);
            columnJSON.put("index", arrColAttribs[i]);
            columnJSON.put("width", arrColWidths[i]);
            columnJSON.put("sortable", "true");
            columnJSON.put("sorttype", ((i == 0) ? "String" : "integer"));
            colModelList.add(columnJSON);
        }
        responseJSON.put("columnNames", colNamesList);
        responseJSON.put("columnModels", colModelList);
        responseJSON.put("clusterName", cluster.getServerName());
        responseJSON.put("userName", userName);
        // Send json response
        response.getOutputStream().write(responseJSON.toString().getBytes());
    } catch (Exception e) {
        logger.debug("Exception Occurred : ", e);
    }
}
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) IOException(java.io.IOException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 93 with ArrayNode

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

the class JobletProfile method toJSON.

@Override
public ObjectNode toJSON() {
    ObjectMapper om = new ObjectMapper();
    ObjectNode json = om.createObjectNode();
    json.put("node-id", nodeId.toString());
    populateCounters(json);
    ArrayNode tasks = om.createArrayNode();
    for (TaskProfile p : taskProfiles.values()) {
        tasks.add(p.toJSON());
    }
    json.set("tasks", tasks);
    return json;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 94 with ArrayNode

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

the class TaskProfile method toJSON.

@Override
public ObjectNode toJSON() {
    ObjectMapper om = new ObjectMapper();
    ObjectNode json = om.createObjectNode();
    json.put("activity-id", taskAttemptId.getTaskId().getActivityId().toString());
    json.put("partition", taskAttemptId.getTaskId().getPartition());
    json.put("attempt", taskAttemptId.getAttempt());
    if (partitionSendProfile != null) {
        ArrayNode pspArray = om.createArrayNode();
        for (PartitionProfile pp : partitionSendProfile.values()) {
            ObjectNode ppObj = om.createObjectNode();
            PartitionId pid = pp.getPartitionId();
            ObjectNode pidObj = om.createObjectNode();
            pidObj.put("job-id", pid.getJobId().toString());
            pidObj.put("connector-id", pid.getConnectorDescriptorId().toString());
            pidObj.put("sender-index", pid.getSenderIndex());
            pidObj.put("receiver-index", pid.getReceiverIndex());
            ppObj.set("partition-id", pidObj);
            ppObj.put("open-time", pp.getOpenTime());
            ppObj.put("close-time", pp.getCloseTime());
            MultiResolutionEventProfiler samples = pp.getSamples();
            ppObj.put("offset", samples.getOffset());
            int resolution = samples.getResolution();
            int sampleCount = samples.getCount();
            ArrayNode ftA = om.createArrayNode();
            int[] ft = samples.getSamples();
            for (int i = 0; i < sampleCount; ++i) {
                ftA.add(ft[i]);
            }
            ppObj.set("frame-times", ftA);
            ppObj.put("resolution", resolution);
            pspArray.add(ppObj);
        }
        json.set("partition-send-profile", pspArray);
    }
    populateCounters(json);
    return json;
}
Also used : MultiResolutionEventProfiler(org.apache.hyracks.control.common.job.profiling.counters.MultiResolutionEventProfiler) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) PartitionId(org.apache.hyracks.api.partitions.PartitionId) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 95 with ArrayNode

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

the class AUnorderedList method toJSON.

@Override
public ObjectNode toJSON() {
    ObjectMapper om = new ObjectMapper();
    ObjectNode json = om.createObjectNode();
    ArrayNode list = om.createArrayNode();
    for (IAObject v : values) {
        list.add(v.toJSON());
    }
    json.set("AUnorderedList", list);
    return json;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

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