use of org.apache.jena.atlas.json.JsonObject in project jena by apache.
the class TestAdmin method checkJsonStatsOne.
private static void checkJsonStatsOne(JsonValue v) {
checkJsonStatsCounters(v);
JsonObject obj1 = v.getAsObject().get("endpoints").getAsObject();
for (String srvName : obj1.keys()) {
JsonObject obj2 = obj1.get(srvName).getAsObject();
assertTrue(obj2.hasKey("description"));
assertTrue(obj2.hasKey("operation"));
checkJsonStatsCounters(obj2);
}
}
use of org.apache.jena.atlas.json.JsonObject in project jena by apache.
the class TestAdmin method server_1.
// --- Server status
@Test
public void server_1() {
JsonValue jv = httpGetJson(ServerCtl.urlRoot() + "$/" + opServer);
JsonObject obj = jv.getAsObject();
// Now optional : assertTrue(obj.hasKey(JsonConst.admin)) ;
assertTrue(obj.hasKey(JsonConst.datasets));
assertTrue(obj.hasKey(JsonConst.uptime));
assertTrue(obj.hasKey(JsonConst.startDT));
}
use of org.apache.jena.atlas.json.JsonObject in project jena by apache.
the class StatsServlet method statsJSON.
private void statsJSON(HttpServletRequest req, HttpServletResponse resp) throws IOException {
ServletOutputStream out = resp.getOutputStream();
resp.setContentType(WebContent.contentTypeJSON);
resp.setCharacterEncoding(WebContent.charsetUTF8);
/*
* { "server" : ....
* "datasets" : {
* "ds1": { counters... }
* GSP stucture?
*
*/
JsonObject obj = new JsonObject();
JsonObject datasets = new JsonObject();
JsonObject server = new JsonObject();
server.put("host", req.getLocalName() + ":" + req.getLocalPort());
for (String ds : DatasetRegistry.get().keys()) statsJSON(datasets, ds);
obj.put("server", server);
obj.put("datasets", datasets);
JSON.write(out, obj);
out.flush();
}
use of org.apache.jena.atlas.json.JsonObject in project jena by apache.
the class StatsServlet method statsJSON.
private void statsJSON(JsonObject datasets, String ds) {
DatasetRef desc = DatasetRegistry.get().get(ds);
JsonObject stats = new JsonObject();
datasets.put(ds, stats);
stats.put(CounterName.Requests.name(), desc.getCounters().value(CounterName.Requests));
stats.put(CounterName.RequestsGood.name(), desc.getCounters().value(CounterName.RequestsGood));
stats.put(CounterName.RequestsBad.name(), desc.getCounters().value(CounterName.RequestsBad));
JsonObject services = new JsonObject();
// There can be several endpoints for one service.
for (ServiceRef srvRef : desc.getServiceRefs()) {
JsonObject epStats = new JsonObject();
statsJSON(epStats, srvRef);
services.put(srvRef.name, epStats);
JsonArray endpoints = new JsonArray();
epStats.put("endpoints", endpoints);
for (String ep : srvRef.endpoints) {
endpoints.add(ep);
}
}
stats.put("services", services);
}
use of org.apache.jena.atlas.json.JsonObject in project jena by apache.
the class StoreParamsCodec method encodeToJson.
public static JsonObject encodeToJson(StoreParams params) {
JsonBuilder builder = new JsonBuilder();
// "StoreParams" is an internal alignment marker - not in the JSON.
builder.startObject("StoreParams");
encode(builder, key(fFileMode), params.getFileMode().name());
encode(builder, key(fBlockSize), params.getBlockSize());
encode(builder, key(fBlockReadCacheSize), params.getBlockReadCacheSize());
encode(builder, key(fBlockWriteCacheSize), params.getBlockWriteCacheSize());
encode(builder, key(fNode2NodeIdCacheSize), params.getNode2NodeIdCacheSize());
encode(builder, key(fNodeId2NodeCacheSize), params.getNodeId2NodeCacheSize());
encode(builder, key(fNodeMissCacheSize), params.getNodeMissCacheSize());
encode(builder, key(fIndexNode2Id), params.getIndexNode2Id());
encode(builder, key(fIndexId2Node), params.getIndexId2Node());
encode(builder, key(fPrimaryIndexTriples), params.getPrimaryIndexTriples());
encode(builder, key(fTripleIndexes), params.getTripleIndexes());
encode(builder, key(fPrimaryIndexQuads), params.getPrimaryIndexQuads());
encode(builder, key(fQuadIndexes), params.getQuadIndexes());
encode(builder, key(fPrimaryIndexPrefix), params.getPrimaryIndexPrefix());
encode(builder, key(fPrefixIndexes), params.getPrefixIndexes());
encode(builder, key(fIndexPrefix), params.getIndexPrefix());
encode(builder, key(fPrefixNode2Id), params.getPrefixNode2Id());
encode(builder, key(fPrefixId2Node), params.getPrefixId2Node());
builder.finishObject("StoreParams");
return (JsonObject) builder.build();
}
Aggregations