Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void doWork() throws java.io.IOException
        protected internal override void DoWork()
        {
            int newMemberId = _cluster.readReplicas().Count;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.causalclustering.discovery.ReadReplica readReplica = cluster.addReadReplicaWithId(newMemberId);
            ReadReplica readReplica = _cluster.addReadReplicaWithId(newMemberId);

            _log.info("Adding " + readReplica);
            readReplica.Start();

            LagEvaluator lagEvaluator = new LagEvaluator(this.leaderTxId, () => TxId(readReplica), Clock.systemUTC());

            awaitForever(() =>
            {
                if (!Control.keepGoing())
                {
                    return(true);
                }

                Optional <Lag> lagEstimate = lagEvaluator.Evaluate();

                if (lagEstimate.Present)
                {
                    _log.info(lagEstimate.get().ToString());
                    return(lagEstimate.get().timeLagMillis() < MAX_LAG_MS);
                }
                else
                {
                    _log.info("Lag estimate not available");
                    return(false);
                }
            }, SAMPLE_INTERVAL_MS, MILLISECONDS);

            if (!Control.keepGoing())
            {
                return;
            }

            _log.info("Caught up");
            _cluster.removeReadReplicaWithMemberId(newMemberId);

            if (_deleteStore)
            {
                _log.info("Deleting store of " + readReplica);
                _fs.deleteRecursively(readReplica.DatabaseDirectory());
            }
            _deleteStore = !_deleteStore;
        }
Beispiel #2
0
 internal Lag(LagEvaluator outerInstance, long timeLagMillis, long valueLag)
 {
     this._outerInstance        = outerInstance;
     this.TimeLagMillisConflict = timeLagMillis;
     this.ValueLag = valueLag;
 }