use of io.atomix.primitive.session.SessionClient in project atomix by atomix.
the class PrimaryBackupTest method testSubmitQuery.
/**
* Tests submitting a query with a configured consistency level.
*/
private void testSubmitQuery(int nodes, int backups, Replication replication) throws Throwable {
createServers(nodes);
PrimaryBackupClient client = createClient();
SessionClient session = createProxy(client, backups, replication);
session.execute(operation(READ)).thenRun(this::resume);
await(5000);
}
use of io.atomix.primitive.session.SessionClient in project atomix by atomix.
the class PrimaryBackupTest method testSubmitCommand.
/**
* Tests submitting a command to a partial cluster.
*/
private void testSubmitCommand(int nodes, int backups, Replication replication) throws Throwable {
createServers(nodes);
PrimaryBackupClient client = createClient();
SessionClient session = createProxy(client, backups, replication);
session.execute(operation(WRITE)).thenRun(this::resume);
await(5000);
}
use of io.atomix.primitive.session.SessionClient in project atomix by atomix.
the class PrimaryBackupTest method testSessionClose.
/**
* Tests a session closing.
*/
private void testSessionClose(Replication replication) throws Throwable {
createServers(3);
PrimaryBackupClient client1 = createClient();
SessionClient session1 = createProxy(client1, 2, replication);
PrimaryBackupClient client2 = createClient();
session1.execute(operation(CLOSE)).thenRun(this::resume);
await(Duration.ofSeconds(10).toMillis(), 1);
session1.addEventListener(CLOSE_EVENT, e -> resume());
SessionClient session2 = createProxy(client2, 2, replication);
session2.execute(operation(READ)).thenRun(this::resume);
await(5000);
session2.close().thenRun(this::resume);
await(Duration.ofSeconds(10).toMillis(), 2);
}
use of io.atomix.primitive.session.SessionClient in project atomix by atomix.
the class RaftTest method createPrimitive.
/**
* Creates a new primitive instance.
*/
private TestPrimitive createPrimitive(RaftClient client, ReadConsistency consistency) throws Exception {
SessionClient partition = createSession(client, consistency);
ProxyClient<TestPrimitiveService> proxy = new DefaultProxyClient<>("test", TestPrimitiveType.INSTANCE, MultiRaftProtocol.builder().build(), TestPrimitiveService.class, Collections.singletonList(partition), (key, partitions) -> partitions.get(0));
PrimitiveRegistry registry = mock(PrimitiveRegistry.class);
when(registry.createPrimitive(any(String.class), any(PrimitiveType.class))).thenReturn(CompletableFuture.completedFuture(new PrimitiveInfo("raft-test", TestPrimitiveType.INSTANCE)));
when(registry.deletePrimitive(any(String.class))).thenReturn(CompletableFuture.completedFuture(null));
return new TestPrimitiveImpl(proxy, registry);
}
Aggregations