Search in sources :

Example 26 with JSONStringer

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;
    }
}
Also used : JSONException(org.json_voltpatches.JSONException) JSONStringer(org.json_voltpatches.JSONStringer)

Example 27 with JSONStringer

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";
    }
}
Also used : JSONException(org.json_voltpatches.JSONException) JSONStringer(org.json_voltpatches.JSONStringer)

Example 28 with JSONStringer

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();
}
Also used : JSONException(org.json_voltpatches.JSONException) JSONStringer(org.json_voltpatches.JSONStringer)

Aggregations

JSONStringer (org.json_voltpatches.JSONStringer)28 JSONException (org.json_voltpatches.JSONException)18 JSONObject (org.json_voltpatches.JSONObject)7 ExecutionException (java.util.concurrent.ExecutionException)6 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)6 IOException (java.io.IOException)5 Map (java.util.Map)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 SocketException (java.net.SocketException)2 ByteBuffer (java.nio.ByteBuffer)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 AbstractExpression (org.voltdb.expressions.AbstractExpression)2 SettingsException (org.voltdb.settings.SettingsException)2 ImmutableSortedMap (com.google_voltpatches.common.collect.ImmutableSortedMap)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 StringWriter (java.io.StringWriter)1 Inet4Address (java.net.Inet4Address)1 Inet6Address (java.net.Inet6Address)1