Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.cursor.IOCursor<org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation> getCursor(long txIdPromise, io.netty.channel.ChannelHandlerContext ctx, long firstTxId, org.neo4j.causalclustering.identity.StoreId localStoreId, org.neo4j.causalclustering.identity.StoreId expectedStoreId) throws java.io.IOException
        private IOCursor <CommittedTransactionRepresentation> GetCursor(long txIdPromise, ChannelHandlerContext ctx, long firstTxId, StoreId localStoreId, StoreId expectedStoreId)
        {
            if (localStoreId == null || !localStoreId.Equals(expectedStoreId))
            {
                _log.info("Failed to serve TxPullRequest for tx %d and storeId %s because that storeId is different " + "from this machine with %s", firstTxId, expectedStoreId, localStoreId);
                EndInteraction(ctx, E_STORE_ID_MISMATCH, txIdPromise);
                return(null);
            }
            else if (!_databaseAvailable.AsBoolean)
            {
                _log.info("Failed to serve TxPullRequest for tx %d because the local database is unavailable.", firstTxId);
                EndInteraction(ctx, E_STORE_UNAVAILABLE, txIdPromise);
                return(null);
            }
            else if (txIdPromise < firstTxId)
            {
                EndInteraction(ctx, SUCCESS_END_OF_STREAM, txIdPromise);
                return(null);
            }

            try
            {
                return(_logicalTransactionStore.getTransactions(firstTxId));
            }
            catch (NoSuchTransactionException)
            {
                _log.info("Failed to serve TxPullRequest for tx %d because the transaction does not exist.", firstTxId);
                EndInteraction(ctx, E_TRANSACTION_PRUNED, txIdPromise);
                return(null);
            }
        }
Beispiel #2
0
        public override Fallible <BackupStageOutcome> PerformFullBackup(DatabaseLayout targetDatabaseLayout, Config config, OptionalHostnamePort userProvidedAddress)
        {
            AdvertisedSocketAddress fromAddress = _addressResolver.resolveCorrectCCAddress(config, userProvidedAddress);

            _log.info("Resolved address for catchup protocol is " + fromAddress);
            StoreId storeId;

            try
            {
                storeId = _backupDelegator.fetchStoreId(fromAddress);
                _log.info("Remote store id is " + storeId);
            }
            catch (StoreIdDownloadFailedException e)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.WrongProtocol, e));
            }

            Optional <StoreId> expectedStoreId = ReadLocalStoreId(targetDatabaseLayout);

            if (expectedStoreId.Present)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, new StoreIdDownloadFailedException(format("Cannot perform a full backup onto preexisting backup. Remote store id was %s but local is %s", storeId, expectedStoreId))));
            }

            try
            {
                _backupDelegator.copy(fromAddress, storeId, targetDatabaseLayout);
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Success, null));
            }
            catch (StoreCopyFailedException e)
            {
                return(new Fallible <BackupStageOutcome>(BackupStageOutcome.Failure, e));
            }
        }
Beispiel #3
0
        public override void Print(string name)
        {
            string accessStr = _accessStatistics.AccessStatSummary;

            _logger.info(format("=== %s ===", name));
            _logger.info(format("I/Os%n%s", accessStr));
            _logger.info(_counts.ToString());
            _logger.info(MemoryStats());
            _logger.info("Done in  " + Format.duration(currentTimeMillis() - _startTime));
        }
Beispiel #4
0
 public virtual void Start()
 {
     lock (this)
     {
         _log.info("Starting log shipper: %s", StatusAsString());
         SendEmpty(_raftLog.appendIndex(), _lastLeaderContext);
     }
 }
Beispiel #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public final synchronized void enable() throws Throwable
        public override void Enable()
        {
            lock (this)
            {
                if (!_stoppedByLifeCycle)
                {
                    Start0();
                }
                else
                {
                    _debugLog.info("%s will not start. It was enabled but is stopped by lifecycle", this);
                }
                _enabled = true;
            }
        }
Beispiel #6
0
        public override void Validate()
        {
            if (_backupHelper.successfulBackups.get() == 0)
            {
                throw new System.InvalidOperationException("Failed to perform any backups");
            }

            _log.info(string.Format("Performed {0:D}/{1:D} successful backups.", _backupHelper.successfulBackups.get(), _backupHelper.backupNumber.get()));
        }
Beispiel #7
0
 public override void Dispose()
 {
     lock (this)
     {
         _log.info("Disposing channel: " + _channel);
         _disposed = true;
         _channel.close();
     }
 }
