Search in sources :

Example 1 with RaftContext

use of io.atomix.protocols.raft.impl.RaftContext in project atomix by atomix.

the class RaftSessionsTest method createSession.

private RaftSession createSession(long sessionId) {
    RaftServiceContext context = mock(RaftServiceContext.class);
    when(context.serviceType()).thenReturn(new TestPrimitiveType());
    when(context.serviceName()).thenReturn("test");
    when(context.serviceId()).thenReturn(PrimitiveId.from(1));
    RaftContext server = mock(RaftContext.class);
    when(server.getProtocol()).thenReturn(mock(RaftServerProtocol.class));
    RaftServiceManager manager = mock(RaftServiceManager.class);
    when(manager.executor()).thenReturn(mock(ThreadContext.class));
    when(server.getServiceManager()).thenReturn(manager);
    return new RaftSession(SessionId.from(sessionId), NodeId.from("1"), "test", new TestPrimitiveType(), ReadConsistency.LINEARIZABLE, 100, 5000, System.currentTimeMillis(), context, server, mock(ThreadContextFactory.class));
}
Also used : RaftServerProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol) RaftContext(io.atomix.protocols.raft.impl.RaftContext) RaftSession(io.atomix.protocols.raft.session.RaftSession) RaftServiceManager(io.atomix.protocols.raft.impl.RaftServiceManager) ThreadContextFactory(io.atomix.utils.concurrent.ThreadContextFactory) ThreadContext(io.atomix.utils.concurrent.ThreadContext) TestPrimitiveType(io.atomix.protocols.raft.proxy.impl.TestPrimitiveType)

Example 2 with RaftContext

use of io.atomix.protocols.raft.impl.RaftContext in project atomix by atomix.

the class RaftSessionRegistryTest method createSession.

private RaftSession createSession(long sessionId) {
    RaftServiceContext context = mock(RaftServiceContext.class);
    when(context.serviceType()).thenReturn(new TestPrimitiveType());
    when(context.serviceName()).thenReturn("test");
    when(context.serviceId()).thenReturn(PrimitiveId.from(1));
    RaftContext server = mock(RaftContext.class);
    when(server.getProtocol()).thenReturn(mock(RaftServerProtocol.class));
    RaftServiceManager manager = mock(RaftServiceManager.class);
    when(manager.executor()).thenReturn(mock(ThreadContext.class));
    when(server.getServiceManager()).thenReturn(manager);
    return new RaftSession(SessionId.from(sessionId), NodeId.from("1"), "test", new TestPrimitiveType(), ReadConsistency.LINEARIZABLE, 100, 5000, System.currentTimeMillis(), context, server, mock(ThreadContextFactory.class));
}
Also used : RaftServerProtocol(io.atomix.protocols.raft.protocol.RaftServerProtocol) RaftContext(io.atomix.protocols.raft.impl.RaftContext) RaftServiceManager(io.atomix.protocols.raft.impl.RaftServiceManager) ThreadContextFactory(io.atomix.utils.concurrent.ThreadContextFactory) ThreadContext(io.atomix.utils.concurrent.ThreadContext) RaftServiceContext(io.atomix.protocols.raft.service.RaftServiceContext) TestPrimitiveType(io.atomix.protocols.raft.proxy.impl.TestPrimitiveType)

Aggregations

RaftContext (io.atomix.protocols.raft.impl.RaftContext)2 RaftServiceManager (io.atomix.protocols.raft.impl.RaftServiceManager)2 RaftServerProtocol (io.atomix.protocols.raft.protocol.RaftServerProtocol)2 TestPrimitiveType (io.atomix.protocols.raft.proxy.impl.TestPrimitiveType)2 ThreadContext (io.atomix.utils.concurrent.ThreadContext)2 ThreadContextFactory (io.atomix.utils.concurrent.ThreadContextFactory)2 RaftServiceContext (io.atomix.protocols.raft.service.RaftServiceContext)1 RaftSession (io.atomix.protocols.raft.session.RaftSession)1