Пример #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private java.util.concurrent.Future<Object> replicate0(ReplicatedContent command, boolean trackResult, org.neo4j.causalclustering.identity.MemberId leader) throws ReplicationFailureException
        private Future <object> Replicate0(ReplicatedContent command, bool trackResult, MemberId leader)
        {
            _replicationMonitor.startReplication();
            try
            {
                OperationContext session = _sessionPool.acquireSession();

                DistributedOperation operation = new DistributedOperation(command, session.GlobalSession(), session.LocalOperationId());
                Progress             progress  = _progressTracker.start(operation);

                Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout progressTimeout = _progressTimeoutStrategy.newTimeout();
                int attempts = 0;
                try
                {
                    while (true)
                    {
                        attempts++;
                        if (attempts > 1)
                        {
                            _log.info("Retrying replication. Current attempt: %d Content: %s", attempts, command);
                        }
                        _replicationMonitor.replicationAttempt();
                        AssertDatabaseAvailable();
                        // blocking at least until the send has succeeded or failed before retrying
                        _outbound.send(leader, new Org.Neo4j.causalclustering.core.consensus.RaftMessages_NewEntry_Request(_me, operation), true);
                        progress.AwaitReplication(progressTimeout.Millis);
                        if (progress.Replicated)
                        {
                            break;
                        }
                        progressTimeout.Increment();
                        leader = _leaderProvider.awaitLeader();
                    }
                }
                catch (InterruptedException e)
                {
                    _progressTracker.abort(operation);
                    throw new ReplicationFailureException("Interrupted while replicating", e);
                }

                System.Action <object, Exception> cleanup = (ignored1, ignored2) => _sessionPool.releaseSession(session);

                if (trackResult)
                {
                    progress.FutureResult().whenComplete(cleanup);
                }
                else
                {
                    cleanup(null, null);
                }
                _replicationMonitor.successfulReplication();
                return(progress.FutureResult());
            }
            catch (Exception t)
            {
                _replicationMonitor.failedReplication(t);
                throw t;
            }
        }
Пример #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldGiveCurrentLeaderIfAvailable() throws InterruptedException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldGiveCurrentLeaderIfAvailable()
        {
            _leaderProvider.Leader = _memberId;
            assertEquals(_leaderProvider.currentLeader(), _memberId);
            assertEquals(_leaderProvider.awaitLeader(), _memberId);
        }