use of org.apache.jackrabbit.api.stats.RepositoryStatistics in project jackrabbit by apache.
the class StatisticsServlet method doGet.
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String klass = RepositoryContext.class.getName();
String name = getServletConfig().getInitParameter(klass);
if (name == null) {
name = klass;
}
RepositoryContext context = (RepositoryContext) getServletContext().getAttribute(name);
if (context != null) {
RepositoryStatistics statistics = context.getRepositoryStatistics();
response.setContentType("application/json");
Writer writer = response.getWriter();
writer.write('{');
write(writer, "read", statistics.getTimeSeries(RepositoryStatistics.Type.SESSION_READ_COUNTER));
writer.write(',');
write(writer, "write", statistics.getTimeSeries(RepositoryStatistics.Type.SESSION_WRITE_COUNTER));
writer.write(',');
write(writer, "login", statistics.getTimeSeries(RepositoryStatistics.Type.SESSION_LOGIN_COUNTER));
writer.write('}');
} else {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Jackrabbit repository internals are not available");
}
}
use of org.apache.jackrabbit.api.stats.RepositoryStatistics in project jackrabbit-oak by apache.
the class SimpleStatsTest method noopRepoStatsTest.
@Test
public void noopRepoStatsTest() throws Exception {
RepositoryStatistics stats = StatisticsProvider.NOOP.getStats();
assertNotNull(stats);
assertNotNull(stats.getTimeSeries("foo", false));
assertNotNull(stats.getTimeSeries(RepositoryStatistics.Type.QUERY_COUNT));
TimeSeries ts = stats.getTimeSeries("foo", false);
assertNotNull(ts.getValuePerHour());
assertNotNull(ts.getValuePerMinute());
assertNotNull(ts.getValuePerSecond());
assertNotNull(ts.getValuePerWeek());
assertEquals(0, ts.getMissingValue());
}
Aggregations