Exemplo n.º 1
0
 /// <summary>
 /// Starts the dynamic process operation.
 /// </summary>
 public void Start()
 {
     _dynamicProcess.Start();
 }
        public CoordinationExchangeManager(ICoordinationSessionOwner sessionOwner,
                                           ISessionManager sessionManager,
                                           ILockWaitDirectory lockWaitDirectory,
                                           IProvider <ICoordinationLockManager> lockManager,
                                           ICoordinationStorage storage,
                                           CoordinationEntryCache cache,
                                           IPhysicalEndPointMultiplexer <TAddress> endPointMultiplexer,
                                           IAddressConversion <TAddress> addressConversion,
                                           IOptions <CoordinationManagerOptions> optionsAccessor,
                                           ILogger <CoordinationExchangeManager <TAddress> > logger = null)
        {
            if (sessionOwner == null)
            {
                throw new ArgumentNullException(nameof(sessionOwner));
            }

            if (sessionManager == null)
            {
                throw new ArgumentNullException(nameof(sessionManager));
            }

            if (lockWaitDirectory == null)
            {
                throw new ArgumentNullException(nameof(lockWaitDirectory));
            }

            if (lockManager == null)
            {
                throw new ArgumentNullException(nameof(lockManager));
            }

            if (storage == null)
            {
                throw new ArgumentNullException(nameof(storage));
            }

            if (cache == null)
            {
                throw new ArgumentNullException(nameof(cache));
            }

            if (endPointMultiplexer == null)
            {
                throw new ArgumentNullException(nameof(endPointMultiplexer));
            }

            if (addressConversion == null)
            {
                throw new ArgumentNullException(nameof(addressConversion));
            }

            _sessionOwner        = sessionOwner;
            _sessionManager      = sessionManager;
            _lockWaitDirectory   = lockWaitDirectory;
            _lockManager         = lockManager;
            _storage             = storage;
            _cache               = cache;
            _endPointMultiplexer = endPointMultiplexer;
            _addressConversion   = addressConversion;
            _logger              = logger;

            _options          = optionsAccessor.Value ?? new CoordinationManagerOptions();
            _physicalEndPoint = new DisposableAsyncLazy <IPhysicalEndPoint <TAddress> >(
                factory: GetLocalSessionEndPointAsync,
                disposal: DisposePhysicalEndPointAsync,
                DisposableAsyncLazyOptions.Autostart | DisposableAsyncLazyOptions.ExecuteOnCallingThread);

            _receiveProcess = new AsyncProcess(ReceiveProcess);
            _receiveProcess.Start();
        }