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

Method loadCachedJson

src/tsd/GraphHandler.java:643–662  ·  view source on GitHub ↗

Attempts to read the cached .json file for this query. @param query The query to serve. @param end_time The end time on the query (32-bit unsigned int, seconds). @param max_age The maximum time (in seconds) we wanna allow clients to cache the result in case of a cache hit. @param basepath Th

(final HttpQuery query,
                                       final long end_time,
                                       final long max_age,
                                       final String basepath)

Source from the content-addressed store, hash-verified

641 * @throws JsonParseException If the JSON is improperly formatted
642 */
643 @SuppressWarnings("unchecked")
644 private HashMap<String, Object> loadCachedJson(final HttpQuery query,
645 final long end_time,
646 final long max_age,
647 final String basepath)
648 throws JsonParseException,
649 JsonMappingException, IOException {
650 final String json_path = basepath + ".json";
651 File json_cache = new File(json_path);
652 if (staleCacheFile(query, end_time, max_age, json_cache)) {
653 return null;
654 }
655 final byte[] json = readFile(query, json_cache, 4096);
656 if (json == null) {
657 return null;
658 }
659 json_cache = null;
660
661 return (HashMap<String, Object>) JSON.parseToObject(json, HashMap.class);
662 }
663
664 /** Parses the {@code wxh} query parameter to set the graph dimension. */
665 static void setPlotDimensions(final HttpQuery query, final Plot plot) {

Callers 1

isDiskCacheHitMethod · 0.95

Calls 3

staleCacheFileMethod · 0.95
readFileMethod · 0.95
parseToObjectMethod · 0.95

Tested by

no test coverage detected