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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations