internal BoundedLogAdapter(Image image, ReadableCounter upperBound, ClusteredServiceAgent agent) { fragmentAssembler = new ImageControlledFragmentAssembler(this, INITIAL_BUFFER_LENGTH); this.image = image; this.upperBound = upperBound; this.agent = agent; }
public void OnStart() { service.OnStart(this); CountersReader counters = aeron.CountersReader(); int recoveryCounterId = AwaitRecoveryCounterId(counters); isRecovering = true; CheckForSnapshot(counters, recoveryCounterId); CheckForReplay(counters, recoveryCounterId); isRecovering = false; JoinActiveLog(counters); roleCounter = AwaitClusterRoleCounter(counters); role = (ClusterRole)roleCounter.Get(); if (ClusterRole.Leader == role) { foreach (ClientSession session in sessionByIdMap.Values) { session.Connect(aeron); } } }
public void OnStart() { aeron.AddCloseHandler(abortHandler); CountersReader counters = aeron.CountersReader; roleCounter = AwaitClusterRoleCounter(counters, ctx.ClusterId()); commitPosition = AwaitCommitPositionCounter(counters, ctx.ClusterId()); RecoverState(counters); }
public void OnStart() { CountersReader counters = aeron.CountersReader; roleCounter = AwaitClusterRoleCounter(counters); commitPosition = AwaitCommitPositionCounter(counters); int recoveryCounterId = AwaitRecoveryCounter(counters); isServiceActive = true; CheckForSnapshot(counters, recoveryCounterId); CheckForReplay(counters, recoveryCounterId); }
public void OnStart() { CountersReader counters = aeron.CountersReader(); roleCounter = AwaitClusterRoleCounter(counters); FindHeartbeatCounter(counters); service.OnStart(this); isRecovering = true; int recoveryCounterId = AwaitRecoveryCounter(counters); CheckForSnapshot(counters, recoveryCounterId); CheckForReplay(counters, recoveryCounterId); isRecovering = false; service.OnReady(); }
public void OnStart() { CountersReader counters = aeron.CountersReader; roleCounter = AwaitClusterRoleCounter(counters); heartbeatCounter = AwaitHeartbeatCounter(counters); commitPosition = AwaitCommitPositionCounter(counters); service.OnStart(this); int recoveryCounterId = AwaitRecoveryCounter(counters); heartbeatCounter.SetOrdered(epochClock.Time()); CheckForSnapshot(counters, recoveryCounterId); CheckForReplay(counters, recoveryCounterId); }
private void CheckForReplay(CountersReader counters, int recoveryCounterId) { long replayTermCount = RecoveryState.GetReplayTermCount(counters, recoveryCounterId); if (0 == replayTermCount) { return; } service.OnReplayBegin(); for (int i = 0; i < replayTermCount; i++) { AwaitActiveLog(); int counterId = newActiveLogEvent.commitPositionId; leadershipTermId = CommitPos.GetLeadershipTermId(counters, counterId); termBaseLogPosition = CommitPos.GetTermBaseLogPosition(counters, counterId); // TODO MARK if (CommitPos.GetLeadershipTermLength(counters, counterId) > 0) { using (Subscription subscription = aeron.AddSubscription(newActiveLogEvent.channel, newActiveLogEvent.streamId)) { serviceControlPublisher.AckAction(termBaseLogPosition, leadershipTermId, serviceId, ClusterAction.READY); Image image = AwaitImage(newActiveLogEvent.sessionId, subscription); ReadableCounter limit = new ReadableCounter(counters, counterId); BoundedLogAdapter adapter = new BoundedLogAdapter(image, limit, this); ConsumeImage(image, adapter); termBaseLogPosition += image.Position(); } } newActiveLogEvent = null; serviceControlPublisher.AckAction(termBaseLogPosition, leadershipTermId, serviceId, ClusterAction.REPLAY); } service.OnReplayEnd(); }
private void CheckForReplay(CountersReader counters, int recoveryCounterId) { if (RecoveryState.HasReplay(counters, recoveryCounterId)) { AwaitActiveLog(); int counterId = _activeLogEvent.commitPositionId; using (Subscription subscription = aeron.AddSubscription(_activeLogEvent.channel, _activeLogEvent.streamId)) { _consensusModuleProxy.Ack(CommitPos.GetLogPosition(counters, counterId), ackId++, serviceId); Image image = AwaitImage(_activeLogEvent.sessionId, subscription); ReadableCounter limit = new ReadableCounter(counters, counterId); BoundedLogAdapter adapter = new BoundedLogAdapter(image, limit, this); ConsumeImage(image, adapter); } _activeLogEvent = null; heartbeatCounter.SetOrdered(epochClock.Time()); } }