Search in sources :

Example 1 with InMemoryAcceptorInstanceStore

use of org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore in project neo4j by neo4j.

the class ClusterInstance method newCopy.

public ClusterInstance newCopy() {
    // A very invasive method of cloning a protocol server. Nonetheless, since this is mostly an experiment at this
    // point, it seems we can refactor later on to have a cleaner clone mechanism.
    // Because state machines share state, and are simultaneously conceptually unaware of each other, implementing
    // a clean snapshot mechanism is very hard. I've opted for having a dirty one here in the test code rather
    // than introducing a hack into the runtime code.
    ProverTimeouts timeoutsSnapshot = timeouts.snapshot();
    InMemoryAcceptorInstanceStore snapshotAcceptorInstances = acceptorInstanceStore.snapshot();
    ClusterInstanceOutput output = new ClusterInstanceOutput(uri);
    ClusterInstanceInput input = new ClusterInstanceInput();
    DelayedDirectExecutor executor = new DelayedDirectExecutor(logging);
    ObjectStreamFactory objectStreamFactory = new ObjectStreamFactory();
    MultiPaxosContext snapshotCtx = ctx.snapshot(logging, timeoutsSnapshot, executor, snapshotAcceptorInstances, objectStreamFactory, objectStreamFactory, new DefaultElectionCredentialsProvider(server.getServerId(), new StateVerifierLastTxIdGetter(), new MemberInfoProvider()));
    List<StateMachine> snapshotMachines = new ArrayList<>();
    for (StateMachine stateMachine : server.getStateMachines().getStateMachines()) {
        snapshotMachines.add(snapshotStateMachine(logging, snapshotCtx, stateMachine));
    }
    ProtocolServer snapshotProtocolServer = factory.constructSupportingInfrastructureFor(server.getServerId(), input, output, executor, timeoutsSnapshot, stateMachineExecutor, snapshotCtx, snapshotMachines.toArray(new StateMachine[snapshotMachines.size()]));
    return new ClusterInstance(stateMachineExecutor, logging, factory, snapshotProtocolServer, snapshotCtx, snapshotAcceptorInstances, timeoutsSnapshot, input, output, uri);
}
Also used : StateMachine(org.neo4j.cluster.statemachine.StateMachine) ArrayList(java.util.ArrayList) HighAvailabilityMemberInfoProvider(org.neo4j.kernel.ha.HighAvailabilityMemberInfoProvider) DelayedDirectExecutor(org.neo4j.cluster.DelayedDirectExecutor) DefaultElectionCredentialsProvider(org.neo4j.kernel.ha.cluster.DefaultElectionCredentialsProvider) ObjectStreamFactory(org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory) ProtocolServer(org.neo4j.cluster.ProtocolServer) MultiPaxosContext(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext) InMemoryAcceptorInstanceStore(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore)

Example 2 with InMemoryAcceptorInstanceStore

use of org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore in project neo4j by neo4j.

the class NetworkMock method newTestProtocolServer.

protected TestProtocolServer newTestProtocolServer(int serverId, URI serverUri) {
    ProtocolServerFactory protocolServerFactory = new MultiPaxosServerFactory(new ClusterConfiguration("default", logService.getInternalLogProvider()), logService.getInternalLogProvider(), monitors.newMonitor(StateMachines.Monitor.class));
    ServerIdElectionCredentialsProvider electionCredentialsProvider = new ServerIdElectionCredentialsProvider();
    electionCredentialsProvider.listeningAt(serverUri);
    TestProtocolServer protocolServer = new TestProtocolServer(logService.getInternalLogProvider(), timeoutStrategy, protocolServerFactory, serverUri, new InstanceId(serverId), new InMemoryAcceptorInstanceStore(), electionCredentialsProvider);
    protocolServer.addStateTransitionListener(new StateTransitionLogger(logService.getInternalLogProvider(), new AtomicBroadcastSerializer(new ObjectStreamFactory(), new ObjectStreamFactory())));
    return protocolServer;
}
Also used : AtomicBroadcastSerializer(org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcastSerializer) StateTransitionLogger(org.neo4j.cluster.statemachine.StateTransitionLogger) ServerIdElectionCredentialsProvider(org.neo4j.cluster.protocol.election.ServerIdElectionCredentialsProvider) ClusterConfiguration(org.neo4j.cluster.protocol.cluster.ClusterConfiguration) InMemoryAcceptorInstanceStore(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore) ObjectStreamFactory(org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory)

Example 3 with InMemoryAcceptorInstanceStore

use of org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore in project neo4j by neo4j.

the class ClusterInstance method newClusterInstance.

