void IHandle <SystemMessage.WaitForChaserToCatchUp> .Handle(SystemMessage.WaitForChaserToCatchUp message) { // if we are in states, that doesn't need to wait for chaser, ignore if (_vnodeState != VNodeState.PreMaster && _vnodeState != VNodeState.PreReplica) { throw new Exception(string.Format("{0} appeared in {1} state.", message.GetType().Name, _vnodeState)); } if (Writer.Checkpoint.Read() != Writer.Checkpoint.ReadNonFlushed()) { Writer.Flush(); } var sw = Stopwatch.StartNew(); while (Db.Config.ChaserCheckpoint.Read() < Db.Config.WriterCheckpoint.Read() && sw.Elapsed < WaitForChaserSingleIterationTimeout) { Thread.Sleep(1); } if (Db.Config.ChaserCheckpoint.Read() == Db.Config.WriterCheckpoint.Read()) { Bus.Publish(new SystemMessage.ChaserCaughtUp(message.CorrelationId)); return; } var totalTime = message.TotalTimeWasted + sw.Elapsed; if (totalTime < TimeSpan.FromSeconds(5) || (int)totalTime.TotalSeconds % 30 == 0) // too verbose otherwise { Log.Debug("Still waiting for chaser to catch up already for {0}...", totalTime); } Bus.Publish(new SystemMessage.WaitForChaserToCatchUp(message.CorrelationId, totalTime)); }
private void Handle(SystemMessage.WaitForChaserToCatchUp message) { if (message.CorrelationId != _stateCorrelationId) { return; } _outputBus.Publish(message); }