public Set<String> getAllMetricNames() { Set<String> metricNames = new HashSet<>(); for (LevelCache levelCache : caches.values()) { metricNames.addAll(levelCache.getContents().keySet()); } return metricNames; }
public void loadSavedMetrics() { List<RetentionLevel> accessLevels = environment.retentions().getAllAccessLevels(); int numberOfAccessLevels = accessLevels.size(); log.info("trying to load Metrics for " + numberOfAccessLevels + " accessLevels"); List<Future<?>> futures = new ArrayList<>(); try { for (RetentionLevel rlevel : accessLevels) { futures.addAll(loadSavedMetricsToCaches(rlevel.name())); } } catch (Exception e) { loadMetricsThreadPool.shutdownNow(); try { loadMetricsThreadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS); } catch (InterruptedException e1) { log.error("Waiting for loadMetrics thread pool shutdown was interrupted", e1); } for (LevelCache cache : caches.values()) { cache.shutdown(); } throw e; } log.info("Submitted a total of {} futures to pre-load metrics", futures.size()); int logEvery = Math.max(1, futures.size() / 10); int futuresDone = 0; for (Future<?> f : futures) { try { f.get(); } catch (InterruptedException | ExecutionException e) { log.warn("Exception while waiting for load metrics threads", e); } futuresDone++; if (futuresDone % logEvery == 0) { log.info("Preloaded {} of {} metrics", futuresDone, futures.size()); } } log.info("all metrics preloaded!"); }