Esempio n. 1
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);
        }
Esempio n. 2
0
        /// <summary>
        /// Sets up the supporting infrastructure and communication hooks for our state machines. This is here to support
        /// an external requirement for assembling protocol servers given an existing set of state machines (used to prove
        /// correctness).
        /// </summary>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("rawtypes") public ProtocolServer constructSupportingInfrastructureFor(InstanceId me, org.neo4j.cluster.com.message.MessageSource input, org.neo4j.cluster.com.message.MessageSender output, DelayedDirectExecutor executor, org.neo4j.cluster.timeout.Timeouts timeouts, java.util.concurrent.Executor stateMachineExecutor, final org.neo4j.cluster.protocol.atomicbroadcast.multipaxos.context.MultiPaxosContext context, org.neo4j.cluster.statemachine.StateMachine[] machines)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public virtual ProtocolServer ConstructSupportingInfrastructureFor(InstanceId me, MessageSource input, MessageSender output, DelayedDirectExecutor executor, Timeouts timeouts, Executor stateMachineExecutor, MultiPaxosContext context, StateMachine[] machines)
        {
            StateMachines stateMachines = new StateMachines(_logging, _stateMachinesMonitor, input, output, timeouts, executor, stateMachineExecutor, me);

            foreach (StateMachine machine in machines)
            {
                stateMachines.AddStateMachine(machine);
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final ProtocolServer server = new ProtocolServer(me, stateMachines, logging);
            ProtocolServer server = new ProtocolServer(me, stateMachines, _logging);

            server.AddBindingListener(me1 => context.ClusterContext.setBoundAt(me1));

            stateMachines.AddMessageProcessor(new HeartbeatRefreshProcessor(stateMachines.Outgoing, context.ClusterContext));
            input.AddMessageProcessor(new HeartbeatIAmAliveProcessor(stateMachines.Outgoing, context.ClusterContext));

            Cluster cluster = server.NewClient(typeof(Cluster));

            cluster.AddClusterListener(new HeartbeatJoinListener(stateMachines.Outgoing));
            cluster.AddClusterListener(new HeartbeatLeftListener(context.HeartbeatContext, _logging));

            context.HeartbeatContext.addHeartbeatListener(new HeartbeatReelectionListener(server.NewClient(typeof(Election)), _logging));
            context.ClusterContext.addClusterListener(new ClusterLeaveReelectionListener(server.NewClient(typeof(Election)), _logging));

            StateMachineRules rules = (new StateMachineRules(stateMachines.Outgoing)).rule(ClusterState.start, ClusterMessage.create, ClusterState.entered, @internal(AtomicBroadcastMessage.entered), @internal(ProposerMessage.join), @internal(AcceptorMessage.join), @internal(LearnerMessage.join), @internal(HeartbeatMessage.join), @internal(ElectionMessage.created), @internal(SnapshotMessage.join)).rule(ClusterState.discovery, ClusterMessage.configurationResponse, ClusterState.joining, @internal(AcceptorMessage.join), @internal(LearnerMessage.join), @internal(AtomicBroadcastMessage.join)).rule(ClusterState.discovery, ClusterMessage.configurationResponse, ClusterState.entered, @internal(AtomicBroadcastMessage.entered), @internal(ProposerMessage.join), @internal(AcceptorMessage.join), @internal(LearnerMessage.join), @internal(HeartbeatMessage.join), @internal(ElectionMessage.join), @internal(SnapshotMessage.join)).rule(ClusterState.joining, ClusterMessage.configurationChanged, ClusterState.entered, @internal(AtomicBroadcastMessage.entered), @internal(ProposerMessage.join), @internal(AcceptorMessage.join), @internal(LearnerMessage.join), @internal(HeartbeatMessage.join), @internal(ElectionMessage.join), @internal(SnapshotMessage.join)).rule(ClusterState.joining, ClusterMessage.joinFailure, ClusterState.start, @internal(AtomicBroadcastMessage.leave), @internal(AcceptorMessage.leave), @internal(LearnerMessage.leave), @internal(ProposerMessage.leave)).rule(ClusterState.entered, ClusterMessage.leave, ClusterState.start, @internal(AtomicBroadcastMessage.leave), @internal(AcceptorMessage.leave), @internal(LearnerMessage.leave), @internal(HeartbeatMessage.leave), @internal(SnapshotMessage.leave), @internal(ElectionMessage.leave), @internal(ProposerMessage.leave)).rule(ClusterState.entered, ClusterMessage.leave, ClusterState.start, @internal(AtomicBroadcastMessage.leave), @internal(AcceptorMessage.leave), @internal(LearnerMessage.leave), @internal(HeartbeatMessage.leave), @internal(ElectionMessage.leave), @internal(SnapshotMessage.leave), @internal(ProposerMessage.leave)).rule(ClusterState.leaving, ClusterMessage.configurationChanged, ClusterState.start, @internal(AtomicBroadcastMessage.leave), @internal(AcceptorMessage.leave), @internal(LearnerMessage.leave), @internal(HeartbeatMessage.leave), @internal(ElectionMessage.leave), @internal(SnapshotMessage.leave), @internal(ProposerMessage.leave)).rule(ClusterState.leaving, ClusterMessage.leaveTimedout, ClusterState.start, @internal(AtomicBroadcastMessage.leave), @internal(AcceptorMessage.leave), @internal(LearnerMessage.leave), @internal(HeartbeatMessage.leave), @internal(ElectionMessage.leave), @internal(SnapshotMessage.leave), @internal(ProposerMessage.leave));

            stateMachines.AddStateTransitionListener(rules);

            return(server);
        }
Esempio n. 3
0
        public TestProtocolServer(LogProvider logProvider, TimeoutStrategy timeoutStrategy, ProtocolServerFactory factory, URI serverUri, InstanceId instanceId, AcceptorInstanceStore acceptorInstanceStore, ElectionCredentialsProvider electionCredentialsProvider)
        {
            this._serverUri = serverUri;
            this.Receiver   = new TestMessageSource(this);
            this.Sender     = new TestMessageSender(this);

            _stateMachineExecutor = new DelayedDirectExecutor(logProvider);

            Config config = mock(typeof(Config));

            when(config.Get(ClusterSettings.MaxAcceptors)).thenReturn(10);
            when(config.Get(ClusterSettings.StrictInitialHosts)).thenReturn(false);

            ServerConflict = factory.NewProtocolServer(instanceId, timeoutStrategy, Receiver, Sender, acceptorInstanceStore, electionCredentialsProvider, _stateMachineExecutor, new ObjectStreamFactory(), new ObjectStreamFactory(), config);

            ServerConflict.listeningAt(serverUri);
        }