use of io.atomix.primitive.event.Event in project atomix by atomix.
the class RaftTest method testSequentialEvent.
/**
* Tests submitting a sequential event.
*/
private void testSequentialEvent(int nodes) throws Throwable {
createServers(nodes);
AtomicLong count = new AtomicLong();
AtomicLong index = new AtomicLong();
RaftClient client = createClient();
TestPrimitive primitive = createPrimitive(client);
primitive.onEvent(event -> {
threadAssertEquals(count.incrementAndGet(), 2L);
threadAssertEquals(index.get(), event);
resume();
}).join();
primitive.sendEvent(true).thenAccept(result -> {
threadAssertNotNull(result);
threadAssertEquals(count.incrementAndGet(), 1L);
index.set(result);
resume();
});
await(30000, 2);
}
Aggregations