Search in sources :

Example 51 with JSONException

use of org.json_voltpatches.JSONException in project voltdb by VoltDB.

the class ExtensibleSnapshotDigestData method writeDRStateToSnapshot.

private void writeDRStateToSnapshot(JSONStringer stringer) throws IOException {
    try {
        long clusterCreateTime = VoltDB.instance().getClusterCreateTime();
        stringer.keySymbolValuePair("clusterCreateTime", clusterCreateTime);
        Iterator<Entry<Integer, TupleStreamStateInfo>> iter = m_drTupleStreamInfo.entrySet().iterator();
        if (iter.hasNext()) {
            stringer.keySymbolValuePair("drVersion", iter.next().getValue().drVersion);
        }
        writeDRTupleStreamInfoToSnapshot(stringer);
        stringer.key("drMixedClusterSizeConsumerState");
        stringer.object();
        for (Entry<Integer, JSONObject> e : m_drMixedClusterSizeConsumerState.entrySet()) {
            // Consumer partitionId
            stringer.key(e.getKey().toString());
            // Trackers from that site
            stringer.value(e.getValue());
        }
        stringer.endObject();
    } catch (JSONException e) {
        throw new IOException(e);
    }
}
Also used : Entry(java.util.Map.Entry) JSONObject(org.json_voltpatches.JSONObject) JSONException(org.json_voltpatches.JSONException) IOException(java.io.IOException)

Example 52 with JSONException

use of org.json_voltpatches.JSONException in project voltdb by VoltDB.

the class ExtensibleSnapshotDigestData method writeDRTupleStreamInfoToSnapshot.

private void writeDRTupleStreamInfoToSnapshot(JSONStringer stringer) throws IOException {
    try {
        stringer.key("drTupleStreamStateInfo");
        stringer.object();
        for (Map.Entry<Integer, TupleStreamStateInfo> e : m_drTupleStreamInfo.entrySet()) {
            stringer.key(e.getKey().toString());
            stringer.object();
            if (e.getKey() != MpInitiator.MP_INIT_PID) {
                stringer.keySymbolValuePair("sequenceNumber", e.getValue().partitionInfo.drId);
                stringer.keySymbolValuePair("spUniqueId", e.getValue().partitionInfo.spUniqueId);
                stringer.keySymbolValuePair("mpUniqueId", e.getValue().partitionInfo.mpUniqueId);
            } else {
                stringer.keySymbolValuePair("sequenceNumber", e.getValue().replicatedInfo.drId);
                stringer.keySymbolValuePair("spUniqueId", e.getValue().replicatedInfo.spUniqueId);
                stringer.keySymbolValuePair("mpUniqueId", e.getValue().replicatedInfo.mpUniqueId);
            }
            stringer.endObject();
        }
        stringer.endObject();
    } catch (JSONException e) {
        throw new IOException(e);
    }
}
Also used : JSONException(org.json_voltpatches.JSONException) IOException(java.io.IOException) Map(java.util.Map) HashMap(java.util.HashMap)

Example 53 with JSONException

use of org.json_voltpatches.JSONException in project voltdb by VoltDB.

the class ElasticHashinator method toJSONString.

/**
     * Serializes the configuration into JSON, also updates the currently cached m_configJSON.
     * @return The JSONString of the current configuration.
     */
private String toJSONString() {
    JSONStringer js = new JSONStringer();
    try {
        js.object();
        for (Map.Entry<Integer, Integer> entry : m_tokensMap.get().entrySet()) {
            js.key(entry.getKey().toString()).value(entry.getValue());
        }
        js.endObject();
    } catch (JSONException e) {
        throw new RuntimeException("Failed to serialize Hashinator Configuration to JSON.", e);
    }
    return js.toString();
}
Also used : JSONException(org.json_voltpatches.JSONException) JSONStringer(org.json_voltpatches.JSONStringer) ImmutableSortedMap(com.google_voltpatches.common.collect.ImmutableSortedMap) Map(java.util.Map) NavigableMap(java.util.NavigableMap) TreeMap(java.util.TreeMap) SortedMap(java.util.SortedMap)

Example 54 with JSONException

use of org.json_voltpatches.JSONException in project voltdb by VoltDB.

the class ConstantValueExpression method toJSONString.

@Override
public void toJSONString(JSONStringer stringer) throws JSONException {
    super.toJSONString(stringer);
    stringer.keySymbolValuePair(Members.ISNULL.name(), m_isNull);
    stringer.key(Members.VALUE.name());
    if (m_isNull) {
        stringer.value("NULL");
        return;
    }
    {
        switch(m_valueType) {
            case INVALID:
                throw new JSONException("ConstantValueExpression.toJSONString(): value_type should never be VoltType.INVALID");
            case NULL:
                stringer.value("null");
                break;
            case TINYINT:
                stringer.value(Long.valueOf(m_value));
                break;
            case SMALLINT:
                stringer.value(Long.valueOf(m_value));
                break;
            case INTEGER:
                stringer.value(Long.valueOf(m_value));
                break;
            case BIGINT:
                stringer.value(Long.valueOf(m_value));
                break;
            case FLOAT:
                stringer.value(Double.valueOf(m_value));
                break;
            case STRING:
                stringer.value(m_value);
                break;
            case VARBINARY:
                stringer.value(m_value);
                break;
            case TIMESTAMP:
                stringer.value(Long.valueOf(m_value));
                break;
            case DECIMAL:
                stringer.value(m_value);
                break;
            case BOOLEAN:
                stringer.value(Boolean.valueOf(m_value));
                break;
            default:
                throw new JSONException("ConstantValueExpression.toJSONString(): Unrecognized value_type " + m_valueType);
        }
    }
}
Also used : JSONException(org.json_voltpatches.JSONException)

Example 55 with JSONException

use of org.json_voltpatches.JSONException in project voltdb by VoltDB.

the class AbstractExpression method toJSONString.

@Override
public String toJSONString() {
    JSONStringer stringer = new JSONStringer();
    try {
        stringer.object();
        toJSONString(stringer);
        stringer.endObject();
    } catch (JSONException e) {
        e.printStackTrace();
        return null;
    }
    return stringer.toString();
}
Also used : JSONException(org.json_voltpatches.JSONException) JSONStringer(org.json_voltpatches.JSONStringer)

Aggregations

JSONException (org.json_voltpatches.JSONException)76 JSONObject (org.json_voltpatches.JSONObject)36 AbstractExpression (org.voltdb.expressions.AbstractExpression)17 IOException (java.io.IOException)14 ArrayList (java.util.ArrayList)13 ColumnRef (org.voltdb.catalog.ColumnRef)13 JSONArray (org.json_voltpatches.JSONArray)12 JSONStringer (org.json_voltpatches.JSONStringer)12 Column (org.voltdb.catalog.Column)12 KeeperException (org.apache.zookeeper_voltpatches.KeeperException)11 HashMap (java.util.HashMap)9 Map (java.util.Map)9 File (java.io.File)8 Constraint (org.voltdb.catalog.Constraint)8 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)8 HashSet (java.util.HashSet)7 Table (org.voltdb.catalog.Table)7 Index (org.voltdb.catalog.Index)6 TreeMap (java.util.TreeMap)5 ExecutionException (java.util.concurrent.ExecutionException)5