示例#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: 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;
            }
        }
示例#3
0
 public CoreStateDownloaderService(JobScheduler jobScheduler, CoreStateDownloader downloader, CommandApplicationProcess applicationProcess, LogProvider logProvider, Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout downloaderPauseStrategy, System.Func <DatabaseHealth> dbHealth, Monitors monitors)
 {
     this._jobScheduler       = jobScheduler;
     this._downloader         = downloader;
     this._applicationProcess = applicationProcess;
     this._log = logProvider.getLog(this.GetType());
     this._downloaderPauseStrategy = downloaderPauseStrategy;
     this._dbHealth = dbHealth;
     this._monitors = monitors;
 }
示例#4
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: private ReconnectingChannel(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.EventLoop eventLoop, org.neo4j.helpers.SocketAddress destination, final org.neo4j.logging.Log log, org.neo4j.causalclustering.helper.TimeoutStrategy connectionBackoffStrategy)
        private ReconnectingChannel(Bootstrap bootstrap, EventLoop eventLoop, SocketAddress destination, Log log, TimeoutStrategy connectionBackoffStrategy)
        {
            this._bootstrap    = bootstrap;
            this._eventLoop    = eventLoop;
            this._destination  = destination;
            this._log          = log;
            this._cappedLogger = (new CappedLogger(log)).setTimeLimit(20, TimeUnit.SECONDS, Clock.systemUTC());
            this._connectionBackoffStrategy = connectionBackoffStrategy;
            this._connectionBackoff         = connectionBackoffStrategy.NewTimeout();
        }
示例#5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void awaitAndIncrementTimeout(org.neo4j.causalclustering.helper.TimeoutStrategy_Timeout timeout) throws StoreCopyFailedException
        private void AwaitAndIncrementTimeout(Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout timeout)
        {
            try
            {
                Thread.Sleep(timeout.Millis);
                timeout.Increment();
            }
            catch (InterruptedException)
            {
                throw new StoreCopyFailedException("Thread interrupted");
            }
        }
示例#6
0
 internal PersistentSnapshotDownloader(CatchupAddressProvider addressProvider, CommandApplicationProcess applicationProcess, CoreStateDownloader downloader, Log log, Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout pauseStrategy, System.Func <DatabaseHealth> dbHealth, Monitors monitors)
 {
     this._applicationProcess = applicationProcess;
     this._addressProvider    = addressProvider;
     this._downloader         = downloader;
     this._log         = log;
     this._timeout     = pauseStrategy;
     this._dbHealth    = dbHealth;
     this._monitor     = monitors.NewMonitor(typeof(Monitor));
     this._state       = State.Initiated;
     this._keepRunning = true;
 }
示例#7
0
        private void TryConnect()
        {
            lock (this)
            {
                if (_disposed)
                {
                    return;
                }
                else if (_fChannel != null && !_fChannel.Done)
                {
                    return;
                }

                _fChannel = _bootstrap.connect(_destination.socketAddress());
                _channel  = _fChannel.channel();

                _fChannel.addListener((ChannelFuture f) =>
                {
                    if (!f.Success)
                    {
                        long millis = _connectionBackoff.Millis;
                        _cappedLogger.warn("Failed to connect to: " + _destination.socketAddress() + ". Retrying in " + millis + " ms");
                        f.channel().eventLoop().schedule(this.tryConnect, millis, MILLISECONDS);
                        _connectionBackoff.increment();
                    }
                    else
                    {
                        _log.info("Connected: " + f.channel());
                        f.channel().closeFuture().addListener(closed =>
                        {
                            _log.warn(string.Format("Lost connection to: {0} ({1})", _destination, _channel.remoteAddress()));
                            _connectionBackoff = _connectionBackoffStrategy.newTimeout();
                            f.channel().eventLoop().schedule(this.tryConnect, 0, MILLISECONDS);
                        });
                    }
                });
            }
        }
示例#8
0
 /// <summary>
 /// schedules the handshake initiation after the connection attempt
 /// </summary>
 private void ScheduleHandshake(SocketChannel ch, HandshakeClient handshakeClient, Org.Neo4j.causalclustering.helper.TimeoutStrategy_Timeout handshakeDelay)
 {
     ch.eventLoop().schedule(() =>
     {
         if (ch.Active)
         {
             InitiateHandshake(ch, handshakeClient);
         }
         else if (ch.Open)
         {
             handshakeDelay.Increment();
             ScheduleHandshake(ch, handshakeClient, handshakeDelay);
         }
         else
         {
             handshakeClient.FailIfNotDone("Channel closed");
         }
     }, handshakeDelay.Millis, MILLISECONDS);
 }
示例#9
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);
            }
        }