@Test public void testBuckets() throws Exception { WindowedMapGauge<Long> gauge = new WindowedMapGauge<>("wtf", 60000L, Long::max); assertEquals(new WindowedMapGauge.Windows(0L, -60000L), gauge.getWindowStartTimes(0L)); assertEquals(new WindowedMapGauge.Windows(0L, -60000L), gauge.getWindowStartTimes(1L)); assertEquals(new WindowedMapGauge.Windows(0L, -60000L) , gauge.getWindowStartTimes(59999L)); assertEquals(new WindowedMapGauge.Windows(60000L, 0L), gauge.getWindowStartTimes(60000L)); assertEquals(new WindowedMapGauge.Windows(300000L, 240000L), gauge.getWindowStartTimes(300001L)); }
public Windows getWindowStartTimes(long tsMs) { long activeStartMs = tsMs/windowDurationMs * windowDurationMs; return new Windows(activeStartMs, activeStartMs - windowDurationMs); }
WindowedMapGauge extends Gauge<Map<String,Object>> { public Windows getWindowStartTimes(long tsMs) { long activeStartMs = tsMs/windowDurationMs * windowDurationMs; return new Windows(activeStartMs, activeStartMs - windowDurationMs); } }
WindowedMapGauge extends Gauge<Map<String,Object>> { public Windows getWindowStartTimes(long tsMs) { long activeStartMs = tsMs/windowDurationMs * windowDurationMs; return new Windows(activeStartMs, activeStartMs - windowDurationMs); } WindowedMapGauge(String name, long windowDurationMs, BiFunction<V,V,V> mergeFunc);  WindowedMapGauge(String name, long windowDurationMs, BiFunction<V,V,V> mergeFunc, Clock clock); }
WindowedMapGauge extends Gauge<Map<String,Object>> { public Windows getWindowStartTimes(long tsMs) { long activeStartMs = tsMs/windowDurationMs * windowDurationMs; return new Windows(activeStartMs, activeStartMs - windowDurationMs); } WindowedMapGauge(String name, long windowDurationMs, BiFunction<V,V,V> mergeFunc);  WindowedMapGauge(String name, long windowDurationMs, BiFunction<V,V,V> mergeFunc, Clock clock); void update(String src, V val); @Override Map<String,Object> getValue(); Map<String,V> getSnapshot(); Windows getWindowStartTimes(long tsMs); }
WindowedMapGauge extends Gauge<Map<String,Object>> { public Windows getWindowStartTimes(long tsMs) { long activeStartMs = tsMs/windowDurationMs * windowDurationMs; return new Windows(activeStartMs, activeStartMs - windowDurationMs); } WindowedMapGauge(String name, long windowDurationMs, BiFunction<V,V,V> mergeFunc);  WindowedMapGauge(String name, long windowDurationMs, BiFunction<V,V,V> mergeFunc, Clock clock); void update(String src, V val); @Override Map<String,Object> getValue(); Map<String,V> getSnapshot(); Windows getWindowStartTimes(long tsMs);  }