MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / getRunningAndCompleteStats

Method getRunningAndCompleteStats

src/stats/QueryStats.java:398–429  ·  view source on GitHub ↗

Builds a serializable map from the running and cached query maps to be returned to a caller. @return A map for serialization

()

Source from the content-addressed store, hash-verified

396 * @return A map for serialization
397 */
398 public static Map<String, Object> getRunningAndCompleteStats() {
399 Map<String, Object> root = new TreeMap<String, Object>();
400
401 if (running_queries.isEmpty()) {
402 root.put("running", Collections.emptyList());
403 } else {
404 final List<Object> running = new ArrayList<Object>(running_queries.size());
405 root.put("running", running);
406
407 // don't need to lock the map beyond what the iterator will do implicitly
408 for (final QueryStats stats : running_queries.values()) {
409 final Map<String, Object> obj = new HashMap<String, Object>(10);
410 obj.put("query", stats.query);
411 obj.put("remote", stats.remote_address);
412 obj.put("user", stats.user);
413 obj.put("headers", stats.headers);
414 obj.put("queryStart", stats.query_start_ms);
415 obj.put("elapsed", DateTime.msFromNanoDiff(DateTime.nanoTime(),
416 stats.query_start_ns));
417 running.add(obj);
418 }
419 }
420
421 final Map<Integer, QueryStats> completed = completed_queries.asMap();
422 if (completed.isEmpty()) {
423 root.put("completed", Collections.emptyList());
424 } else {
425 root.put("completed", completed.values());
426 }
427
428 return root;
429 }
430
431 /**
432 * Fetches data about the running queries and status of queries in the cache

Callers 8

ctorMethod · 0.95
ctorDuplicateMethod · 0.95
ctorNullHeadersMethod · 0.95
markCompleteMethod · 0.95
markCompleteTimeoutMethod · 0.95
executedMethod · 0.95
executedTwiceMethod · 0.95
printQueryStatsMethod · 0.95

Calls 7

msFromNanoDiffMethod · 0.95
nanoTimeMethod · 0.95
isEmptyMethod · 0.80
putMethod · 0.80
sizeMethod · 0.65
valuesMethod · 0.65
addMethod · 0.45

Tested by 7

ctorMethod · 0.76
ctorDuplicateMethod · 0.76
ctorNullHeadersMethod · 0.76
markCompleteMethod · 0.76
markCompleteTimeoutMethod · 0.76
executedMethod · 0.76
executedTwiceMethod · 0.76