public void OnClose() { if (isServiceActive) { isServiceActive = false; try { service.OnTerminate(this); } catch (Exception ex) { ctx.CountedErrorHandler().OnError(ex); } } if (!ctx.OwnsAeronClient()) { foreach (ClientSession session in sessionByIdMap.Values) { session.Disconnect(); } logAdapter?.Dispose(); _consensusModuleProxy?.Dispose(); _serviceAdapter?.Dispose(); } ctx.Dispose(); }
public void OnClose() { if (!ctx.OwnsAeronClient()) { logAdapter?.Dispose(); _consensusModuleProxy?.Dispose(); _serviceAdapter?.Dispose(); foreach (ClientSession session in sessionByIdMap.Values) { session.Disconnect(); } } }
public void OnClose() { aeron.RemoveCloseHandler(abortHandler); if (isAbort) { ctx.AbortLatch().Signal(); } else { ErrorHandler errorHandler = ctx.CountedErrorHandler().OnError; if (isServiceActive) { isServiceActive = false; try { service.OnTerminate(this); } catch (Exception ex) { errorHandler(ex); } } if (!ctx.OwnsAeronClient() && !aeron.IsClosed) { foreach (var session in sessionByIdMap.Values) { session.Disconnect(errorHandler); } CloseHelper.Dispose(errorHandler, logAdapter); CloseHelper.Dispose(errorHandler, _serviceAdapter); CloseHelper.Dispose(errorHandler, _consensusModuleProxy); } } ctx.Dispose(); }
internal ClusteredServiceAgent(ClusteredServiceContainer.Context ctx) { this.ctx = ctx; archiveCtx = ctx.ArchiveContext(); aeron = ctx.Aeron(); shouldCloseResources = ctx.OwnsAeronClient(); service = ctx.ClusteredService(); recordingLog = ctx.RecordingLog(); idleStrategy = ctx.IdleStrategy(); serviceId = ctx.ServiceId(); epochClock = ctx.EpochClock(); markFile = ctx.MarkFile(); var channel = ctx.ServiceControlChannel(); var streamId = ctx.ServiceControlStreamId(); serviceControlPublisher = new ServiceControlPublisher(aeron.AddPublication(channel, streamId)); serviceControlAdapter = new ServiceControlAdapter(aeron.AddSubscription(channel, streamId), this); }