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);
}
}
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);
}
}
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();
}
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);
}
}
}
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();
}
Aggregations