Beispiel #1
0
        public WorkerWrapper(IInvokeHandler invokeHandler,
                             NodeConfiguration nodeConfiguration,
                             TrySendNodeStartUpNotificationToManagerTimer nodeStartUpNotificationToManagerTimer,
                             Timer pingToManagerTimer,
                             TrySendJobDoneStatusToManagerTimer trySendJobDoneStatusToManagerTimer,
                             TrySendJobCanceledToManagerTimer trySendJobCanceledStatusToManagerTimer,
                             TrySendJobFaultedToManagerTimer trySendJobFaultedStatusToManagerTimer,
                             TrySendJobDetailToManagerTimer trySendJobDetailToManagerTimer, JobDetailSender jobDetailSender)
        {
            _handler           = invokeHandler;
            _nodeConfiguration = nodeConfiguration;
            WhoamI             = _nodeConfiguration.CreateWhoIAm(Environment.MachineName);

            _nodeStartUpNotificationToManagerTimer = nodeStartUpNotificationToManagerTimer;
            _nodeStartUpNotificationToManagerTimer.TrySendNodeStartUpNotificationSucceded +=
                NodeStartUpNotificationToManagerTimer_TrySendNodeStartUpNotificationSucceded;

            _pingToManagerTimer = pingToManagerTimer;
            _trySendJobDoneStatusToManagerTimer     = trySendJobDoneStatusToManagerTimer;
            _trySendJobCanceledStatusToManagerTimer = trySendJobCanceledStatusToManagerTimer;
            _trySendJobFaultedStatusToManagerTimer  = trySendJobFaultedStatusToManagerTimer;
            _trySendJobDetailToManagerTimer         = trySendJobDetailToManagerTimer;
            _jobDetailSender = jobDetailSender;

            IsWorking = false;

            _trySendJobDetailToManagerTimer.Start();
            _nodeStartUpNotificationToManagerTimer.Start();
        }
Beispiel #2
0
        private void SetNodeStatusTimer(TrySendStatusToManagerTimer newTrySendStatusToManagerTimer,
                                        JobQueueItemEntity jobQueueItemEntity)
        {
            // Stop and dispose old timer.
            if (_trySendStatusToManagerTimer != null)
            {
                _trySendStatusToManagerTimer.Stop();

                // Remove event handler.
                _trySendStatusToManagerTimer.TrySendStatusSucceded -=
                    TrySendStatusToManagerTimer_TrySendStatus;

                _trySendStatusToManagerTimer = null;
            }

            // Set new timer, if exists.
            if (newTrySendStatusToManagerTimer != null)
            {
                _trySendStatusToManagerTimer = newTrySendStatusToManagerTimer;

                _trySendStatusToManagerTimer.JobQueueItemEntity = jobQueueItemEntity;

                _trySendStatusToManagerTimer.TrySendStatusSucceded +=
                    TrySendStatusToManagerTimer_TrySendStatus;

                _trySendStatusToManagerTimer.Start();
            }
            else
            {
                _trySendStatusToManagerTimer = null;
            }
        }