use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class BalancePartitionsRequest method toJSONString.
@Override
public String toJSONString() {
JSONStringer stringer = new JSONStringer();
try {
stringer.object();
stringer.key("partitionPairs").array();
for (PartitionPair pair : partitionPairs) {
stringer.object();
stringer.keySymbolValuePair("srcPartition", pair.srcPartition);
stringer.keySymbolValuePair("destPartition", pair.destPartition);
stringer.keySymbolValuePair("rangeStart", pair.rangeStart);
stringer.keySymbolValuePair("rangeEnd", pair.rangeEnd);
stringer.endObject();
}
stringer.endArray();
stringer.endObject();
return stringer.toString();
} catch (JSONException e) {
return null;
}
}
use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class PlanNodeList method toJSONString.
@Override
public String toJSONString() {
try {
JSONStringer stringer = new JSONStringer();
stringer.object();
m_tree.toJSONString(stringer);
if (m_executeLists.size() == 1) {
stringer.key(EXECUTE_LIST_MEMBER_NAME).array();
List<AbstractPlanNode> list = m_executeLists.get(0);
for (AbstractPlanNode node : list) {
stringer.value(node.getPlanNodeId().intValue());
}
//end execution list
stringer.endArray();
} else {
stringer.key(EXECUTE_LISTS_MEMBER_NAME).array();
for (List<AbstractPlanNode> list : m_executeLists) {
stringer.object().key(EXECUTE_LIST_MEMBER_NAME).array();
for (AbstractPlanNode node : list) {
stringer.value(node.getPlanNodeId().intValue());
}
//end execution list
stringer.endArray().endObject();
}
//end execution list
stringer.endArray();
}
//end PlanNodeList
stringer.endObject();
return stringer.toString();
} catch (JSONException e) {
// Consider this the coward's way out.
return "This JSON error message is a lie";
}
}
use of org.json_voltpatches.JSONStringer in project voltdb by VoltDB.
the class PlanNodeTree method toJSONString.
@Override
public String toJSONString() {
JSONStringer stringer = new JSONStringer();
try {
stringer.object();
toJSONString(stringer);
stringer.endObject();
} catch (JSONException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return stringer.toString();
}
Aggregations