use of org.json_voltpatches.JSONObject in project voltdb by VoltDB.
the class HTTPBenchmark method responseFromJSON.
public static Response responseFromJSON(String jsonStr) throws JSONException, IOException {
Response response = new Response();
JSONObject jsonObj = new JSONObject(jsonStr);
JSONArray resultsJson = jsonObj.getJSONArray("results");
response.results = new VoltTable[resultsJson.length()];
for (int i = 0; i < response.results.length; i++) {
JSONObject tableJson = resultsJson.getJSONObject(i);
response.results[i] = VoltTable.fromJSONObject(tableJson);
System.out.println(response.results[i].toString());
}
if (jsonObj.isNull("status") == false) {
response.status = (byte) jsonObj.getInt("status");
}
if (jsonObj.isNull("appstatus") == false) {
response.appStatus = (byte) jsonObj.getInt("appstatus");
}
if (jsonObj.isNull("statusstring") == false) {
response.statusString = jsonObj.getString("statusstring");
}
if (jsonObj.isNull("appstatusstring") == false) {
response.appStatusString = jsonObj.getString("appstatusstring");
}
if (jsonObj.isNull("exception") == false) {
response.exception = jsonObj.getString("exception");
}
return response;
}
use of org.json_voltpatches.JSONObject in project voltdb by VoltDB.
the class TestCollector method getWorkingDir.
private String getWorkingDir(String voltDbRootPath) throws Exception {
File configLogDir = new File(voltDbRootPath, Constants.CONFIG_DIR);
File configInfo = new File(configLogDir, "config.json");
JSONObject jsonObject = Collector.parseJSONFile(configInfo.getCanonicalPath());
String workingDir = jsonObject.getString("workingDir");
return workingDir;
}
use of org.json_voltpatches.JSONObject in project voltdb by VoltDB.
the class TestCollector method getLogPaths.
private List<String> getLogPaths(String voltDbRootPath) throws Exception {
File configLogDir = new File(voltDbRootPath, Constants.CONFIG_DIR);
File configInfo = new File(configLogDir, "config.json");
JSONObject jsonObject = Collector.parseJSONFile(configInfo.getCanonicalPath());
List<String> logPaths = new ArrayList<String>();
JSONArray jsonArray = jsonObject.getJSONArray("log4jDst");
for (int i = 0; i < jsonArray.length(); i++) {
String path = jsonArray.getJSONObject(i).getString("path");
logPaths.add(path);
}
return logPaths;
}
use of org.json_voltpatches.JSONObject in project voltdb by VoltDB.
the class TestSpSchedulerSpHandle method createObjs.
public void createObjs() throws JSONException {
mbox = mock(Mailbox.class);
when(mbox.getHSId()).thenReturn(dut_hsid);
iv2masters = mock(MapCache.class);
snapMonitor = mock(SnapshotCompletionMonitor.class);
// make fake MapCache of iv2masters
HashMap<String, JSONObject> fakecache = new HashMap<String, JSONObject>();
fakecache.put("0", new JSONObject("{hsid:0}"));
when(iv2masters.pointInTimeCache()).thenReturn(ImmutableMap.copyOf(fakecache));
final CommandLog cl = mock(CommandLog.class);
doReturn(CoreUtils.COMPLETED_FUTURE).when(cl).log(any(Iv2InitiateTaskMessage.class), anyLong(), any(int[].class), any(CommandLog.DurabilityListener.class), any(TransactionTask.class));
dut = new SpScheduler(0, getSiteTaskerQueue(), snapMonitor);
dut.setMailbox(mbox);
dut.setCommandLog(cl);
dut.setLock(mbox);
}
use of org.json_voltpatches.JSONObject in project voltdb by VoltDB.
the class TestSpSchedulerDedupe method createObjs.
public void createObjs() throws JSONException {
mbox = mock(Mailbox.class);
when(mbox.getHSId()).thenReturn(dut_hsid);
iv2masters = mock(MapCache.class);
snapMonitor = mock(SnapshotCompletionMonitor.class);
// make fake MapCache of iv2masters
HashMap<String, JSONObject> fakecache = new HashMap<String, JSONObject>();
fakecache.put("0", new JSONObject("{hsid:0}"));
when(iv2masters.pointInTimeCache()).thenReturn(ImmutableMap.copyOf(fakecache));
final CommandLog cl = mock(CommandLog.class);
doReturn(CoreUtils.COMPLETED_FUTURE).when(cl).log(any(Iv2InitiateTaskMessage.class), anyLong(), any(int[].class), any(CommandLog.DurabilityListener.class), any(TransactionTask.class));
dut = new SpScheduler(0, getSiteTaskerQueue(), snapMonitor);
dut.setMailbox(mbox);
dut.setCommandLog(cl);
dut.setLock(mbox);
((SpScheduler) dut).setConsistentReadLevelForTestOnly(m_readLevel);
}
Aggregations