@Override public TimeStampedCounterValue[] getAllSampleValues() { ArrayList<TimeStampedCounterValue> arr = new ArrayList<TimeStampedCounterValue>(); for (Timestamped<E> ts : rate.history()) { arr.add(new TimeStampedCounterValue(ts.getTimestamp(), ts.getSample().longValue())); } return sortAndPresent(arr); }
@Override public TimeStampedCounterValue[] getAllSampleValues() { ArrayList<TimeStampedCounterValue> arr = new ArrayList<TimeStampedCounterValue>(); for (Timestamped<Double> ts : rate.history()) { arr.add(new TimeStampedCounterValue(ts.getTimestamp(), (int) (ts.getSample().doubleValue() * ONE_HUNDRED))); } return sortAndPresent(arr); }
private void saveLocalCache(Cache cache) { cache.getStatistics().cacheHitOperation().count().history() .stream() .collect(Collectors.groupingBy( o -> DateTimeUtils.ofPattern(o.getTimestamp(), FORMATTER_FOR_GROUPING) )) .values() .stream() .map(list -> list.stream().max(Comparator.comparingLong(Timestamped::getTimestamp)).orElse(null)) .filter(Objects::nonNull) .forEach(cacheHistory -> { Map<String, Timestamped<Long>> map = this.storage.getOrDefault(cache.getName(), new HashMap<>()); map.put(DateTimeUtils.ofPattern(cacheHistory.getTimestamp(), FORMATTER_FOR_GROUPING), cacheHistory); if (map.size() > 3) { String removeKey = map.entrySet().stream().min(Comparator.comparingLong(o -> o.getValue().getTimestamp())).map(Map.Entry::getKey).orElse(""); map.remove(removeKey); } this.storage.put(cache.getName(), map); }); }
when(statisticsGateway.cacheHitOperation()).thenReturn(result); when(result.count()).thenReturn(statistic); when(statistic.history()).thenReturn( Arrays.asList( new MockTimestamped(2L, 10000L),
@Override public Map get(String name) { if (stat.active()) { return historyToMapLong(stat.history()); } return Collections.EMPTY_MAP; } };
@Override public Map get(String name) { if (stat.active()) { return historyToMapDouble(stat.history()); } return Collections.EMPTY_MAP; } };
@Override public TimeStampedCounterValue[] getAllSampleValues() { ArrayList<TimeStampedCounterValue> arr = new ArrayList<TimeStampedCounterValue>(); for (Timestamped<Double> ts : rate.history()) { arr.add(new TimeStampedCounterValue(ts.getTimestamp(), (int) (ts.getSample().doubleValue() * ONE_HUNDRED))); } return sortAndPresent(arr); }
@Override public TimeStampedCounterValue[] getAllSampleValues() { ArrayList<TimeStampedCounterValue> arr = new ArrayList<TimeStampedCounterValue>(); for (Timestamped<E> ts : rate.history()) { arr.add(new TimeStampedCounterValue(ts.getTimestamp(), ts.getSample().longValue())); } return sortAndPresent(arr); }
@Override public Map get(String name) { if (stat.active()) { return historyToMapDouble(stat.history()); } return Collections.EMPTY_MAP; } };
@Override public TimeStampedCounterValue[] getAllSampleValues() { ArrayList<TimeStampedCounterValue> arr = new ArrayList<TimeStampedCounterValue>(); for (Timestamped<Double> ts : rate.history()) { arr.add(new TimeStampedCounterValue(ts.getTimestamp(), (int) (ts.getSample().doubleValue() * ONE_HUNDRED))); } return sortAndPresent(arr); }
@Override public TimeStampedCounterValue[] getAllSampleValues() { ArrayList<TimeStampedCounterValue> arr = new ArrayList<TimeStampedCounterValue>(); for (Timestamped<E> ts : rate.history()) { arr.add(new TimeStampedCounterValue(ts.getTimestamp(), ts.getSample().longValue())); } return sortAndPresent(arr); }
@Override public Map get(String name) { if (stat.active()) { return historyToMapLong(stat.history()); } return Collections.EMPTY_MAP; } };
@Override public Map get(String name) { if (stat.active()) { return historyToMapDouble(stat.history()); } return Collections.EMPTY_MAP; } };
@Override public Map get(String name) { if (stat.active()) { return historyToMapLong(stat.history()); } return Collections.EMPTY_MAP; } };