@Test public void concurrency() throws InterruptedException { final int threadCount = 10; final int operationCount = 1000; final List<Thread> threads = Lists.newArrayList(); for (int i = 0; i < threadCount; i++) { threads.add(new Thread(new Runnable() { @Override public void run() { final Statistics stats = StatisticsTest.this.stats; final Pair<Request, Response> operation = StatisticsTest.this.operation; for (int j = 0; j < operationCount / threadCount; j++) { stats.update(operation); } } })); } for (final Thread t : threads) { t.start(); } for (final Thread t : threads) { t.join(); } assertAll(Operation.WRITE, 1000, 1024 * operationCount, 201, 1000); }
@Subscribe public void update(final TestState state) { checkNotNull(state); if (state == TestState.STOPPING) { this.running = false; } }
Statistics { @Subscribe public void update(final TestState state) { checkNotNull(state); if (state == TestState.STOPPING) { this.running = false; } } }
Statistics { @Subscribe public void update(final TestState state) { checkNotNull(state); if (state == TestState.STOPPING) { this.running = false; } } @Inject  Statistics(); }
Statistics { @Subscribe public void update(final TestState state) { checkNotNull(state); if (state == TestState.STOPPING) { this.running = false; } } @Inject  Statistics(); @Subscribe void update(final TestState state); @Subscribe void update(final Request request); @Subscribe void update(final Pair<Request, Response> result); void setOperation(final Operation operation); long get(final Operation operation, final Counter counter); long getStatusCode(final Operation operation, final int statusCode); Map<Integer, Long> statusCodes(final Operation operation); @Override String toString(); }
Statistics { @Subscribe public void update(final TestState state) { checkNotNull(state); if (state == TestState.STOPPING) { this.running = false; } } @Inject  Statistics(); @Subscribe void update(final TestState state); @Subscribe void update(final Request request); @Subscribe void update(final Pair<Request, Response> result); void setOperation(final Operation operation); long get(final Operation operation, final Counter counter); long getStatusCode(final Operation operation, final int statusCode); Map<Integer, Long> statusCodes(final Operation operation); @Override String toString();  }