ASTERIXDB-1714: Eliminate dependency on org.json
Change-Id: Ie9c5400fd134ae75d43385255af7794e968b1c7e
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1392
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/pom.xml b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/pom.xml
index 350a7b3..636e1fe 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/pom.xml
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/pom.xml
@@ -102,14 +102,18 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20090211</version>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.5</version>
</dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>18.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/NodeControllerState.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/NodeControllerState.java
index ca980b9..bf94dff 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/NodeControllerState.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/NodeControllerState.java
@@ -25,6 +25,8 @@
import java.util.Map;
import java.util.Set;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.comm.NetworkAddress;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.control.common.base.INodeController;
@@ -33,8 +35,6 @@
import org.apache.hyracks.control.common.heartbeat.HeartbeatData;
import org.apache.hyracks.control.common.heartbeat.HeartbeatSchema;
import org.apache.hyracks.control.common.heartbeat.HeartbeatSchema.GarbageCollectorInfo;
-import org.json.JSONException;
-import org.json.JSONObject;
public class NodeControllerState {
private static final int RRD_SIZE = 720;
@@ -277,13 +277,13 @@
public NetworkAddress getMessagingPort() {
return messagingPort;
}
-
public int getNumCores() {
return numCores;
}
- public synchronized JSONObject toSummaryJSON() throws JSONException {
- JSONObject o = new JSONObject();
+ public synchronized ObjectNode toSummaryJSON() {
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode o = om.createObjectNode();
o.put("node-id", ncConfig.nodeId);
o.put("heap-used", heapUsedSize[(rrdPtr + RRD_SIZE - 1) % RRD_SIZE]);
o.put("system-load-average", systemLoadAverage[(rrdPtr + RRD_SIZE - 1) % RRD_SIZE]);
@@ -291,8 +291,9 @@
return o;
}
- public synchronized JSONObject toDetailedJSON(boolean includeStats, boolean includeConfig) throws JSONException {
- JSONObject o = new JSONObject();
+ public synchronized ObjectNode toDetailedJSON(boolean includeStats, boolean includeConfig) {
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode o = om.createObjectNode();
o.put("node-id", ncConfig.nodeId);
@@ -304,45 +305,45 @@
o.put("vm-name", vmName);
o.put("vm-version", vmVersion);
o.put("vm-vendor", vmVendor);
- o.put("classpath", classpath.split(File.pathSeparator));
- o.put("library-path", libraryPath.split(File.pathSeparator));
- o.put("boot-classpath", bootClasspath.split(File.pathSeparator));
- o.put("input-arguments", inputArguments);
- o.put("system-properties", systemProperties);
+ o.putPOJO("classpath", classpath.split(File.pathSeparator));
+ o.putPOJO("library-path", libraryPath.split(File.pathSeparator));
+ o.putPOJO("boot-classpath", bootClasspath.split(File.pathSeparator));
+ o.putPOJO("input-arguments", inputArguments);
+ o.putPOJO("system-properties", systemProperties);
o.put("pid", pid);
}
if (includeStats) {
- o.put("date", new Date());
+ o.putPOJO("date", new Date());
o.put("rrd-ptr", rrdPtr);
- o.put("heartbeat-times", hbTime);
- o.put("heap-init-sizes", heapInitSize);
- o.put("heap-used-sizes", heapUsedSize);
- o.put("heap-committed-sizes", heapCommittedSize);
- o.put("heap-max-sizes", heapMaxSize);
- o.put("nonheap-init-sizes", nonheapInitSize);
- o.put("nonheap-used-sizes", nonheapUsedSize);
- o.put("nonheap-committed-sizes", nonheapCommittedSize);
- o.put("nonheap-max-sizes", nonheapMaxSize);
- o.put("thread-counts", threadCount);
- o.put("peak-thread-counts", peakThreadCount);
- o.put("system-load-averages", systemLoadAverage);
- o.put("gc-names", gcNames);
- o.put("gc-collection-counts", gcCollectionCounts);
- o.put("gc-collection-times", gcCollectionTimes);
- o.put("net-payload-bytes-read", netPayloadBytesRead);
- o.put("net-payload-bytes-written", netPayloadBytesWritten);
- o.put("net-signaling-bytes-read", netSignalingBytesRead);
- o.put("net-signaling-bytes-written", netSignalingBytesWritten);
- o.put("dataset-net-payload-bytes-read", datasetNetPayloadBytesRead);
- o.put("dataset-net-payload-bytes-written", datasetNetPayloadBytesWritten);
- o.put("dataset-net-signaling-bytes-read", datasetNetSignalingBytesRead);
- o.put("dataset-net-signaling-bytes-written", datasetNetSignalingBytesWritten);
- o.put("ipc-messages-sent", ipcMessagesSent);
- o.put("ipc-message-bytes-sent", ipcMessageBytesSent);
- o.put("ipc-messages-received", ipcMessagesReceived);
- o.put("ipc-message-bytes-received", ipcMessageBytesReceived);
- o.put("disk-reads", diskReads);
- o.put("disk-writes", diskWrites);
+ o.putPOJO("heartbeat-times", hbTime);
+ o.putPOJO("heap-init-sizes", heapInitSize);
+ o.putPOJO("heap-used-sizes", heapUsedSize);
+ o.putPOJO("heap-committed-sizes", heapCommittedSize);
+ o.putPOJO("heap-max-sizes", heapMaxSize);
+ o.putPOJO("nonheap-init-sizes", nonheapInitSize);
+ o.putPOJO("nonheap-used-sizes", nonheapUsedSize);
+ o.putPOJO("nonheap-committed-sizes", nonheapCommittedSize);
+ o.putPOJO("nonheap-max-sizes", nonheapMaxSize);
+ o.putPOJO("thread-counts", threadCount);
+ o.putPOJO("peak-thread-counts", peakThreadCount);
+ o.putPOJO("system-load-averages", systemLoadAverage);
+ o.putPOJO("gc-names", gcNames);
+ o.putPOJO("gc-collection-counts", gcCollectionCounts);
+ o.putPOJO("gc-collection-times", gcCollectionTimes);
+ o.putPOJO("net-payload-bytes-read", netPayloadBytesRead);
+ o.putPOJO("net-payload-bytes-written", netPayloadBytesWritten);
+ o.putPOJO("net-signaling-bytes-read", netSignalingBytesRead);
+ o.putPOJO("net-signaling-bytes-written", netSignalingBytesWritten);
+ o.putPOJO("dataset-net-payload-bytes-read", datasetNetPayloadBytesRead);
+ o.putPOJO("dataset-net-payload-bytes-written", datasetNetPayloadBytesWritten);
+ o.putPOJO("dataset-net-signaling-bytes-read", datasetNetSignalingBytesRead);
+ o.putPOJO("dataset-net-signaling-bytes-written", datasetNetSignalingBytesWritten);
+ o.putPOJO("ipc-messages-sent", ipcMessagesSent);
+ o.putPOJO("ipc-message-bytes-sent", ipcMessageBytesSent);
+ o.putPOJO("ipc-messages-received", ipcMessagesReceived);
+ o.putPOJO("ipc-message-bytes-received", ipcMessageBytesReceived);
+ o.putPOJO("disk-reads", diskReads);
+ o.putPOJO("disk-writes", diskWrites);
}
return o;
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/IndexPage.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/IndexPage.java
index 32ac3f5..680c2a7 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/IndexPage.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/IndexPage.java
@@ -18,22 +18,23 @@
*/
package org.apache.hyracks.control.cc.adminconsole.pages;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Lists;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.request.mapper.parameter.PageParameters;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.apache.hyracks.control.cc.ClusterControllerService;
-import org.apache.hyracks.control.cc.web.util.JSONUtils;
import org.apache.hyracks.control.cc.work.GetJobSummariesJSONWork;
import org.apache.hyracks.control.cc.work.GetNodeSummariesJSONWork;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.List;
public class IndexPage extends AbstractPage {
private static final long serialVersionUID = 1L;
@@ -43,49 +44,42 @@
GetNodeSummariesJSONWork gnse = new GetNodeSummariesJSONWork(ccs);
ccs.getWorkQueue().scheduleAndSync(gnse);
- JSONArray nodeSummaries = gnse.getSummaries();
- add(new Label("node-count", String.valueOf(nodeSummaries.length())));
- ListView<JSONObject> nodeList = new ListView<JSONObject>("node-list", JSONUtils.toList(nodeSummaries)) {
+ ArrayNode nodeSummaries = gnse.getSummaries();
+ add(new Label("node-count", String.valueOf(nodeSummaries.size())));
+ ListView<JsonNode> nodeList = new ListView<JsonNode>("node-list",
+ Lists.newArrayList(nodeSummaries.iterator())) {
private static final long serialVersionUID = 1L;
@Override
- protected void populateItem(ListItem<JSONObject> item) {
- JSONObject o = item.getModelObject();
- try {
- item.add(new Label("node-id", o.getString("node-id")));
- item.add(new Label("heap-used", o.getString("heap-used")));
- item.add(new Label("system-load-average", o.getString("system-load-average")));
- PageParameters params = new PageParameters();
- params.add("node-id", o.getString("node-id"));
- item.add(new BookmarkablePageLink<Object>("node-details", NodeDetailsPage.class, params));
- } catch (JSONException e) {
- throw new RuntimeException(e);
- }
+ protected void populateItem(ListItem<JsonNode> item) {
+ JsonNode o = item.getModelObject();
+ item.add(new Label("node-id", o.get("node-id").asText()));
+ item.add(new Label("heap-used", o.get("heap-used").asText()));
+ item.add(new Label("system-load-average", o.get("system-load-average").asText()));
+ PageParameters params = new PageParameters();
+ params.add("node-id", o.get("node-id").asText());
+ item.add(new BookmarkablePageLink<Object>("node-details", NodeDetailsPage.class, params));
}
};
add(nodeList);
GetJobSummariesJSONWork gjse = new GetJobSummariesJSONWork(ccs);
ccs.getWorkQueue().scheduleAndSync(gjse);
- JSONArray jobSummaries = gjse.getSummaries();
- ListView<JSONObject> jobList = new ListView<JSONObject>("jobs-list", JSONUtils.toList(jobSummaries)) {
+ ArrayNode jobSummaries = gjse.getSummaries();
+ ListView<JsonNode> jobList = new ListView<JsonNode>("jobs-list", Lists.newArrayList(jobSummaries.iterator())) {
private static final long serialVersionUID = 1L;
@Override
- protected void populateItem(ListItem<JSONObject> item) {
- JSONObject o = item.getModelObject();
- try {
- item.add(new Label("job-id", o.getString("job-id")));
- item.add(new Label("status", o.getString("status")));
- item.add(new Label("create-time", longToDateString(Long.parseLong(o.getString("create-time")))));
- item.add(new Label("start-time", longToDateString(Long.parseLong(o.getString("start-time")))));
- item.add(new Label("end-time", longToDateString(Long.parseLong(o.getString("end-time")))));
- PageParameters params = new PageParameters();
- params.add("job-id", o.getString("job-id"));
- item.add(new BookmarkablePageLink<Object>("job-details", JobDetailsPage.class, params));
- } catch (JSONException e) {
- throw new RuntimeException(e);
- }
+ protected void populateItem(ListItem<JsonNode> item) {
+ JsonNode o = item.getModelObject();
+ item.add(new Label("job-id", o.get("job-id").asText()));
+ item.add(new Label("status", o.get("status").asText()));
+ item.add(new Label("create-time", longToDateString(Long.parseLong(o.get("create-time").asText()))));
+ item.add(new Label("start-time", longToDateString(Long.parseLong(o.get("start-time").asText()))));
+ item.add(new Label("end-time", longToDateString(Long.parseLong(o.get("end-time").asText()))));
+ PageParameters params = new PageParameters();
+ params.add("job-id", o.get("job-id"));
+ item.add(new BookmarkablePageLink<Object>("job-details", JobDetailsPage.class, params));
}
};
add(jobList);
@@ -99,4 +93,4 @@
Date date = new Date(milliseconds);
return sdf.format(date);
}
-}
\ No newline at end of file
+}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/JobDetailsPage.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/JobDetailsPage.java
index 7898122..abc07d9 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/JobDetailsPage.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/adminconsole/pages/JobDetailsPage.java
@@ -26,11 +26,12 @@
import java.util.List;
import java.util.Map;
+import com.fasterxml.jackson.databind.JsonNode;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.string.StringValue;
-import org.json.JSONArray;
-import org.json.JSONObject;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.dataflow.ActivityId;
import org.apache.hyracks.api.dataflow.TaskAttemptId;
@@ -58,19 +59,19 @@
jag.setEscapeModelStrings(false);
add(jag);
- JSONObject jagO = gacgw.getJSON();
+ ObjectNode jagO = gacgw.getJSON();
Map<ActivityId, String> activityMap = new HashMap<ActivityId, String>();
if (jagO.has("activity-clusters")) {
- JSONArray acArray = jagO.getJSONArray("activity-clusters");
- for (int j = 0; j < acArray.length(); ++j) {
- JSONObject acO = acArray.getJSONObject(j);
+ JsonNode acArray = jagO.get("activity-clusters");
+ for (int j = 0; j < acArray.size(); ++j) {
+ JsonNode acO = acArray.get(j);
if (acO.has("activities")) {
- JSONArray aArray = acO.getJSONArray("activities");
- for (int i = 0; i < aArray.length(); ++i) {
- JSONObject aO = aArray.getJSONObject(i);
- ActivityId aid = ActivityId.parse(aO.getString("id"));
- String className = aO.getString("java-class");
+ JsonNode aArray = acO.get("activities");
+ for (int i = 0; i < aArray.size(); ++i) {
+ JsonNode aO = aArray.get(i);
+ ActivityId aid = ActivityId.parse(aO.get("id").asText());
+ String className = aO.get("java-class").asText();
activityMap.put(aid, className);
}
@@ -84,30 +85,30 @@
jobrun.setEscapeModelStrings(false);
add(jobrun);
- JSONObject jrO = gjrw.getJSON();
+ ObjectNode jrO = gjrw.getJSON();
List<TaskClusterAttempt[]> tcList = new ArrayList<TaskClusterAttempt[]>();
long minTime = Long.MAX_VALUE;
long maxTime = Long.MIN_VALUE;
if (jrO.has("activity-clusters")) {
- JSONArray acA = jrO.getJSONArray("activity-clusters");
- for (int i = 0; i < acA.length(); ++i) {
- JSONObject acO = acA.getJSONObject(i);
+ JsonNode acA = jrO.get("activity-clusters");
+ for (int i = 0; i < acA.size(); ++i) {
+ JsonNode acO = acA.get(i);
if (acO.has("plan")) {
- JSONObject planO = acO.getJSONObject("plan");
+ JsonNode planO = acO.get("plan");
if (planO.has("task-clusters")) {
- JSONArray tcA = planO.getJSONArray("task-clusters");
- for (int j = 0; j < tcA.length(); ++j) {
- JSONObject tcO = tcA.getJSONObject(j);
- String tcId = tcO.getString("task-cluster-id");
+ JsonNode tcA = planO.get("task-clusters");
+ for (int j = 0; j < tcA.size(); ++j) {
+ JsonNode tcO = tcA.get(j);
+ String tcId = tcO.get("task-cluster-id").asText();
if (tcO.has("attempts")) {
- JSONArray tcaA = tcO.getJSONArray("attempts");
- TaskClusterAttempt[] tcAttempts = new TaskClusterAttempt[tcaA.length()];
- for (int k = 0; k < tcaA.length(); ++k) {
- JSONObject tcaO = tcaA.getJSONObject(k);
- int attempt = tcaO.getInt("attempt");
- long startTime = tcaO.getLong("start-time");
- long endTime = tcaO.getLong("end-time");
+ JsonNode tcaA = tcO.get("attempts");
+ TaskClusterAttempt[] tcAttempts = new TaskClusterAttempt[tcaA.size()];
+ for (int k = 0; k < tcaA.size(); ++k) {
+ JsonNode tcaO = tcaA.get(k);
+ int attempt = tcaO.get("attempt").asInt();
+ long startTime = tcaO.get("start-time").asLong();
+ long endTime = tcaO.get("end-time").asLong();
tcAttempts[k] = new TaskClusterAttempt(tcId, attempt, startTime, endTime);
if (startTime < minTime) {
@@ -117,13 +118,13 @@
maxTime = endTime;
}
if (tcaO.has("task-attempts")) {
- JSONArray taArray = tcaO.getJSONArray("task-attempts");
- tcAttempts[k].tasks = new TaskAttempt[taArray.length()];
- for (int l = 0; l < taArray.length(); ++l) {
- JSONObject taO = taArray.getJSONObject(l);
- TaskAttemptId taId = TaskAttemptId.parse(taO.getString("task-attempt-id"));
- TaskAttempt ta = new TaskAttempt(taId, taO.getLong("start-time"),
- taO.getLong("end-time"));
+ JsonNode taArray = tcaO.get("task-attempts");
+ tcAttempts[k].tasks = new TaskAttempt[taArray.size()];
+ for (int l = 0; l < taArray.size(); ++l) {
+ JsonNode taO = taArray.get(l);
+ TaskAttemptId taId = TaskAttemptId.parse(taO.get("task-attempt-id").asText());
+ TaskAttempt ta = new TaskAttempt(taId, taO.get("start-time").asLong(),
+ taO.get("end-time").asLong());
tcAttempts[k].tasks[l] = ta;
TaskId tid = taId.getTaskId();
ta.name = activityMap.get(tid.getActivityId());
@@ -154,31 +155,31 @@
Map<TaskAttemptId, TaskProfile> tpMap = new HashMap<TaskAttemptId, TaskProfile>();
if (jrO.has("profile")) {
- JSONObject pO = jrO.getJSONObject("profile");
+ JsonNode pO = jrO.get("profile");
if (pO.has("joblets")) {
- JSONArray jobletsA = pO.getJSONArray("joblets");
- for (int i = 0; i < jobletsA.length(); ++i) {
- JSONObject jobletO = jobletsA.getJSONObject(i);
+ JsonNode jobletsA = pO.get("joblets");
+ for (int i = 0; i < jobletsA.size(); ++i) {
+ JsonNode jobletO = jobletsA.get(i);
if (jobletO.has("tasks")) {
- JSONArray tasksA = jobletO.getJSONArray("tasks");
- for (int j = 0; j < tasksA.length(); ++j) {
- JSONObject taskO = tasksA.getJSONObject(j);
- ActivityId activityId = ActivityId.parse(taskO.getString("activity-id"));
- int partition = taskO.getInt("partition");
- int attempt = taskO.getInt("attempt");
+ JsonNode tasksA = jobletO.get("tasks");
+ for (int j = 0; j < tasksA.size(); ++j) {
+ JsonNode taskO = tasksA.get(j);
+ ActivityId activityId = ActivityId.parse(taskO.get("activity-id").asText());
+ int partition = taskO.get("partition").asInt();
+ int attempt = taskO.get("attempt").asInt();
TaskAttemptId taId = new TaskAttemptId(new TaskId(activityId, partition), attempt);
if (taskO.has("partition-send-profile")) {
- JSONArray taskProfilesA = taskO.getJSONArray("partition-send-profile");
- for (int k = 0; k < taskProfilesA.length(); ++k) {
- JSONObject ppO = taskProfilesA.getJSONObject(k);
- long openTime = ppO.getLong("open-time");
- long closeTime = ppO.getLong("close-time");
- int resolution = ppO.getInt("resolution");
- long offset = ppO.getLong("offset");
- JSONArray frameTimesA = ppO.getJSONArray("frame-times");
- long[] frameTimes = new long[frameTimesA.length()];
+ JsonNode taskProfilesA = taskO.get("partition-send-profile");
+ for (int k = 0; k < taskProfilesA.size(); ++k) {
+ JsonNode ppO = taskProfilesA.get(k);
+ long openTime = ppO.get("open-time").asLong();
+ long closeTime = ppO.get("close-time").asLong();
+ int resolution = ppO.get("resolution").asInt();
+ long offset = ppO.get("offset").asLong();
+ JsonNode frameTimesA = ppO.get("frame-times");
+ long[] frameTimes = new long[frameTimesA.size()];
for (int l = 0; l < frameTimes.length; ++l) {
- frameTimes[l] = frameTimesA.getInt(l) + offset;
+ frameTimes[l] = frameTimesA.get(l).asLong() + offset;
}
TaskProfile tp = new TaskProfile(taId, openTime, closeTime, frameTimes, resolution);
if (!tpMap.containsKey(tp.taId)) {
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/job/JobRun.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/job/JobRun.java
index dbe4202..f1d04bb 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/job/JobRun.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/job/JobRun.java
@@ -28,10 +28,9 @@
import java.util.Map;
import java.util.Set;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.dataflow.ActivityId;
import org.apache.hyracks.api.dataflow.ConnectorDescriptorId;
import org.apache.hyracks.api.dataflow.OperatorDescriptorId;
@@ -237,131 +236,132 @@
return connectorPolicyMap;
}
- public JSONObject toJSON() throws JSONException {
- JSONObject result = new JSONObject();
+ public ObjectNode toJSON() {
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode result = om.createObjectNode();
result.put("job-id", jobId.toString());
- result.put("status", getStatus());
+ result.putPOJO("status", getStatus());
result.put("create-time", getCreateTime());
result.put("start-time", getStartTime());
result.put("end-time", getEndTime());
- JSONArray aClusters = new JSONArray();
+ ArrayNode aClusters = om.createArrayNode();
for (ActivityCluster ac : acg.getActivityClusterMap().values()) {
- JSONObject acJSON = new JSONObject();
+ ObjectNode acJSON = om.createObjectNode();
acJSON.put("activity-cluster-id", String.valueOf(ac.getId()));
- JSONArray activitiesJSON = new JSONArray();
+ ArrayNode activitiesJSON = om.createArrayNode();
for (ActivityId aid : ac.getActivityMap().keySet()) {
- activitiesJSON.put(aid);
+ activitiesJSON.addPOJO(aid);
}
- acJSON.put("activities", activitiesJSON);
+ acJSON.set("activities", activitiesJSON);
- JSONArray dependenciesJSON = new JSONArray();
+ ArrayNode dependenciesJSON = om.createArrayNode();
for (ActivityCluster dependency : ac.getDependencies()) {
- dependenciesJSON.put(String.valueOf(dependency.getId()));
+ dependenciesJSON.add(String.valueOf(dependency.getId()));
}
- acJSON.put("dependencies", dependenciesJSON);
+ acJSON.set("dependencies", dependenciesJSON);
ActivityClusterPlan acp = activityClusterPlanMap.get(ac.getId());
if (acp == null) {
- acJSON.put("plan", (Object) null);
+ acJSON.putNull("plan");
} else {
- JSONObject planJSON = new JSONObject();
+ ObjectNode planJSON = om.createObjectNode();
- JSONArray acTasks = new JSONArray();
+ ArrayNode acTasks = om.createArrayNode();
for (Map.Entry<ActivityId, ActivityPlan> e : acp.getActivityPlanMap().entrySet()) {
ActivityPlan acPlan = e.getValue();
- JSONObject entry = new JSONObject();
+ ObjectNode entry = om.createObjectNode();
entry.put("activity-id", e.getKey().toString());
ActivityPartitionDetails apd = acPlan.getActivityPartitionDetails();
entry.put("partition-count", apd.getPartitionCount());
- JSONArray inPartCountsJSON = new JSONArray();
+ ArrayNode inPartCountsJSON = om.createArrayNode();
int[] inPartCounts = apd.getInputPartitionCounts();
if (inPartCounts != null) {
for (int i : inPartCounts) {
- inPartCountsJSON.put(i);
+ inPartCountsJSON.add(i);
}
}
- entry.put("input-partition-counts", inPartCountsJSON);
+ entry.set("input-partition-counts", inPartCountsJSON);
- JSONArray outPartCountsJSON = new JSONArray();
+ ArrayNode outPartCountsJSON = om.createArrayNode();
int[] outPartCounts = apd.getOutputPartitionCounts();
if (outPartCounts != null) {
for (int o : outPartCounts) {
- outPartCountsJSON.put(o);
+ outPartCountsJSON.add(o);
}
}
- entry.put("output-partition-counts", outPartCountsJSON);
+ entry.set("output-partition-counts", outPartCountsJSON);
- JSONArray tasks = new JSONArray();
+ ArrayNode tasks = om.createArrayNode();
for (Task t : acPlan.getTasks()) {
- JSONObject task = new JSONObject();
+ ObjectNode task = om.createObjectNode();
task.put("task-id", t.getTaskId().toString());
- JSONArray dependentTasksJSON = new JSONArray();
+ ArrayNode dependentTasksJSON = om.createArrayNode();
for (TaskId dependent : t.getDependents()) {
- dependentTasksJSON.put(dependent.toString());
- }
- task.put("dependents", dependentTasksJSON);
+ dependentTasksJSON.add(dependent.toString());
+ task.set("dependents", dependentTasksJSON);
- JSONArray dependencyTasksJSON = new JSONArray();
+ ArrayNode dependencyTasksJSON = om.createArrayNode();
for (TaskId dependency : t.getDependencies()) {
- dependencyTasksJSON.put(dependency.toString());
+ dependencyTasksJSON.add(dependency.toString());
}
- task.put("dependencies", dependencyTasksJSON);
+ task.set("dependencies", dependencyTasksJSON);
- tasks.put(task);
+ tasks.add(task);
}
- entry.put("tasks", tasks);
+ entry.set("tasks", tasks);
- acTasks.put(entry);
+ acTasks.add(entry);
+ }
}
- planJSON.put("activities", acTasks);
+ planJSON.set("activities", acTasks);
- JSONArray tClusters = new JSONArray();
+ ArrayNode tClusters = om.createArrayNode();
for (TaskCluster tc : acp.getTaskClusters()) {
- JSONObject c = new JSONObject();
+ ObjectNode c = om.createObjectNode();
c.put("task-cluster-id", String.valueOf(tc.getTaskClusterId()));
- JSONArray tasks = new JSONArray();
+ ArrayNode tasksAry = om.createArrayNode();
for (Task t : tc.getTasks()) {
- tasks.put(t.getTaskId().toString());
+ tasksAry.add(t.getTaskId().toString());
}
- c.put("tasks", tasks);
+ c.set("tasks", tasksAry);
- JSONArray prodParts = new JSONArray();
+ ArrayNode prodParts = om.createArrayNode();
for (PartitionId p : tc.getProducedPartitions()) {
- prodParts.put(p.toString());
+ prodParts.add(p.toString());
}
- c.put("produced-partitions", prodParts);
+ c.set("produced-partitions", prodParts);
- JSONArray reqdParts = new JSONArray();
+ ArrayNode reqdParts = om.createArrayNode();
for (PartitionId p : tc.getRequiredPartitions()) {
- reqdParts.put(p.toString());
+ reqdParts.add(p.toString());
}
- c.put("required-partitions", reqdParts);
+ c.set("required-partitions", reqdParts);
- JSONArray attempts = new JSONArray();
+ ArrayNode attempts = om.createArrayNode();
List<TaskClusterAttempt> tcAttempts = tc.getAttempts();
if (tcAttempts != null) {
for (TaskClusterAttempt tca : tcAttempts) {
- JSONObject attempt = new JSONObject();
+ ObjectNode attempt = om.createObjectNode();
attempt.put("attempt", tca.getAttempt());
- attempt.put("status", tca.getStatus());
+ attempt.putPOJO("status", tca.getStatus());
attempt.put("start-time", tca.getStartTime());
attempt.put("end-time", tca.getEndTime());
- JSONArray taskAttempts = new JSONArray();
+ ArrayNode taskAttempts = om.createArrayNode();
for (TaskAttempt ta : tca.getTaskAttempts().values()) {
- JSONObject taskAttempt = new JSONObject();
- taskAttempt.put("task-id", ta.getTaskAttemptId().getTaskId());
- taskAttempt.put("task-attempt-id", ta.getTaskAttemptId());
- taskAttempt.put("status", ta.getStatus());
+ ObjectNode taskAttempt = om.createObjectNode();
+ taskAttempt.putPOJO("task-id", ta.getTaskAttemptId().getTaskId());
+ taskAttempt.putPOJO("task-attempt-id", ta.getTaskAttemptId());
+ taskAttempt.putPOJO("status", ta.getStatus());
taskAttempt.put("node-id", ta.getNodeId());
taskAttempt.put("start-time", ta.getStartTime());
taskAttempt.put("end-time", ta.getEndTime());
@@ -374,26 +374,26 @@
taskAttempt.put("failure-details", exceptionWriter.toString());
}
}
- taskAttempts.put(taskAttempt);
+ taskAttempts.add(taskAttempt);
}
- attempt.put("task-attempts", taskAttempts);
+ attempt.set("task-attempts", taskAttempts);
- attempts.put(attempt);
+ attempts.add(attempt);
}
}
- c.put("attempts", attempts);
+ c.set("attempts", attempts);
- tClusters.put(c);
+ tClusters.add(c);
}
- planJSON.put("task-clusters", tClusters);
+ planJSON.set("task-clusters", tClusters);
- acJSON.put("plan", planJSON);
+ acJSON.set("plan", planJSON);
}
- aClusters.put(acJSON);
+ aClusters.add(acJSON);
}
- result.put("activity-clusters", aClusters);
+ result.set("activity-clusters", aClusters);
- result.put("profile", profile.toJSON());
+ result.set("profile", profile.toJSON());
return result;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/scheduler/JobScheduler.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/scheduler/JobScheduler.java
index ab026eb..b577ff7 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/scheduler/JobScheduler.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/scheduler/JobScheduler.java
@@ -31,9 +31,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-import org.json.JSONException;
-import org.json.JSONObject;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.comm.NetworkAddress;
import org.apache.hyracks.api.constraints.Constraint;
import org.apache.hyracks.api.constraints.expressions.LValueConstraintExpression;
@@ -80,6 +79,7 @@
private final Set<TaskCluster> inProgressTaskClusters;
+
public JobScheduler(ClusterControllerService ccs, JobRun jobRun, Collection<Constraint> constraints) {
this.ccs = ccs;
this.jobRun = jobRun;
@@ -734,15 +734,12 @@
}
}
- private JSONObject createJobLogObject(final JobRun run) {
- JSONObject jobLogObject = new JSONObject();
- try {
- ActivityClusterGraph acg = run.getActivityClusterGraph();
- jobLogObject.put("activity-cluster-graph", acg.toJSON());
- jobLogObject.put("job-run", run.toJSON());
- } catch (JSONException e) {
- throw new RuntimeException(e);
- }
+ private ObjectNode createJobLogObject(final JobRun run) {
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode jobLogObject = om.createObjectNode();
+ ActivityClusterGraph acg = run.getActivityClusterGraph();
+ jobLogObject.set("activity-cluster-graph", acg.toJSON());
+ jobLogObject.set("job-run", run.toJSON());
return jobLogObject;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/JobsRESTAPIFunction.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/JobsRESTAPIFunction.java
index bab77ca..e69884a 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/JobsRESTAPIFunction.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/JobsRESTAPIFunction.java
@@ -18,7 +18,8 @@
*/
package org.apache.hyracks.control.cc.web;
-import org.json.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.control.cc.ClusterControllerService;
@@ -35,8 +36,9 @@
}
@Override
- public JSONObject invoke(String[] arguments) throws Exception {
- JSONObject result = new JSONObject();
+ public ObjectNode invoke(String[] arguments) throws Exception {
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode result = om.createObjectNode();
switch (arguments.length) {
case 1:
if (!"".equals(arguments[0])) {
@@ -45,7 +47,7 @@
case 0: {
GetJobSummariesJSONWork gjse = new GetJobSummariesJSONWork(ccs);
ccs.getWorkQueue().scheduleAndSync(gjse);
- result.put("result", gjse.getSummaries());
+ result.set("result", gjse.getSummaries());
break;
}
@@ -55,11 +57,11 @@
if ("job-activity-graph".equalsIgnoreCase(arguments[1])) {
GetActivityClusterGraphJSONWork gjage = new GetActivityClusterGraphJSONWork(ccs, jobId);
ccs.getWorkQueue().scheduleAndSync(gjage);
- result.put("result", gjage.getJSON());
+ result.set("result", gjage.getJSON());
} else if ("job-run".equalsIgnoreCase(arguments[1])) {
GetJobRunJSONWork gjre = new GetJobRunJSONWork(ccs, jobId);
ccs.getWorkQueue().scheduleAndSync(gjre);
- result.put("result", gjre.getJSON());
+ result.set("result", gjre.getJSON());
}
break;
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/NodesRESTAPIFunction.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/NodesRESTAPIFunction.java
index 58deb55..8994895 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/NodesRESTAPIFunction.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/NodesRESTAPIFunction.java
@@ -18,7 +18,8 @@
*/
package org.apache.hyracks.control.cc.web;
-import org.json.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.control.cc.ClusterControllerService;
import org.apache.hyracks.control.cc.web.util.IJSONOutputFunction;
@@ -33,19 +34,20 @@
}
@Override
- public JSONObject invoke(String[] arguments) throws Exception {
- JSONObject result = new JSONObject();
+ public ObjectNode invoke(String[] arguments) throws Exception {
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode result = om.createObjectNode();
switch (arguments.length) {
case 1: {
if ("".equals(arguments[0])) {
GetNodeSummariesJSONWork gnse = new GetNodeSummariesJSONWork(ccs);
ccs.getWorkQueue().scheduleAndSync(gnse);
- result.put("result", gnse.getSummaries());
+ result.set("result", gnse.getSummaries());
} else {
String nodeId = arguments[0];
GetNodeDetailsJSONWork gnde = new GetNodeDetailsJSONWork(ccs, nodeId, true, true);
ccs.getWorkQueue().scheduleAndSync(gnde);
- result.put("result", gnde.getDetail());
+ result.set("result", gnde.getDetail());
}
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/StateDumpRESTAPIFunction.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/StateDumpRESTAPIFunction.java
index 000cf46..0657f59 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/StateDumpRESTAPIFunction.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/StateDumpRESTAPIFunction.java
@@ -20,7 +20,8 @@
import java.util.Map;
-import org.json.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.control.cc.ClusterControllerService;
import org.apache.hyracks.control.cc.web.util.IJSONOutputFunction;
@@ -35,13 +36,14 @@
}
@Override
- public JSONObject invoke(String[] arguments) throws Exception {
+ public ObjectNode invoke(String[] arguments) throws Exception {
GatherStateDumpsWork gsdw = new GatherStateDumpsWork(ccs);
ccs.getWorkQueue().scheduleAndSync(gsdw);
StateDumpRun sdr = gsdw.getStateDumpRun();
sdr.waitForCompletion();
- JSONObject result = new JSONObject();
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode result = om.createObjectNode();
for (Map.Entry<String, String> e : sdr.getStateDump().entrySet()) {
result.put(e.getKey(), e.getValue());
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/IJSONOutputFunction.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/IJSONOutputFunction.java
index f55bf84..ab0a581 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/IJSONOutputFunction.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/IJSONOutputFunction.java
@@ -18,8 +18,8 @@
*/
package org.apache.hyracks.control.cc.web.util;
-import org.json.JSONObject;
+import com.fasterxml.jackson.databind.node.ObjectNode;
public interface IJSONOutputFunction {
- public JSONObject invoke(String[] arguments) throws Exception;
+ public ObjectNode invoke(String[] arguments) throws Exception;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/JSONOutputRequestHandler.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/JSONOutputRequestHandler.java
index b00eeae..e736406 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/JSONOutputRequestHandler.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/JSONOutputRequestHandler.java
@@ -24,9 +24,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.AbstractHandler;
-import org.json.JSONObject;
public class JSONOutputRequestHandler extends AbstractHandler {
private final IJSONOutputFunction fn;
@@ -46,9 +47,10 @@
}
String[] parts = target.split("/");
try {
- JSONObject result = fn.invoke(parts);
+ ObjectNode result = fn.invoke(parts);
response.setContentType("application/json");
- result.write(response.getWriter());
+ ObjectMapper om = new ObjectMapper();
+ om.writer().writeValue(response.getWriter(),result);
baseRequest.setHandled(true);
} catch (Exception e) {
e.printStackTrace();
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/JSONUtils.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/JSONUtils.java
deleted file mode 100644
index 5da4d9d..0000000
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/web/util/JSONUtils.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.hyracks.control.cc.web.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class JSONUtils {
- public static List<JSONObject> toList(JSONArray array) throws JSONException {
- List<JSONObject> list = new ArrayList<JSONObject>();
- for (int i = 0; i < array.length(); ++i) {
- list.add((JSONObject) array.get(i));
- }
- return list;
- }
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetActivityClusterGraphJSONWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetActivityClusterGraphJSONWork.java
index 951e67e..294ae97 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetActivityClusterGraphJSONWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetActivityClusterGraphJSONWork.java
@@ -18,7 +18,8 @@
*/
package org.apache.hyracks.control.cc.work;
-import org.json.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.control.cc.ClusterControllerService;
@@ -28,7 +29,7 @@
public class GetActivityClusterGraphJSONWork extends SynchronizableWork {
private final ClusterControllerService ccs;
private final JobId jobId;
- private JSONObject json;
+ private ObjectNode json;
public GetActivityClusterGraphJSONWork(ClusterControllerService ccs, JobId jobId) {
this.ccs = ccs;
@@ -37,18 +38,20 @@
@Override
protected void doRun() throws Exception {
+
+ ObjectMapper om = new ObjectMapper();
JobRun run = ccs.getActiveRunMap().get(jobId);
if (run == null) {
run = ccs.getRunMapArchive().get(jobId);
if (run == null) {
- json = new JSONObject();
+ json = om.createObjectNode();
return;
}
}
json = run.getActivityClusterGraph().toJSON();
}
- public JSONObject getJSON() {
+ public ObjectNode getJSON() {
return json;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobRunJSONWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobRunJSONWork.java
index f2119c3..aad6edf 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobRunJSONWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobRunJSONWork.java
@@ -18,7 +18,8 @@
*/
package org.apache.hyracks.control.cc.work;
-import org.json.JSONObject;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.control.cc.ClusterControllerService;
@@ -28,7 +29,7 @@
public class GetJobRunJSONWork extends SynchronizableWork {
private final ClusterControllerService ccs;
private final JobId jobId;
- private JSONObject json;
+ private ObjectNode json;
public GetJobRunJSONWork(ClusterControllerService ccs, JobId jobId) {
this.ccs = ccs;
@@ -37,18 +38,19 @@
@Override
protected void doRun() throws Exception {
+ ObjectMapper om = new ObjectMapper();
JobRun run = ccs.getActiveRunMap().get(jobId);
if (run == null) {
run = ccs.getRunMapArchive().get(jobId);
if (run == null) {
- json = new JSONObject();
+ json = om.createObjectNode();
return;
}
}
json = run.toJSON();
}
- public JSONObject getJSON() {
+ public ObjectNode getJSON() {
return json;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobSummariesJSONWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobSummariesJSONWork.java
index bc4468a..1e5a3a5 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobSummariesJSONWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetJobSummariesJSONWork.java
@@ -20,17 +20,16 @@
import java.util.Collection;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.control.cc.ClusterControllerService;
import org.apache.hyracks.control.cc.job.JobRun;
import org.apache.hyracks.control.common.work.SynchronizableWork;
public class GetJobSummariesJSONWork extends SynchronizableWork {
private final ClusterControllerService ccs;
- private JSONArray summaries;
+ private ArrayNode summaries;
public GetJobSummariesJSONWork(ClusterControllerService ccs) {
this.ccs = ccs;
@@ -38,25 +37,27 @@
@Override
protected void doRun() throws Exception {
- summaries = new JSONArray();
+ ObjectMapper om = new ObjectMapper();
+ summaries = om.createArrayNode();
populateJSON(ccs.getActiveRunMap().values());
populateJSON(ccs.getRunMapArchive().values());
}
- private void populateJSON(Collection<JobRun> jobRuns) throws JSONException {
+ private void populateJSON(Collection<JobRun> jobRuns) {
+ ObjectMapper om = new ObjectMapper();
for (JobRun run : jobRuns) {
- JSONObject jo = new JSONObject();
+ ObjectNode jo = om.createObjectNode();
jo.put("type", "job-summary");
jo.put("job-id", run.getJobId().toString());
jo.put("create-time", run.getCreateTime());
jo.put("start-time", run.getStartTime());
jo.put("end-time", run.getEndTime());
jo.put("status", run.getStatus().toString());
- summaries.put(jo);
+ summaries.add(jo);
}
}
- public JSONArray getSummaries() {
+ public ArrayNode getSummaries() {
return summaries;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeDetailsJSONWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeDetailsJSONWork.java
index dab41ba..4a8dd1f 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeDetailsJSONWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeDetailsJSONWork.java
@@ -35,13 +35,13 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.control.cc.ClusterControllerService;
import org.apache.hyracks.control.cc.NodeControllerState;
import org.apache.hyracks.control.common.utils.PidHelper;
import org.apache.hyracks.control.common.work.IPCResponder;
import org.apache.hyracks.control.common.work.SynchronizableWork;
-import org.json.JSONException;
-import org.json.JSONObject;
import org.kohsuke.args4j.Option;
public class GetNodeDetailsJSONWork extends SynchronizableWork {
@@ -51,7 +51,8 @@
private final boolean includeStats;
private final boolean includeConfig;
private final IPCResponder<String> callback;
- private JSONObject detail;
+ private ObjectNode detail;
+ private ObjectMapper om = new ObjectMapper();
public GetNodeDetailsJSONWork(ClusterControllerService ccs, String nodeId, boolean includeStats,
boolean includeConfig, IPCResponder<String> callback) {
@@ -86,12 +87,12 @@
}
if (callback != null) {
- callback.setValue(detail == null ? null : detail.toString());
+ callback.setValue(detail == null ? null : om.writeValueAsString(detail));
}
}
- private JSONObject getCCDetails() throws JSONException {
- JSONObject o = new JSONObject();
+ private ObjectNode getCCDetails() {
+ ObjectNode o = om.createObjectNode();
MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
List<GarbageCollectorMXBean> gcMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
ThreadMXBean threadMXBean = ManagementFactory.getThreadMXBean();
@@ -106,29 +107,29 @@
o.put("vm_name", runtimeMXBean.getVmName());
o.put("vm_version", runtimeMXBean.getVmVersion());
o.put("vm_vendor", runtimeMXBean.getVmVendor());
- o.put("classpath", runtimeMXBean.getClassPath().split(File.pathSeparator));
- o.put("library_path", runtimeMXBean.getLibraryPath().split(File.pathSeparator));
- o.put("boot_classpath", runtimeMXBean.getBootClassPath().split(File.pathSeparator));
- o.put("input_arguments", runtimeMXBean.getInputArguments());
- o.put("system_properties", runtimeMXBean.getSystemProperties());
+ o.putPOJO("classpath", runtimeMXBean.getClassPath().split(File.pathSeparator));
+ o.putPOJO("library_path", runtimeMXBean.getLibraryPath().split(File.pathSeparator));
+ o.putPOJO("boot_classpath", runtimeMXBean.getBootClassPath().split(File.pathSeparator));
+ o.putPOJO("input_arguments", runtimeMXBean.getInputArguments());
+ o.putPOJO("system_properties", runtimeMXBean.getSystemProperties());
o.put("pid", PidHelper.getPid());
}
if (includeStats) {
MemoryUsage heapUsage = memoryMXBean.getHeapMemoryUsage();
MemoryUsage nonheapUsage = memoryMXBean.getNonHeapMemoryUsage();
- List<JSONObject> gcs = new ArrayList<>();
+ List<ObjectNode> gcs = new ArrayList<>();
for (GarbageCollectorMXBean gcMXBean : gcMXBeans) {
- JSONObject gc = new JSONObject();
+ ObjectNode gc = om.createObjectNode();
gc.put("name", gcMXBean.getName());
gc.put("collection-time", gcMXBean.getCollectionTime());
gc.put("collection-count", gcMXBean.getCollectionCount());
gcs.add(gc);
}
- o.put("gcs", gcs);
+ o.putPOJO("gcs", gcs);
- o.put("date", new Date());
+ o.put("date", new Date().toString());
o.put("heap_init_size", heapUsage.getInit());
o.put("heap_used_size", heapUsage.getUsed());
o.put("heap_committed_size", heapUsage.getCommitted());
@@ -145,7 +146,7 @@
return o;
}
- private static void addIni(JSONObject o, Object configBean) throws JSONException {
+ private static void addIni(ObjectNode o, Object configBean) {
Map<String, Object> iniMap = new HashMap<>();
for (Field f : configBean.getClass().getFields()) {
Option option = f.getAnnotation(Option.class);
@@ -170,10 +171,10 @@
}
}
}
- o.put("ini", iniMap);
+ o.putPOJO("ini", iniMap);
}
- public JSONObject getDetail() {
+ public ObjectNode getDetail() {
return detail;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeSummariesJSONWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeSummariesJSONWork.java
index 4b81ad0..ebafd7d 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeSummariesJSONWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/GetNodeSummariesJSONWork.java
@@ -18,7 +18,8 @@
*/
package org.apache.hyracks.control.cc.work;
-import org.json.JSONArray;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import org.apache.hyracks.control.cc.ClusterControllerService;
import org.apache.hyracks.control.cc.NodeControllerState;
@@ -26,7 +27,7 @@
public class GetNodeSummariesJSONWork extends SynchronizableWork {
private final ClusterControllerService ccs;
- private JSONArray summaries;
+ private ArrayNode summaries;
public GetNodeSummariesJSONWork(ClusterControllerService ccs) {
this.ccs = ccs;
@@ -34,13 +35,14 @@
@Override
protected void doRun() throws Exception {
- summaries = new JSONArray();
+ ObjectMapper om = new ObjectMapper();
+ summaries = om.createArrayNode();
for (NodeControllerState ncs : ccs.getNodeMap().values()) {
- summaries.put(ncs.toSummaryJSON());
+ summaries.add(ncs.toSummaryJSON());
}
}
- public JSONArray getSummaries() {
+ public ArrayNode getSummaries() {
return summaries;
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobCleanupWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobCleanupWork.java
index bd85463..2a383b6 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobCleanupWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobCleanupWork.java
@@ -23,9 +23,8 @@
import java.util.Set;
import java.util.logging.Logger;
-import org.json.JSONException;
-import org.json.JSONObject;
-
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.hyracks.api.exceptions.HyracksException;
import org.apache.hyracks.api.job.ActivityClusterGraph;
import org.apache.hyracks.api.job.JobId;
@@ -123,15 +122,12 @@
}
}
- private JSONObject createJobLogObject(final JobRun run) {
- JSONObject jobLogObject = new JSONObject();
- try {
- ActivityClusterGraph acg = run.getActivityClusterGraph();
- jobLogObject.put("activity-cluster-graph", acg.toJSON());
- jobLogObject.put("job-run", run.toJSON());
- } catch (JSONException e) {
- throw new RuntimeException(e);
- }
+ private ObjectNode createJobLogObject(final JobRun run) {
+ ObjectMapper om = new ObjectMapper();
+ ObjectNode jobLogObject = om.createObjectNode();
+ ActivityClusterGraph acg = run.getActivityClusterGraph();
+ jobLogObject.set("activity-cluster-graph", acg.toJSON());
+ jobLogObject.set("job-run", run.toJSON());
return jobLogObject;
}