/// <summary> /// Initializes a new instance of the <see cref="TaskSchedulerPollingJob"/> class. /// </summary> /// <param name="configProvider">The configuration provider to retrieve configuration.</param> /// <param name="repository">The repository to use.</param> /// <param name="dateTimeProvider">The date time provider to use.</param> /// <param name="facade">The task processor facade to use to submit tasks.</param> public TaskSchedulerPollingJob(ITaskProcessorConfigurationProvider configProvider, ITaskProcessorRepository repository, IDateTimeProvider dateTimeProvider, ITaskProcessorFacade facade) { if (configProvider == null) { throw new ArgumentNullException(nameof(configProvider)); } if (repository == null) { throw new ArgumentNullException(nameof(repository)); } if (dateTimeProvider == null) { throw new ArgumentNullException(nameof(dateTimeProvider)); } if (facade == null) { throw new ArgumentNullException(nameof(facade)); } this.configuration = configProvider.GetTaskSchedulerConfiguration(); this.repository = repository; this.dateTimeProvider = dateTimeProvider; this.facade = facade; this.repository.ScheduledTasks.Added += this.OnScheduledTaskAdded; this.repository.ScheduledTasks.Updated += this.OnScheduledTaskUpdated; this.repository.ScheduledTasks.Deleted += this.OnScheduledTaskDeleted; }
/// <summary> /// Initializes a new instance of the <see cref="MasterCommandsProcessor"/> class. /// </summary> /// <param name="repository">The repository to use.</param> /// <param name="messageBus">The message bus to use.</param> /// <param name="taskDistributor">The task distributor to use.</param> /// <exception cref="ArgumentNullException">Parameter <paramref name="repository"/>, <paramref name="messageBus"/> or <paramref name="taskDistributor"/> is null.</exception> public MasterCommandsProcessor(ITaskProcessorRepository repository, ITaskProcessorMessageBus messageBus, ITaskDistributor taskDistributor) { Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName)); if (repository == null) { throw new ArgumentNullException("repository"); } if (messageBus == null) { throw new ArgumentNullException("messageBus"); } if (taskDistributor == null) { throw new ArgumentNullException("taskDistributor"); } this.messageBus = messageBus; this.repository = repository; this.taskDistributor = taskDistributor; Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName)); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultTaskDistributor"/> class. /// </summary> /// <param name="repository">The repository to be used when the task distributor has to retrieve some data from storage.</param> /// <exception cref="ArgumentNullException">Parameter <paramref name="repository"/> is null.</exception> public DefaultTaskDistributor(ITaskProcessorRepository repository) { if (repository == null) { throw new ArgumentNullException(nameof(repository)); } this.repository = repository; }
/// <summary> /// Initializes a new instance of the <see cref="TaskWorkerBootstrap"/> class. /// </summary> /// <param name="configProvider">The configuration provider to use.</param> /// <param name="repository">The repository to use.</param> /// <param name="messageBus">The message bus to use.</param> /// <param name="taskWorkerFactory">The task worker factory to use.</param> /// <param name="dateTimeProvider">The date time provider to use.</param> /// <exception cref="ArgumentNullException">Parameter <paramref name="repository"/>, <paramref name="messageBus"/>, /// <paramref name="taskWorkerFactory"/> or <paramref name="dateTimeProvider"/> is null.</exception> public TaskWorkerBootstrap(ITaskProcessorConfigurationProvider configProvider, ITaskProcessorRepository repository, ITaskProcessorMessageBus messageBus, ITaskWorkerFactory taskWorkerFactory, IDateTimeProvider dateTimeProvider) { if (configProvider == null) { throw new ArgumentNullException("configProvider"); } if (repository == null) { throw new ArgumentNullException("repository"); } if (messageBus == null) { throw new ArgumentNullException("messageBus"); } if (taskWorkerFactory == null) { throw new ArgumentNullException("taskWorkerFactory"); } if (dateTimeProvider == null) { throw new ArgumentNullException("dateTimeProvider"); } this.configuration = configProvider.GetTaskWorkerConfiguration(); if (this.configuration == null) { throw new ArgumentException("'{0}' returned null configuration.".FormatInvariant(configProvider.GetType()), nameof(configProvider)); } this.repository = repository; this.messageBus = messageBus; this.taskFactory = taskWorkerFactory; this.dateTimeProvider = dateTimeProvider; }
/// <summary> /// Initializes a new instance of the <see cref="TaskProcessorFacade"/> class. /// </summary> /// <param name="repository">The repository to use.</param> /// <param name="messageBus">The message bus to use.</param> /// <param name="dateTimeProvider">The date time provider to use.</param> /// <param name="appConfigConfigurationProvider">The configuration provider to read from App.config.</param> /// <exception cref="ArgumentNullException">Parameter <paramref name="repository"/>, <paramref name="messageBus"/>, /// <paramref name="dateTimeProvider"/> or <paramref name="appConfigConfigurationProvider"/> is null.</exception> public TaskProcessorFacade( ITaskProcessorRepository repository, ITaskProcessorMessageBus messageBus, IDateTimeProvider dateTimeProvider, ITaskProcessorConfigurationProvider appConfigConfigurationProvider) { Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName)); if (repository == null) { throw new ArgumentNullException("repository"); } if (messageBus == null) { throw new ArgumentNullException("messageBus"); } if (dateTimeProvider == null) { throw new ArgumentNullException("dateTimeProvider"); } if (appConfigConfigurationProvider == null) { throw new ArgumentNullException("appConfigConfigurationProvider"); } this.repository = repository; this.messageBus = messageBus; this.dateTimeProvider = dateTimeProvider; this.configuration = appConfigConfigurationProvider.GetClientConfiguration(); Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName)); }
public MainViewModel( ITaskProcessorRepository repository, ITaskProcessorMessageBus messageBus, ITaskProcessorFacade taskProcessorFacade, ITimer performanceMonitoringTimer) { if (repository == null) { throw new ArgumentNullException("repository"); } if (messageBus == null) { throw new ArgumentNullException("messageBus"); } if (taskProcessorFacade == null) { throw new ArgumentNullException("taskProcessorFacade"); } if (performanceMonitoringTimer == null) { throw new ArgumentNullException("performanceMonitoringTimer"); } this.repository = repository; this.messageBus = messageBus; this.taskProcessorFacade = taskProcessorFacade; this.performanceMonitoringTimer = performanceMonitoringTimer; this.messageBus.TaskProcessors.Receiver.MasterModeChanged += this.OnMasterModeChanged; this.messageBus.TaskProcessors.Receiver.StateChanged += this.OnTaskProcessorStateChanged; this.messageBus.TaskProcessors.Receiver.PerformanceReportReceived += this.OnPerformanceReport; this.messageBus.Tasks.Receiver.TaskSubmitted += this.OnTaskSubmitted; this.messageBus.Tasks.Receiver.TaskAssigned += this.OnTaskAssignedToProcessor; this.messageBus.Tasks.Receiver.TaskStarted += this.OnTaskStarted; this.messageBus.Tasks.Receiver.TaskProgress += this.OnTaskProgress; this.messageBus.Tasks.Receiver.TaskCancelRequested += this.OnTaskCancelRequested; this.messageBus.Tasks.Receiver.TaskCancelCompleted += this.OnTaskCancelCompleted; this.messageBus.Tasks.Receiver.TaskFailed += this.OnTaskFailed; this.messageBus.Tasks.Receiver.TaskCompleted += this.OnTaskCompleted; this.performanceMonitoringTimer.Interval = TimeSpan.FromSeconds(5); this.performanceMonitoringTimer.Tick += this.OnPerformanceMonitoringTimerTick; this.InitializeTasks(); this.messageBus.TaskProcessors.Receiver.SubscribeForChannels( MessageBusChannel.TaskProcessorState, MessageBusChannel.MasterModeChanged, MessageBusChannel.PerformanceReport); this.messageBus.Tasks.Receiver.SubscribeForChannels( MessageBusChannel.TaskSubmitted, MessageBusChannel.TaskAssigned, MessageBusChannel.TaskStarted, MessageBusChannel.TaskProgress, MessageBusChannel.TaskCancelRequest, MessageBusChannel.TaskCancelCompleted, MessageBusChannel.TaskFailed, MessageBusChannel.TaskCompleted); }