++counter;
sw.lap();
System.out.println(" continuing after " + sw.getTotalDuration().toSimpleString());
}
if (counter % 24 == 0) {
History history = repository.getRepositoryStatistics().getHistory(ValueMetric.SESSION_COUNT,
Window.PREVIOUS_60_SECONDS);
System.out.println(history);
}
} catch (Throwable t) {
t.printStackTrace();
stop.set(true);
break;
}
}
}
});
status.start();
// wait for 65 minutes, so that the statistics have a value ...
Thread.sleep(MILLISECONDS.convert(65, MINUTES));
stop.set(true);
System.out.println();
Thread.sleep(MILLISECONDS.convert(5, SECONDS));
History history = repository.getRepositoryStatistics().getHistory(ValueMetric.SESSION_COUNT, Window.PREVIOUS_60_MINUTES);
Statistics[] stats = history.getStats();
System.out.println(history);
assertThat(stats.length, is(MetricHistory.MAX_MINUTES));
assertThat(stats[0], is(notNullValue()));
assertThat(stats[11], is(notNullValue()));
assertThat(stats[59], is(notNullValue()));
assertThat(history.getTotalDuration(TimeUnit.MINUTES), is(60L));
history = repository.getRepositoryStatistics().getHistory(ValueMetric.SESSION_COUNT, Window.PREVIOUS_60_SECONDS);
stats = history.getStats();
System.out.println(history);
assertThat(stats.length, is(MetricHistory.MAX_SECONDS));
assertThat(stats[0], is(notNullValue()));
assertThat(stats[11], is(notNullValue()));
assertThat(history.getTotalDuration(TimeUnit.SECONDS), is(60L));
history = repository.getRepositoryStatistics().getHistory(ValueMetric.SESSION_COUNT, Window.PREVIOUS_24_HOURS);
stats = history.getStats();
System.out.println(history);
assertThat(stats.length, is(not(0)));
assertThat(stats[0], is(nullValue()));
assertThat(stats[23], is(notNullValue()));
assertThat(history.getTotalDuration(TimeUnit.HOURS), is(24L));
}