Fixed profile json generator to use arrays consistently for repeating values
git-svn-id: https://hyracks.googlecode.com/svn/branches/hyracks_dev_next@798 123451ca-8445-de46-9d55-352943316053
diff --git a/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/AbstractProfile.java b/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/AbstractProfile.java
index 74d6000..b4e3619 100644
--- a/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/AbstractProfile.java
+++ b/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/AbstractProfile.java
@@ -18,6 +18,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -37,12 +38,14 @@
public abstract JSONObject toJSON() throws JSONException;
protected void populateCounters(JSONObject jo) throws JSONException {
+ JSONArray countersObj = new JSONArray();
for (Map.Entry<String, Long> e : counters.entrySet()) {
JSONObject jpe = new JSONObject();
jpe.put("name", e.getKey());
jpe.put("value", e.getValue());
- jo.accumulate("counters", jpe);
+ countersObj.put(jpe);
}
+ jo.put("counters", countersObj);
}
protected void merge(AbstractProfile profile) {
diff --git a/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/JobletProfile.java b/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/JobletProfile.java
index 5069fc3..78f885d 100644
--- a/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/JobletProfile.java
+++ b/hyracks-control-common/src/main/java/edu/uci/ics/hyracks/control/common/job/profiling/om/JobletProfile.java
@@ -17,6 +17,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
@@ -49,9 +50,11 @@
json.put("type", "joblet-profile");
json.put("node-id", nodeId.toString());
populateCounters(json);
+ JSONArray tasks = new JSONArray();
for (TaskProfile p : taskProfiles.values()) {
- json.accumulate("tasks", p.toJSON());
+ tasks.put(p.toJSON());
}
+ json.put("tasks", tasks);
return json;
}