Search in sources :

Example 16 with SessionClient

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);
}
Also used : SessionClient(io.atomix.primitive.session.SessionClient)

Example 17 with SessionClient

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);
}
Also used : SessionClient(io.atomix.primitive.session.SessionClient)

Example 18 with SessionClient

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);
}
Also used : SessionClient(io.atomix.primitive.session.SessionClient)

Example 19 with SessionClient

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);
}
Also used : DefaultProxyClient(io.atomix.primitive.proxy.impl.DefaultProxyClient) PrimitiveInfo(io.atomix.primitive.PrimitiveInfo) SessionClient(io.atomix.primitive.session.SessionClient) PrimitiveRegistry(io.atomix.primitive.PrimitiveRegistry) PrimitiveType(io.atomix.primitive.PrimitiveType)

Aggregations

SessionClient (io.atomix.primitive.session.SessionClient)19 PrimitiveType (io.atomix.primitive.PrimitiveType)3 DefaultProxyClient (io.atomix.primitive.proxy.impl.DefaultProxyClient)3 ThreadContext (io.atomix.utils.concurrent.ThreadContext)3 PartitionGroup (io.atomix.primitive.partition.PartitionGroup)2 PartitionService (io.atomix.primitive.partition.PartitionService)2 PrimitiveProtocol (io.atomix.primitive.protocol.PrimitiveProtocol)2 ProxyProtocol (io.atomix.primitive.protocol.ProxyProtocol)2 ProxyClient (io.atomix.primitive.proxy.ProxyClient)2 ServiceConfig (io.atomix.primitive.service.ServiceConfig)2 BlockingAwareSessionClient (io.atomix.primitive.session.impl.BlockingAwareSessionClient)2 RecoveringSessionClient (io.atomix.primitive.session.impl.RecoveringSessionClient)2 RetryingSessionClient (io.atomix.primitive.session.impl.RetryingSessionClient)2 ConfigurationException (io.atomix.utils.config.ConfigurationException)2 Collection (java.util.Collection)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Collectors (java.util.stream.Collectors)2 MoreObjects.toStringHelper (com.google.common.base.MoreObjects.toStringHelper)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1