public void Conclude() { if (serviceId < 0) { throw new ConfigurationException("service id must be not be negative: " + serviceId); } if (null == threadFactory) { threadFactory = new DefaultThreadFactory(); } if (null == idleStrategySupplier) { idleStrategySupplier = Configuration.IdleStrategySupplier(null); } if (null == epochClock) { epochClock = new SystemEpochClock(); } if (null == clusterDir) { clusterDir = new DirectoryInfo(clusteredServiceDirectoryName); } if (!clusterDir.Exists) { Directory.CreateDirectory(clusterDir.FullName); } if (null == markFile) { markFile = new ClusterMarkFile( new FileInfo(Path.Combine(clusterDir.FullName, ClusterMarkFile.MarkFilenameForService(serviceId))), ClusterComponentType.CONTAINER, errorBufferLength, epochClock, 0); } if (null == errorLog) { errorLog = new DistinctErrorLog(markFile.ErrorBuffer, epochClock); } if (null == errorHandler) { errorHandler = new LoggingErrorHandler(errorLog).OnError; // TODO Use interface } if (null == aeron) { aeron = Adaptive.Aeron.Aeron.Connect( new Aeron.Aeron.Context() .AeronDirectoryName(aeronDirectoryName) .ErrorHandler(errorHandler) .EpochClock(epochClock)); ownsAeronClient = true; } if (null == errorCounter) { errorCounter = aeron.AddCounter(SYSTEM_COUNTER_TYPE_ID, "Cluster errors - service " + serviceId); } if (null == countedErrorHandler) { countedErrorHandler = new CountedErrorHandler(errorHandler, errorCounter); if (ownsAeronClient) { aeron.Ctx().ErrorHandler(countedErrorHandler.OnError); } } if (null == archiveContext) { archiveContext = new AeronArchive.Context() .ControlRequestChannel(AeronArchive.Configuration.LocalControlChannel()) .ControlResponseChannel(AeronArchive.Configuration.LocalControlChannel()) .ControlRequestStreamId(AeronArchive.Configuration.LocalControlStreamId()); } archiveContext .AeronClient(aeron) .OwnsAeronClient(false) .Lock(new NoOpLock()); if (null == shutdownSignalBarrier) { shutdownSignalBarrier = new ShutdownSignalBarrier(); } if (null == terminationHook) { terminationHook = () => shutdownSignalBarrier.Signal(); } if (null == clusteredService) { string className = Config.GetProperty(Configuration.SERVICE_CLASS_NAME_PROP_NAME); if (null == className) { throw new ClusterException("either a ClusteredService instance or class name for the service must be provided"); } clusteredService = (IClusteredService)Activator.CreateInstance(Type.GetType(className)); } ConcludeMarkFile(); }
/// <summary> /// Set the <seealso cref="DistinctErrorLog"/> in use. /// </summary> /// <param name="errorLog"> to use. </param> /// <returns> this for a fluent API. </returns> public Context ErrorLog(DistinctErrorLog errorLog) { this.errorLog = errorLog; return(this); }