@Override public List statisticByTop(final String resourceId, final DateSeries dateSeries, TopFilter top) { Cache<DateSeries, Map<TopFilter, List>> cache = topCache.getIfPresent(resourceId); if (cache == null) { cache = CacheBuilder.newBuilder().maximumSize(1024).expireAfterWrite(1, TimeUnit.DAYS).build(); topCache.put(resourceId, cache); } if (dateSeries != DateSeries.today) { try { Map<TopFilter, List> map = cache.get( dateSeries, new Callable<Map<TopFilter, List>>() { @Override public Map<TopFilter, List> call() throws Exception { Map<TopFilter, List> map = newHashMap(); for (TopFilter t : TopFilter.values()) { map.put(t, statisticTopReport.statisticByTop(resourceId, dateSeries, t)); } return map; } }); return map.get(top); } catch (ExecutionException e) { throw new RuntimeException(e); } } // today data is dynamic,so don't do cache else { return statisticTopReport.statisticByTop(resourceId, dateSeries, top); } }
@Override public Attribute getAttribute() { return statisticTopReport.getAttribute(); }
@Override public ReportAttribute reportAttribute() { return statisticTopReport.reportAttribute(); }