Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDeepClone()
        public virtual void ShouldDeepClone()
        {
            // Given
            ObjectStreamFactory   objStream                 = new ObjectStreamFactory();
            AcceptorInstanceStore acceptorInstances         = mock(typeof(AcceptorInstanceStore));
            Executor                    executor            = mock(typeof(Executor));
            Timeouts                    timeouts            = mock(typeof(Timeouts));
            ClusterConfiguration        clusterConfig       = new ClusterConfiguration("myCluster", NullLogProvider.Instance);
            ElectionCredentialsProvider electionCredentials = mock(typeof(ElectionCredentialsProvider));

            Config config = mock(typeof(Config));

            when(config.Get(ClusterSettings.max_acceptors)).thenReturn(10);

            MultiPaxosContext ctx = new MultiPaxosContext(new InstanceId(1), Collections.emptyList(), clusterConfig, executor, NullLogProvider.Instance, objStream, objStream, acceptorInstances, timeouts, electionCredentials, config);

            // When
            MultiPaxosContext snapshot = ctx.Snapshot(NullLogProvider.Instance, timeouts, executor, acceptorInstances, objStream, objStream, electionCredentials);

            // Then
            assertEquals(ctx, snapshot);
        }
Beispiel #2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
//ORIGINAL LINE: public ProtocolServer newNetworkedServer(final org.neo4j.kernel.configuration.Config config, org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.AcceptorInstanceStore acceptorInstanceStore, org.neo4j.cluster.protocol.election.ElectionCredentialsProvider electionCredentialsProvider)
        public virtual ProtocolServer NewNetworkedServer(Config config, AcceptorInstanceStore acceptorInstanceStore, ElectionCredentialsProvider electionCredentialsProvider)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.cluster.com.NetworkReceiver receiver = new org.neo4j.cluster.com.NetworkReceiver(networkReceiverMonitor, new org.neo4j.cluster.com.NetworkReceiver.Configuration()
            NetworkReceiver receiver = new NetworkReceiver(_networkReceiverMonitor, new ConfigurationAnonymousInnerClass(this, config)
                                                           , _logProvider);

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.cluster.com.NetworkSender sender = new org.neo4j.cluster.com.NetworkSender(networkSenderMonitor, new org.neo4j.cluster.com.NetworkSender.Configuration()
            NetworkSender sender = new NetworkSender(_networkSenderMonitor, new ConfigurationAnonymousInnerClass(this, config)
                                                     , receiver, _logProvider);

            ExecutorLifecycleAdapter stateMachineExecutor = new ExecutorLifecycleAdapter(() => Executors.newSingleThreadExecutor(new NamedThreadFactory("State machine", _namedThreadFactoryMonitor)));

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ProtocolServer protocolServer = protocolServerFactory.newProtocolServer(config.get(ClusterSettings.server_id), timeoutStrategy, receiver, sender, acceptorInstanceStore, electionCredentialsProvider, stateMachineExecutor, objectInputStreamFactory, objectOutputStreamFactory, config);
            ProtocolServer protocolServer = _protocolServerFactory.newProtocolServer(config.Get(ClusterSettings.ServerId), _timeoutStrategy, receiver, sender, acceptorInstanceStore, electionCredentialsProvider, stateMachineExecutor, _objectInputStreamFactory, _objectOutputStreamFactory, config);

            receiver.AddNetworkChannelsListener(new NetworkChannelsListenerAnonymousInnerClass(this, protocolServer));

            _life.add(stateMachineExecutor);

            // Timeout timer - triggers every 10 ms
            _life.add(new LifecycleAnonymousInnerClass(this, protocolServer));

            // Add this last to ensure that timeout service is setup first
            _life.add(sender);
            _life.add(receiver);

            return(protocolServer);
        }
Beispiel #3
0
        public override ProtocolServer NewProtocolServer(InstanceId me, TimeoutStrategy timeoutStrategy, MessageSource input, MessageSender output, AcceptorInstanceStore acceptorInstanceStore, ElectionCredentialsProvider electionCredentialsProvider, Executor stateMachineExecutor, ObjectInputStreamFactory objectInputStreamFactory, ObjectOutputStreamFactory objectOutputStreamFactory, Config config)
        {
            DelayedDirectExecutor executor = new DelayedDirectExecutor(_logging);

            // Create state machines
            Timeouts timeouts = new Timeouts(timeoutStrategy);

//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(me, 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(initialConfig.getName(), logging, initialConfig.getMemberURIs()), executor, logging, objectInputStreamFactory, objectOutputStreamFactory, acceptorInstanceStore, timeouts, electionCredentialsProvider, config);
            MultiPaxosContext context = new MultiPaxosContext(me, Iterables.iterable(new ElectionRole(ClusterConfiguration.COORDINATOR)), new ClusterConfiguration(_initialConfig.Name, _logging, _initialConfig.MemberURIs), executor, _logging, objectInputStreamFactory, objectOutputStreamFactory, acceptorInstanceStore, timeouts, electionCredentialsProvider, config);

            SnapshotContext snapshotContext = new SnapshotContext(context.ClusterContext, context.LearnerContext);

            return(NewProtocolServer(me, input, output, stateMachineExecutor, executor, timeouts, context, snapshotContext));
        }