}
}
public JSONObject toJSONObject()
{
JSONStringer stringer = new JSONStringer();
try {
stringer.object();
stringer.key("txnId").value(txnId);
stringer.key("path").value(path);
stringer.key("nonce").value(nonce);
stringer.key("partitionCount").value(partitionCount);
stringer.key("newPartitionCount").value(newPartitionCount);
stringer.key("catalogCrc").value(catalogCrc);
stringer.key("hostId").value(hostId);
stringer.key("tables").array();
for (Entry<String, Set<Integer>> p : partitions.entrySet()) {
stringer.object();
stringer.key("name").value(p.getKey());
stringer.key("partitions").array();
for (int pid : p.getValue()) {
stringer.value(pid);
}
stringer.endArray();
stringer.endObject();
}
stringer.endArray(); // tables
stringer.key("partitionToTxnId").object();
for (Entry<Integer,Long> e : partitionToTxnId.entrySet()) {
stringer.key(e.getKey().toString()).value(e.getValue());
}
stringer.endObject(); // partitionToTxnId
stringer.key("instanceId").value(instanceId.serializeToJSONObject());
stringer.key("digestTables").array();
for (String digestTable : digestTables) {
stringer.value(digestTable);
}
stringer.endArray();
stringer.key("fileTables").array();
for (String fileTable : fileTables) {
stringer.value(fileTable);
}
stringer.endArray();
stringer.endObject();
return new JSONObject(stringer.toString());
} catch (JSONException e) {
VoltDB.crashLocalVoltDB("Invalid JSON communicate snapshot info.", true, e);
}
throw new RuntimeException("impossible.");
}