public virtual 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.ServerId, new StateVerifierLastTxIdGetter(), new MemberInfoProvider()) ); IList <StateMachine> snapshotMachines = new List <StateMachine>(); foreach (StateMachine stateMachine in _server.StateMachines.StateMachines) { snapshotMachines.Add(SnapshotStateMachine(_logging, snapshotCtx, stateMachine)); } ProtocolServer snapshotProtocolServer = _factory.constructSupportingInfrastructureFor(_server.ServerId, input, output, executor, timeoutsSnapshot, _stateMachineExecutor, snapshotCtx, snapshotMachines.ToArray()); return(new ClusterInstance(_stateMachineExecutor, _logging, _factory, snapshotProtocolServer, snapshotCtx, snapshotAcceptorInstances, timeoutsSnapshot, input, output, _uri)); }
public static ClusterInstance NewClusterInstance(InstanceId id, URI uri, Monitors monitors, ClusterConfiguration configuration, int maxSurvivableFailedMembers, LogProvider logging) { MultiPaxosServerFactory factory = new MultiPaxosServerFactory(configuration, logging, monitors.NewMonitor(typeof(StateMachines.Monitor))); 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(typeof(Config)); when(config.Get(ClusterSettings.max_acceptors)).thenReturn(maxSurvivableFailedMembers); DelayedDirectExecutor executor = new DelayedDirectExecutor(logging); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext context = new org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext(id, org.neo4j.helpers.collection.Iterables.iterable(new org.neo4j.cluster.protocol.election.ElectionRole(org.neo4j.cluster.protocol.cluster.ClusterConfiguration.COORDINATOR)), new org.neo4j.cluster.protocol.cluster.ClusterConfiguration(configuration.getName(), logging, configuration.getMemberURIs()), executor, logging, objStreamFactory, objStreamFactory, acceptorInstances, timeouts, new org.neo4j.kernel.ha.cluster.DefaultElectionCredentialsProvider(id, new StateVerifierLastTxIdGetter(), new MemberInfoProvider()), config); MultiPaxosContext context = new MultiPaxosContext(id, Iterables.iterable(new ElectionRole(ClusterConfiguration.COORDINATOR)), new ClusterConfiguration(configuration.Name, logging, configuration.MemberURIs), executor, logging, objStreamFactory, objStreamFactory, acceptorInstances, timeouts, new DefaultElectionCredentialsProvider(id, new StateVerifierLastTxIdGetter(), new MemberInfoProvider()), config); context.ClusterContext.BoundAt = uri; SnapshotContext snapshotContext = new SnapshotContext(context.ClusterContext, context.LearnerContext); DelayedDirectExecutor taskExecutor = new DelayedDirectExecutor(logging); ProtocolServer ps = factory.NewProtocolServer(id, input, output, DirectExecutor, taskExecutor, timeouts, context, snapshotContext); return(new ClusterInstance(DirectExecutor, logging, factory, ps, context, acceptorInstances, timeouts, input, output, uri)); }
internal ClusterInstance(Executor stateMachineExecutor, LogProvider logging, MultiPaxosServerFactory factory, ProtocolServer server, MultiPaxosContext ctx, InMemoryAcceptorInstanceStore acceptorInstanceStore, ProverTimeouts timeouts, ClusterInstanceInput input, ClusterInstanceOutput output, URI uri) { this._stateMachineExecutor = stateMachineExecutor; this._logging = logging; this._factory = factory; this._server = server; this._ctx = ctx; this._acceptorInstanceStore = acceptorInstanceStore; this._timeouts = timeouts; this._input = input; this._output = output; this._uri = uri; }