示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void persistentCallToSecondary(org.neo4j.causalclustering.messaging.CatchUpRequest request, org.neo4j.causalclustering.catchup.CatchUpResponseAdaptor<StoreCopyFinishedResponse> copyHandler, org.neo4j.causalclustering.catchup.CatchupAddressProvider addressProvider, TerminationCondition terminationCondition) throws StoreCopyFailedException
        private void PersistentCallToSecondary(CatchUpRequest request, CatchUpResponseAdaptor <StoreCopyFinishedResponse> copyHandler, CatchupAddressProvider addressProvider, TerminationCondition terminationCondition)
        {
            Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout timeout = _backOffStrategy.newTimeout();
            while (true)
            {
                try
                {
                    AdvertisedSocketAddress address = addressProvider.Secondary();
                    _log.info(format("Sending request '%s' to '%s'", request, address));
                    StoreCopyFinishedResponse response = _catchUpClient.makeBlockingRequest(address, request, copyHandler);
                    if (SuccessfulRequest(response, request))
                    {
                        break;
                    }
                }
                catch (CatchUpClientException e)
                {
                    Exception cause = e.InnerException;
                    if (cause is ConnectException)
                    {
                        _log.warn(cause.Message);
                    }
                    else
                    {
                        _log.warn(format("Request failed exceptionally '%s'.", request), e);
                    }
                }
                catch (CatchupAddressResolutionException e)
                {
                    _log.warn("Unable to resolve address for '%s'. %s", request, e.Message);
                }
                terminationCondition();
                AwaitAndIncrementTimeout(timeout);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void initChannel(io.netty.channel.socket.SocketChannel channel) throws Exception
        protected internal override void InitChannel(SocketChannel channel)
        {
            HandshakeClient handshakeClient = new HandshakeClient();

            InstallHandlers(channel, handshakeClient);

            _debugLog.info("Scheduling handshake (and timeout) local %s remote %s", channel.localAddress(), channel.remoteAddress());

            ScheduleHandshake(channel, handshakeClient, _handshakeDelay.newTimeout());
            ScheduleTimeout(channel, handshakeClient);
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void start() throws java.io.IOException, org.neo4j.causalclustering.catchup.storecopy.DatabaseShutdownException
        public override void Start()
        {
            bool syncedWithUpstream = false;

            Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout timeout = _timeoutStrategy.newTimeout();
            int attempt = 0;

            while (!syncedWithUpstream)
            {
                attempt++;
                MemberId source = null;
                try
                {
                    source = _selectionStrategy.bestUpstreamDatabase();
                    SyncStoreWithUpstream(source);
                    syncedWithUpstream = true;
                }
                catch (UpstreamDatabaseSelectionException)
                {
                    _lastIssue = IssueOf("finding upstream member", attempt);
                    _debugLog.warn(_lastIssue);
                }
                catch (StoreCopyFailedException)
                {
                    _lastIssue = IssueOf(format("copying store files from %s", source), attempt);
                    _debugLog.warn(_lastIssue);
                }
                catch (StoreIdDownloadFailedException)
                {
                    _lastIssue = IssueOf(format("getting store id from %s", source), attempt);
                    _debugLog.warn(_lastIssue);
                }
                catch (TopologyLookupException)
                {
                    _lastIssue = IssueOf(format("getting address of %s", source), attempt);
                    _debugLog.warn(_lastIssue);
                }

                try
                {
                    Thread.Sleep(timeout.Millis);
                    timeout.Increment();
                }
                catch (InterruptedException)
                {
                    Thread.interrupted();
                    _lastIssue = "Interrupted while trying to start read replica";
                    _debugLog.warn(_lastIssue);
                    break;
                }
            }

            if (!syncedWithUpstream)
            {
                _userLog.error(_lastIssue);
                throw new Exception(_lastIssue);
            }

            try
            {
                _localDatabase.start();
                _txPulling.start();
            }
            catch (Exception e)
            {
                throw new Exception(e);
            }
        }
示例#4
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;
            }
        }