Exemple #1
0
        public override bool Equals(object o)
        {
            if (this == o)
            {
                return(true);
            }
            if (o == null || this.GetType() != o.GetType())
            {
                return(false);
            }

            LearnerContextImpl that = ( LearnerContextImpl )o;

            if (_lastDeliveredInstanceId != that._lastDeliveredInstanceId)
            {
                return(false);
            }
            if (_lastLearnedInstanceId != that._lastLearnedInstanceId)
            {
                return(false);
            }
            if (_heartbeatContext != null ?!_heartbeatContext.Equals(that._heartbeatContext) : that._heartbeatContext != null)
            {
                return(false);
            }
            if (_instanceStore != null ?!_instanceStore.Equals(that._instanceStore) : that._instanceStore != null)
            {
                return(false);
            }
            return(_paxosInstances != null?_paxosInstances.Equals(that._paxosInstances) : that._paxosInstances == null);
        }
Exemple #2
0
 private MultiPaxosContext(ProposerContextImpl proposerContext, AcceptorContextImpl acceptorContext, LearnerContextImpl learnerContext, HeartbeatContextImpl heartbeatContext, ElectionContextImpl electionContext, AtomicBroadcastContextImpl atomicBroadcastContext, CommonContextState commonState, PaxosInstanceStore paxosInstances, ClusterContextImpl clusterContext)
 {
     this._clusterContext         = clusterContext;
     this._proposerContext        = proposerContext;
     this._acceptorContext        = acceptorContext;
     this._learnerContext         = learnerContext;
     this._heartbeatContext       = heartbeatContext;
     this._electionContext        = electionContext;
     this._atomicBroadcastContext = atomicBroadcastContext;
     this._commonState            = commonState;
     this._paxosInstances         = paxosInstances;
 }
Exemple #3
0
        public MultiPaxosContext(InstanceId me, IEnumerable <ElectionRole> roles, ClusterConfiguration configuration, Executor executor, LogProvider logging, ObjectInputStreamFactory objectInputStreamFactory, ObjectOutputStreamFactory objectOutputStreamFactory, AcceptorInstanceStore instanceStore, Timeouts timeouts, ElectionCredentialsProvider electionCredentialsProvider, Config config)
        {
            _commonState    = new CommonContextState(configuration, config.Get(ClusterSettings.max_acceptors));
            _paxosInstances = new PaxosInstanceStore();

            _heartbeatContext       = new HeartbeatContextImpl(me, _commonState, logging, timeouts, executor);
            _learnerContext         = new LearnerContextImpl(me, _commonState, logging, timeouts, _paxosInstances, instanceStore, objectInputStreamFactory, objectOutputStreamFactory, _heartbeatContext);
            _clusterContext         = new ClusterContextImpl(me, _commonState, logging, timeouts, executor, objectOutputStreamFactory, objectInputStreamFactory, _learnerContext, _heartbeatContext, config);
            _electionContext        = new ElectionContextImpl(me, _commonState, logging, timeouts, roles, _clusterContext, _heartbeatContext, electionCredentialsProvider);
            _proposerContext        = new ProposerContextImpl(me, _commonState, logging, timeouts, _paxosInstances, _heartbeatContext);
            _acceptorContext        = new AcceptorContextImpl(me, _commonState, logging, timeouts, instanceStore);
            _atomicBroadcastContext = new AtomicBroadcastContextImpl(me, _commonState, logging, timeouts, executor, _heartbeatContext);

            _heartbeatContext.setCircularDependencies(_clusterContext, _learnerContext);
        }
