StatisticManager { public MeterStats getMeter(Type type){ return repoStats.getMeter(type.name(), getOption(type)); } StatisticManager(Whiteboard whiteboard, ScheduledExecutorService executor); void logQueryEvaluationTime(String language, String statement, long millis); MeterStats getMeter(Type type); CounterStats getStatsCounter(Type type); TimerStats getTimer(Type type); TimeSeriesMax maxQueLengthRecorder(); void dispose();  }
@Test public void defaultSetup() throws Exception { Whiteboard wb = new DefaultWhiteboard(); StatisticManager mgr = new StatisticManager(wb, executorService); MeterStats meterStats = mgr.getMeter(Type.QUERY_COUNT); meterStats.mark(5); assertNotNull(WhiteboardUtils.getServices(wb, RepositoryStatsMBean.class)); assertNotNull(WhiteboardUtils.getServices(wb, QueryStatManagerMBean.class)); }
@Test public void setupWithCustom() throws Exception { Whiteboard wb = new DefaultWhiteboard(); wb.register(StatisticsProvider.class, StatisticsProvider.NOOP, null); StatisticManager mgr = new StatisticManager(wb, executorService); MeterStats meterStats = mgr.getMeter(Type.QUERY_COUNT); meterStats.mark(5); }
@Test public void timeSeriesOnly() throws Exception{ Whiteboard wb = new DefaultWhiteboard(); final Map<String, StatsOptions> optionsPassed = Maps.newHashMap(); wb.register(StatisticsProvider.class, new DummyStatsProvider(){ @Override public MeterStats getMeter(String name, StatsOptions options) { optionsPassed.put(name, options); return super.getMeter(name, options); } }, null); StatisticManager mgr = new StatisticManager(wb, executorService); mgr.getMeter(Type.SESSION_READ_COUNTER); assertEquals(StatsOptions.TIME_SERIES_ONLY, optionsPassed.get(Type.SESSION_READ_COUNTER.name())); mgr.getMeter(Type.SESSION_WRITE_COUNTER); assertEquals(StatsOptions.DEFAULT, optionsPassed.get(Type.SESSION_WRITE_COUNTER.name())); }