use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.
the class RaftTest method testEvents.
/**
* Tests submitting sequential events to all sessions.
*/
private void testEvents(int nodes) throws Throwable {
createServers(nodes);
RaftClient client = createClient();
PrimitiveProxy session = createSession(client);
session.addEventListener(event -> {
threadAssertNotNull(event);
resume();
});
createSession(createClient()).addEventListener(event -> {
threadAssertNotNull(event);
resume();
});
createSession(createClient()).addEventListener(event -> {
threadAssertNotNull(event);
resume();
});
session.invoke(EVENT, clientSerializer::encode, false).thenRun(this::resume);
await(30000, 4);
}
use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.
the class RaftTest method testEventsAfterLeaderKill.
/**
* Tests submitting a linearizable event that publishes to all sessions.
*/
private void testEventsAfterLeaderKill(int nodes) throws Throwable {
List<RaftServer> servers = createServers(nodes);
RaftClient client = createClient();
PrimitiveProxy session = createSession(client);
session.addEventListener(event -> {
threadAssertNotNull(event);
resume();
});
for (int i = 0; i < 10; i++) {
session.invoke(EVENT, clientSerializer::encode, true).thenRun(this::resume);
await(30000, 2);
}
session.invoke(EVENT, clientSerializer::encode, true).thenRun(this::resume);
RaftServer leader = servers.stream().filter(s -> s.getRole() == RaftServer.Role.LEADER).findFirst().get();
leader.shutdown().get(10, TimeUnit.SECONDS);
await(30000);
for (int i = 0; i < 10; i++) {
session.invoke(EVENT, clientSerializer::encode, true).thenRun(this::resume);
await(30000, 2);
}
}
use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.
the class RaftTest method testSessionExpire.
/**
* Tests a session expiring.
*/
private void testSessionExpire(int nodes) throws Throwable {
createServers(nodes);
RaftClient client1 = createClient();
PrimitiveProxy session1 = createSession(client1);
RaftClient client2 = createClient();
createSession(client2);
session1.addEventListener(EXPIRE_EVENT, this::resume);
session1.invoke(EXPIRE).thenRun(this::resume);
client2.close().thenRun(this::resume);
await(Duration.ofSeconds(10).toMillis(), 3);
}
use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.
the class RaftTest method testSubmitCommand.
/**
* Tests submitting a command with a configured consistency level.
*/
private void testSubmitCommand(int nodes) throws Throwable {
createServers(nodes);
RaftClient client = createClient();
PrimitiveProxy session = createSession(client);
session.invoke(WRITE).thenRun(this::resume);
await(30000);
}
use of io.atomix.primitive.proxy.PrimitiveProxy in project atomix by atomix.
the class RaftTest method testClientKeepAlive.
/**
* Tests keeping a client session alive.
*/
@Test
public void testClientKeepAlive() throws Throwable {
createServers(3);
RaftClient client = createClient();
PrimitiveProxy session = createSession(client);
Thread.sleep(Duration.ofSeconds(10).toMillis());
threadAssertTrue(session.getState() == PrimitiveProxy.State.CONNECTED);
}
Aggregations