@Test public void onlyMaxHostsCollected() { Map<String, Long> map = ImmutableMap.of("a", 8L, "b", 3L, "c", 1L, "d", 3L); Map<String, Long> actual = logger.getTopElements(map); Map<String, Long> expected = ImmutableMap.of("a", 8L, "b", 3L, "d", 3L); assertEquals(expected, actual); }
protected Map<String, Long> getTopElements(Map<String, Long> countMap) { MinMaxPriorityQueue<Map.Entry<String, Long>> topQueue = MinMaxPriorityQueue .orderedBy(Comparator.comparing((Function<Map.Entry<String, Long>, Long>) Map.Entry::getValue).reversed()) .maximumSize(topSize) .create(countMap.entrySet()); return topQueue.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); }
IntervalRegistryLogger { protected Map<String, Long> getTopElements(Map<String, Long> countMap) { MinMaxPriorityQueue<Map.Entry<String, Long>> topQueue = MinMaxPriorityQueue .orderedBy(Comparator.comparing((Function<Map.Entry<String, Long>, Long>) Map.Entry::getValue).reversed()) .maximumSize(topSize) .create(countMap.entrySet()); return topQueue.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } }
IntervalRegistryLogger { protected Map<String, Long> getTopElements(Map<String, Long> countMap) { MinMaxPriorityQueue<Map.Entry<String, Long>> topQueue = MinMaxPriorityQueue .orderedBy(Comparator.comparing((Function<Map.Entry<String, Long>, Long>) Map.Entry::getValue).reversed()) .maximumSize(topSize) .create(countMap.entrySet()); return topQueue.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } IntervalRegistryLogger(int topSize, long logIntervalMin, KeyBasedIntervalRegistry intervalRegistry); }
IntervalRegistryLogger { protected Map<String, Long> getTopElements(Map<String, Long> countMap) { MinMaxPriorityQueue<Map.Entry<String, Long>> topQueue = MinMaxPriorityQueue .orderedBy(Comparator.comparing((Function<Map.Entry<String, Long>, Long>) Map.Entry::getValue).reversed()) .maximumSize(topSize) .create(countMap.entrySet()); return topQueue.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } IntervalRegistryLogger(int topSize, long logIntervalMin, KeyBasedIntervalRegistry intervalRegistry); void schedule(); void stop(); void logStatistic(); }
IntervalRegistryLogger { protected Map<String, Long> getTopElements(Map<String, Long> countMap) { MinMaxPriorityQueue<Map.Entry<String, Long>> topQueue = MinMaxPriorityQueue .orderedBy(Comparator.comparing((Function<Map.Entry<String, Long>, Long>) Map.Entry::getValue).reversed()) .maximumSize(topSize) .create(countMap.entrySet()); return topQueue.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } IntervalRegistryLogger(int topSize, long logIntervalMin, KeyBasedIntervalRegistry intervalRegistry); void schedule(); void stop(); void logStatistic();  }