internal ClusteredServiceAgent(ClusteredServiceContainer.Context ctx) { this.ctx = ctx; headerVector = new DirectBufferVector(headerBuffer, 0, headerBuffer.Capacity); abortHandler = Abort; archiveCtx = ctx.ArchiveContext(); aeron = ctx.Aeron(); aeronAgentInvoker = ctx.Aeron().ConductorAgentInvoker; service = ctx.ClusteredService(); idleStrategy = ctx.IdleStrategy(); serviceId = ctx.ServiceId(); epochClock = ctx.EpochClock(); markFile = ctx.MarkFile(); var channel = ctx.ServiceControlChannel(); _consensusModuleProxy = new ConsensusModuleProxy(aeron.AddPublication(channel, ctx.ConsensusModuleStreamId())); _serviceAdapter = new ServiceAdapter(aeron.AddSubscription(channel, ctx.ServiceStreamId()), this); _sessionMessageHeaderEncoder.WrapAndApplyHeader(headerBuffer, 0, new MessageHeaderEncoder()); aeron.AddCloseHandler(abortHandler); }
public void OnStart() { aeron.AddCloseHandler(abortHandler); CountersReader counters = aeron.CountersReader; roleCounter = AwaitClusterRoleCounter(counters, ctx.ClusterId()); commitPosition = AwaitCommitPositionCounter(counters, ctx.ClusterId()); RecoverState(counters); }