Exemple #4
0
        /// <summary>
        /// Create a state snapshot. The snapshot will not duplicate services, and expects the caller to duplicate
        /// <seealso cref="AcceptorInstanceStore"/>, since that is externally provided.
        /// </summary>
        public virtual MultiPaxosContext Snapshot(LogProvider logging, Timeouts timeouts, Executor executor, AcceptorInstanceStore instanceStore, ObjectInputStreamFactory objectInputStreamFactory, ObjectOutputStreamFactory objectOutputStreamFactory, ElectionCredentialsProvider electionCredentialsProvider)
        {
            CommonContextState commonStateSnapshot    = _commonState.snapshot(logging.GetLog(typeof(ClusterConfiguration)));
            PaxosInstanceStore paxosInstancesSnapshot = _paxosInstances.snapshot();

            HeartbeatContextImpl       snapshotHeartbeatContext       = _heartbeatContext.snapshot(commonStateSnapshot, logging, timeouts, executor);
            LearnerContextImpl         snapshotLearnerContext         = _learnerContext.snapshot(commonStateSnapshot, logging, timeouts, paxosInstancesSnapshot, instanceStore, objectInputStreamFactory, objectOutputStreamFactory, snapshotHeartbeatContext);
            ClusterContextImpl         snapshotClusterContext         = _clusterContext.snapshot(commonStateSnapshot, logging, timeouts, executor, objectOutputStreamFactory, objectInputStreamFactory, snapshotLearnerContext, snapshotHeartbeatContext);
            ElectionContextImpl        snapshotElectionContext        = _electionContext.snapshot(commonStateSnapshot, logging, timeouts, snapshotClusterContext, snapshotHeartbeatContext, electionCredentialsProvider);
            ProposerContextImpl        snapshotProposerContext        = _proposerContext.snapshot(commonStateSnapshot, logging, timeouts, paxosInstancesSnapshot, _heartbeatContext);
            AcceptorContextImpl        snapshotAcceptorContext        = _acceptorContext.snapshot(commonStateSnapshot, logging, timeouts, instanceStore);
            AtomicBroadcastContextImpl snapshotAtomicBroadcastContext = _atomicBroadcastContext.snapshot(commonStateSnapshot, logging, timeouts, executor, snapshotHeartbeatContext);

            snapshotHeartbeatContext.SetCircularDependencies(snapshotClusterContext, snapshotLearnerContext);

            return(new MultiPaxosContext(snapshotProposerContext, snapshotAcceptorContext, snapshotLearnerContext, snapshotHeartbeatContext, snapshotElectionContext, snapshotAtomicBroadcastContext, commonStateSnapshot, paxosInstancesSnapshot, snapshotClusterContext));
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldOnlyLogLearnMissOnce()
        public virtual void ShouldOnlyLogLearnMissOnce()
        {
            // Given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.logging.AssertableLogProvider logProvider = new org.neo4j.logging.AssertableLogProvider();
            AssertableLogProvider logProvider = new AssertableLogProvider();
            LearnerContextImpl    ctx         = new LearnerContextImpl(new InstanceId(1), mock(typeof(CommonContextState)), logProvider, mock(typeof(Timeouts)), mock(typeof(PaxosInstanceStore)), mock(typeof(AcceptorInstanceStore)), mock(typeof(ObjectInputStreamFactory)), mock(typeof(ObjectOutputStreamFactory)), mock(typeof(HeartbeatContextImpl)));

            // When
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(2L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(2L));
            ctx.NotifyLearnMiss(new Org.Neo4j.cluster.protocol.atomicbroadcast.multipaxos.InstanceId(1L));

            // Then
            logProvider.AssertExactly(inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 1.")), inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 2.")), inLog(typeof(LearnerState)).warn(containsString("Did not have learned value for Paxos instance 1.")));
        }
Exemple #6
0
 public virtual ClusterContextImpl Snapshot(CommonContextState commonStateSnapshot, LogProvider logging, Timeouts timeouts, Executor executor, ObjectOutputStreamFactory objectOutputStreamFactory, ObjectInputStreamFactory objectInputStreamFactory, LearnerContextImpl snapshotLearnerContext, HeartbeatContextImpl snapshotHeartbeatContext)
 {
     return(new ClusterContextImpl(Me, commonStateSnapshot, logging, timeouts, _joiningInstances == null ? null : new List <>(asList(_joiningInstances)), _joinDeniedConfigurationResponseState == null ? null : _joinDeniedConfigurationResponseState.snapshot(), executor, objectOutputStreamFactory, objectInputStreamFactory, snapshotLearnerContext, snapshotHeartbeatContext, _config));
 }