public static ClusterInstance newClusterInstance(InstanceId id, URI uri, Monitors monitors, ClusterConfiguration configuration, int maxSurvivableFailedMembers, LogProvider logging) {
    MultiPaxosServerFactory factory = new MultiPaxosServerFactory(configuration, logging, monitors.newMonitor(StateMachines.Monitor.class));
    ClusterInstanceInput input = new ClusterInstanceInput();
    ClusterInstanceOutput output = new ClusterInstanceOutput(uri);
    ObjectStreamFactory objStreamFactory = new ObjectStreamFactory();
    ProverTimeouts timeouts = new ProverTimeouts(uri);
    InMemoryAcceptorInstanceStore acceptorInstances = new InMemoryAcceptorInstanceStore();
    Config config = mock(Config.class);
    when(config.get(ClusterSettings.max_acceptors)).thenReturn(maxSurvivableFailedMembers);
    DelayedDirectExecutor executor = new DelayedDirectExecutor(logging);
    final MultiPaxosContext context = new MultiPaxosContext(id, Iterables.<ElectionRole, ElectionRole>iterable(new ElectionRole(ClusterConfiguration.COORDINATOR)), new ClusterConfiguration(configuration.getName(), logging, configuration.getMemberURIs()), executor, logging, objStreamFactory, objStreamFactory, acceptorInstances, timeouts, new DefaultElectionCredentialsProvider(id, new StateVerifierLastTxIdGetter(), new MemberInfoProvider()), config);
    context.getClusterContext().setBoundAt(uri);
    SnapshotContext snapshotContext = new SnapshotContext(context.getClusterContext(), context.getLearnerContext());
    DelayedDirectExecutor taskExecutor = new DelayedDirectExecutor(logging);
    ProtocolServer ps = factory.newProtocolServer(id, input, output, DIRECT_EXECUTOR, taskExecutor, timeouts, context, snapshotContext);
    return new ClusterInstance(DIRECT_EXECUTOR, logging, factory, ps, context, acceptorInstances, timeouts, input, output, uri);
}
Also used : Config(org.neo4j.kernel.configuration.Config) HighAvailabilityMemberInfoProvider(org.neo4j.kernel.ha.HighAvailabilityMemberInfoProvider) DelayedDirectExecutor(org.neo4j.cluster.DelayedDirectExecutor) ClusterConfiguration(org.neo4j.cluster.protocol.cluster.ClusterConfiguration) DefaultElectionCredentialsProvider(org.neo4j.kernel.ha.cluster.DefaultElectionCredentialsProvider) ElectionRole(org.neo4j.cluster.protocol.election.ElectionRole) ObjectStreamFactory(org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory) SnapshotContext(org.neo4j.cluster.protocol.snapshot.SnapshotContext) ProtocolServer(org.neo4j.cluster.ProtocolServer) MultiPaxosContext(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext) MultiPaxosServerFactory(org.neo4j.cluster.MultiPaxosServerFactory) InMemoryAcceptorInstanceStore(org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore)

Aggregations

ObjectStreamFactory (org.neo4j.cluster.protocol.atomicbroadcast.ObjectStreamFactory)3 InMemoryAcceptorInstanceStore (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.InMemoryAcceptorInstanceStore)3 DelayedDirectExecutor (org.neo4j.cluster.DelayedDirectExecutor)2 ProtocolServer (org.neo4j.cluster.ProtocolServer)2 MultiPaxosContext (org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext)2 ClusterConfiguration (org.neo4j.cluster.protocol.cluster.ClusterConfiguration)2 HighAvailabilityMemberInfoProvider (org.neo4j.kernel.ha.HighAvailabilityMemberInfoProvider)2 DefaultElectionCredentialsProvider (org.neo4j.kernel.ha.cluster.DefaultElectionCredentialsProvider)2 ArrayList (java.util.ArrayList)1 MultiPaxosServerFactory (org.neo4j.cluster.MultiPaxosServerFactory)1 AtomicBroadcastSerializer (org.neo4j.cluster.protocol.atomicbroadcast.AtomicBroadcastSerializer)1 ElectionRole (org.neo4j.cluster.protocol.election.ElectionRole)1 ServerIdElectionCredentialsProvider (org.neo4j.cluster.protocol.election.ServerIdElectionCredentialsProvider)1 SnapshotContext (org.neo4j.cluster.protocol.snapshot.SnapshotContext)1 StateMachine (org.neo4j.cluster.statemachine.StateMachine)1 StateTransitionLogger (org.neo4j.cluster.statemachine.StateTransitionLogger)1 Config (org.neo4j.kernel.configuration.Config)1