Exemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldResendAfterTimeout() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldResendAfterTimeout()
        {
            // given
            Monitors           monitors           = new Monitors();
            ReplicationMonitor replicationMonitor = mock(typeof(ReplicationMonitor));

            monitors.AddMonitorListener(replicationMonitor);
            CapturingProgressTracker capturedProgress = new CapturingProgressTracker(this);
            CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound = new CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage>();

            RaftReplicator replicator = GetReplicator(outbound, capturedProgress, monitors);

            replicator.OnLeaderSwitch(_leaderInfo);

            ReplicatedInteger content           = ReplicatedInteger.valueOf(5);
            Thread            replicatingThread = replicatingThread(replicator, content, false);

            // when
            replicatingThread.Start();
            // then
            assertEventually("send count", () => outbound.Count, greaterThan(2), DEFAULT_TIMEOUT_MS, MILLISECONDS);

            // cleanup
            capturedProgress.Last.setReplicated();
            replicatingThread.Join(DEFAULT_TIMEOUT_MS);

            verify(replicationMonitor, times(1)).startReplication();
            verify(replicationMonitor, atLeast(2)).replicationAttempt();
            verify(replicationMonitor, times(1)).successfulReplication();
            verify(replicationMonitor, never()).failedReplication(any());
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void stopReplicationOnShutdown() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void StopReplicationOnShutdown()
        {
            // given
            Monitors           monitors           = new Monitors();
            ReplicationMonitor replicationMonitor = mock(typeof(ReplicationMonitor));

            monitors.AddMonitorListener(replicationMonitor);
            CapturingProgressTracker capturedProgress = new CapturingProgressTracker(this);
            CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound = new CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage>();

            RaftReplicator replicator = GetReplicator(outbound, capturedProgress, monitors);

            replicator.OnLeaderSwitch(_leaderInfo);
            ReplicatedInteger content           = ReplicatedInteger.valueOf(5);
            ReplicatingThread replicatingThread = replicatingThread(replicator, content, true);

            // when
            replicatingThread.Start();

            _databaseAvailabilityGuard.shutdown();
            replicatingThread.Join();
            assertThat(replicatingThread.ReplicationException.InnerException, Matchers.instanceOf(typeof(UnavailableException)));

            verify(replicationMonitor, times(1)).startReplication();
            verify(replicationMonitor, atLeast(1)).replicationAttempt();
            verify(replicationMonitor, never()).successfulReplication();
            verify(replicationMonitor, times(1)).failedReplication(any());
        }
Exemplo n.º 3
0
 public RaftReplicator(LeaderLocator leaderLocator, MemberId me, Outbound <MemberId, Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound, LocalSessionPool sessionPool, ProgressTracker progressTracker, TimeoutStrategy progressTimeoutStrategy, long availabilityTimeoutMillis, AvailabilityGuard availabilityGuard, LogProvider logProvider, LocalDatabase localDatabase, Monitors monitors)
 {
     this._me                        = me;
     this._outbound                  = outbound;
     this._progressTracker           = progressTracker;
     this._sessionPool               = sessionPool;
     this._progressTimeoutStrategy   = progressTimeoutStrategy;
     this._availabilityTimeoutMillis = availabilityTimeoutMillis;
     this._availabilityGuard         = availabilityGuard;
     this._log                       = logProvider.getLog(this.GetType());
     this._localDatabase             = localDatabase;
     this._replicationMonitor        = monitors.NewMonitor(typeof(ReplicationMonitor));
     this._leaderProvider            = new LeaderProvider();
     leaderLocator.RegisterListener(this);
 }