Search in sources :

Example 46 with ArrayNode

use of org.apache.flink.shaded.jackson2.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 47 with ArrayNode

use of org.apache.flink.shaded.jackson2.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 48 with ArrayNode

use of org.apache.flink.shaded.jackson2.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 49 with ArrayNode

use of org.apache.flink.shaded.jackson2.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)

Example 50 with ArrayNode

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ArrayNode in project asterixdb by apache.

the class NodesAPIIntegrationTest method getNodeIds.

private List<String> getNodeIds() throws IOException, URISyntaxException {
    ArrayNode nodes = getNodeSummaries();
    final int size = nodes.size();
    List<String> nodeIds = new ArrayList<>();
    for (int i = 0; i < size; ++i) {
        nodeIds.add(nodes.get(i).get("node-id").asText());
    }
    return nodeIds;
}
Also used : ArrayList(java.util.ArrayList) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)979 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)542 JsonNode (com.fasterxml.jackson.databind.JsonNode)402 Test (org.junit.Test)140 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)125 ArrayList (java.util.ArrayList)110 IOException (java.io.IOException)93 Map (java.util.Map)74 HashMap (java.util.HashMap)68 List (java.util.List)50 TextNode (com.fasterxml.jackson.databind.node.TextNode)38 Test (org.testng.annotations.Test)35 DefaultSerializerProvider (com.fasterxml.jackson.databind.ser.DefaultSerializerProvider)30 HashSet (java.util.HashSet)30 JsonNodeFactory (com.fasterxml.jackson.databind.node.JsonNodeFactory)25 Deployment (org.activiti.engine.test.Deployment)23 File (java.io.File)22 InputStream (java.io.InputStream)20 Iterator (java.util.Iterator)20 StringEntity (org.apache.http.entity.StringEntity)20