Beispiel #8
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.causalclustering.core.consensus.outcome.Outcome handle(org.neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat req) throws java.io.IOException
            public override Outcome Handle(Org.Neo4j.causalclustering.core.consensus.RaftMessages_Heartbeat req)
            {
                if (req.LeaderTerm() < Ctx.term())
                {
                    return(Outcome);
                }

                Outcome.NextRole = FOLLOWER;
                Log.info("Moving to FOLLOWER state after receiving heartbeat from %s at term %d (I am at %d)", req.From(), req.LeaderTerm(), Ctx.term());
                Heart.Beat(Ctx, Outcome, req, Log);
                return(Outcome);
            }
Beispiel #9
0
        /// <summary>
        /// Performs a switch to the master state. Starts communication endpoints, switches components to the master state
        /// and broadcasts the appropriate Master Is Available event. </summary>
        /// <param name="haCommunicationLife"> The LifeSupport instance to register communication endpoints. </param>
        /// <param name="me"> The URI that the communication endpoints should bind to </param>
        /// <returns> The URI at which the master communication was bound. </returns>
//JAVA TO C# CONVERTER NOTE: Members cannot have the same name as their enclosing type:
        public virtual URI SwitchToMasterConflict(LifeSupport haCommunicationLife, URI me)
        {
            _userLog.info("I am %s, moving to master", MyId(_config));

            // Do not wait for currently active transactions to complete before continuing switching.
            // - A master in a cluster is very important, without it the cluster cannot process any write requests
            // - Awaiting open transactions to complete assumes that this instance just now was a slave that is
            //   switching to master, which means the previous master where these active transactions were hosted
            //   is no longer available so these open transactions cannot continue and complete anyway,
            //   so what's the point waiting for them?
            // - Read transactions may still be able to complete, but the correct response to failures in those
            //   is to have them throw transient error exceptions hinting that they should be retried,
            //   at which point they may get redirected to another instance, or to this instance if it has completed
            //   the switch until then.

            _idGeneratorFactory.switchToMaster();
            NeoStoreDataSource dataSource = _dataSourceSupplier.get();

            dataSource.AfterModeSwitch();

            Locks locks = dataSource.DependencyResolver.resolveDependency(typeof(Locks));
            ConversationManager conversationManager = ConversationManagerFactory.apply(locks);
            Master master = MasterFactory.apply(conversationManager, haCommunicationLife);

            MasterServer masterServer = MasterServerFactory.apply(master, conversationManager);

            haCommunicationLife.Add(masterServer);
            _masterDelegateHandler.Delegate = master;

            haCommunicationLife.Start();

            URI masterHaURI = GetMasterUri(me, masterServer, _config);

            _clusterMemberAvailability.memberIsAvailable(MASTER, masterHaURI, dataSource.StoreId);
            _userLog.info("I am %s, successfully moved to master", MyId(_config));

            _slaveFactorySupplier.get().StoreId = dataSource.StoreId;

            return(masterHaURI);
        }
Beispiel #10
0
        public override void Init()
        {
            _logger.info("Initiating metrics...");
            if (_metricsBuilt && _reporter.Empty)
            {
                _logger.warn("Several metrics were enabled but no exporting option was configured to report values to. " + "Disabling kernel metrics extension.");
                _life.clear();
            }

            if (!_reporter.Empty && !_metricsBuilt)
            {
                _logger.warn("Exporting tool have been configured to report values to but no metrics were enabled. " + "Disabling kernel metrics extension.");
                _life.clear();
            }

            _life.init();
        }
Beispiel #11
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);
                        });
                    }
                });
            }
        }
Beispiel #12
0
 protected internal override void ChannelRead0(ChannelHandlerContext ctx, FileHeader fileHeader)
 {
     _log.info("Receiving file: %s", fileHeader.FileName());
     _handler.onFileHeader(fileHeader);
     _protocol.expect(State.FILE_CONTENTS);
 }
Beispiel #13
0
 public override void Visit(ResourceType resourceType, long resourceId, string description, long estimatedWaitTime, long lockIdentityHashCode)
 {
     _log.info("%s{id=%d, waitTime=%d, description=%s, lockHash=%d}", resourceType, resourceId, estimatedWaitTime, description, lockIdentityHashCode);
 }
Beispiel #14
0
        // Cluster events

        /// <summary>
        /// Logged when the instance itself joins or rejoins a cluster
        /// </summary>
        /// <param name="clusterConfiguration"> </param>
        public override void EnteredCluster(ClusterConfiguration clusterConfiguration)
        {
            _myUri = clusterConfiguration.GetUriForId(_myId);
            _log.info("Instance %s entered the cluster", PrintId(_myId, _myUri));
        }
Beispiel #15
0
 public override void StartReceivingStoreFiles()
 {
     _log.info("Start receiving store files");
 }
Beispiel #16
0
 public override void WarmupStarted()
 {
     _warmupStartMillis = currentTimeMillis();
     _log.info("Page cache warmup started.");
 }
 public override void Started(int numStages)
 {
     this._numStages = numStages;
     _log.info(MESSAGE_STARTED);
     _startTime = _clock.millis();
 }