コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeartBeatWorker" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="context">The context.</param>
        /// <param name="sendHeartBeat">The send heart beat.</param>
        /// <param name="threadPool">The thread pool.</param>
        /// <param name="log">The log.</param>
        /// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param>
        public HeartBeatWorker(IHeartBeatConfiguration configuration, 
            IMessageContext context,
            ISendHeartBeat sendHeartBeat,
            IHeartBeatThreadPool threadPool,
            ILogFactory log,
            IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => sendHeartBeat, sendHeartBeat);
            Guard.NotNull(() => threadPool, threadPool);
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory);

            _context = context;
            _checkTimespan = configuration.CheckTime;
            _sendHeartbeat = sendHeartBeat;
            _smartThreadPool = threadPool;
            _logger = log.Create();

            _runningLock = new ReaderWriterLockSlim();
            _stoppedLock = new ReaderWriterLockSlim();

            _cancel = new CancellationTokenSource();
            context.WorkerNotification.HeartBeat = heartBeatNotificationFactory.Create(_cancel.Token);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeartBeatWorkerFactory" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="sendHeartBeat">The send heart beat module.</param>
        /// <param name="scheduler">The scheduler.</param>
        /// <param name="logFactory">The log factory.</param>
        /// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param>
        public HeartBeatWorkerFactory(IHeartBeatConfiguration configuration,
                                      ISendHeartBeat sendHeartBeat,
                                      IHeartBeatScheduler scheduler,
                                      ILogFactory logFactory,
                                      IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => sendHeartBeat, sendHeartBeat);
            Guard.NotNull(() => scheduler, scheduler);
            Guard.NotNull(() => logFactory, logFactory);
            Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory);

            _configuration = configuration;
            _sendHeartBeat = sendHeartBeat;
            _scheduler     = scheduler;
            _logFactory    = logFactory;
            _heartBeatNotificationFactory = heartBeatNotificationFactory;
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeartBeatWorkerFactory" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="sendHeartBeat">The send heart beat module.</param>
        /// <param name="threadPool">The thread pool.</param>
        /// <param name="logFactory">The log factory.</param>
        /// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param>
        public HeartBeatWorkerFactory(IHeartBeatConfiguration configuration,
            ISendHeartBeat sendHeartBeat,
            IHeartBeatThreadPoolFactory threadPool,
            ILogFactory logFactory,
            IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => sendHeartBeat, sendHeartBeat);
            Guard.NotNull(() => threadPool, threadPool);
            Guard.NotNull(() => logFactory, logFactory);
            Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory);

            _configuration = configuration;
            _sendHeartBeat = sendHeartBeat;
            _threadPool = threadPool;
            _logFactory = logFactory;
            _heartBeatNotificationFactory = heartBeatNotificationFactory;
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HeartBeatWorker" /> class.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="context">The context.</param>
        /// <param name="sendHeartBeat">The send heart beat.</param>
        /// <param name="scheduler">The scheduler.</param>
        /// <param name="log">The log.</param>
        /// <param name="heartBeatNotificationFactory">The heart beat notification factory.</param>
        public HeartBeatWorker(IHeartBeatConfiguration configuration,
                               IMessageContext context,
                               ISendHeartBeat sendHeartBeat,
                               IHeartBeatScheduler scheduler,
                               ILogFactory log,
                               IWorkerHeartBeatNotificationFactory heartBeatNotificationFactory)
        {
            Guard.NotNull(() => configuration, configuration);
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => sendHeartBeat, sendHeartBeat);
            Guard.NotNull(() => scheduler, scheduler);
            Guard.NotNull(() => log, log);
            Guard.NotNull(() => heartBeatNotificationFactory, heartBeatNotificationFactory);

            _context       = context;
            _checkTime     = configuration.UpdateTime;
            _sendHeartbeat = sendHeartBeat;
            _scheduler     = scheduler;
            _logger        = log.Create();

            _cancel = new CancellationTokenSource();
            context.WorkerNotification.HeartBeat = heartBeatNotificationFactory.Create(_cancel.Token);
        }