public WorkerManagerFacts()
        {
            _sharedContext = new SharedWorkerContext(
                "server",
                new[] { "default" },
                new Mock<JobStorage>().Object,
                new Mock<IJobPerformanceProcess>().Object,
                new Mock<JobActivator>().Object,
                new Mock<IStateMachineFactory>().Object);

            _workerSupervisors = new[]
            {
                new Mock<IServerSupervisor>(), 
                new Mock<IServerSupervisor>()
            };

            _manager = new Mock<WorkerManager>(
                _sharedContext, WorkerCount);

            _manager.Setup(x => x.CreateWorkerSupervisor(It.IsNotNull<WorkerContext>()))
                .Returns((WorkerContext context) => _workerSupervisors[context.WorkerNumber - 1].Object);

			_cts = new CancellationTokenSource();
			_cts.Cancel();
        }
Exemple #2
0
        public WorkerManager(SharedWorkerContext sharedContext, int workerCount)
        {
            if (sharedContext == null) throw new ArgumentNullException("sharedContext");
            if (workerCount <= 0) throw new ArgumentOutOfRangeException("workerCount", "Worker count value must be more than zero.");

            _sharedContext = sharedContext;
            _workerCount = workerCount;
        }
Exemple #3
0
        public WorkerManager(SharedWorkerContext sharedContext, int workerCount)
        {
            if (sharedContext == null)
            {
                throw new ArgumentNullException("sharedContext");
            }
            if (workerCount <= 0)
            {
                throw new ArgumentOutOfRangeException("workerCount", "Worker count value must be more than zero.");
            }

            _sharedContext = sharedContext;
            _workerCount   = workerCount;
        }
Exemple #4
0
 internal WorkerContext(SharedWorkerContext sharedContext, int workerNumber)
     : base(sharedContext)
 {
     WorkerNumber = workerNumber;
 }
Exemple #5
0
 internal WorkerContext(SharedWorkerContext sharedContext, int workerNumber)
     : base(sharedContext)
 {
     WorkerNumber = workerNumber;
 }
        private IEnumerable<IServerSupervisor> GetCommonSupervisors()
        {
            var stateMachineFactory = new StateMachineFactory(_storage);
            var sharedWorkerContext = new SharedWorkerContext(
                _serverId,
                _options.Queues,
                _storage,
                new JobPerformanceProcess(),
                JobActivator.Current,
                stateMachineFactory);

            yield return new ServerSupervisor(new WorkerManager(sharedWorkerContext, _options.WorkerCount));
            yield return new ServerSupervisor(new ServerHeartbeat(_storage, _serverId));
            yield return new ServerSupervisor(new ServerWatchdog(_storage));

            yield return new ServerSupervisor(
                new SchedulePoller(_storage, stateMachineFactory, _options.SchedulePollingInterval));

            yield return new ServerSupervisor(
                new RecurringJobScheduler(
                    _storage, 
                    new BackgroundJobClient(_storage, stateMachineFactory),
                    new ScheduleInstantFactory(),
                    new EveryMinuteThrottler()));
        }
        public void CopyCtor_CorrectlyInitializes_AllProperties()
        {
            var context = CreateContext();
            var contextCopy = new SharedWorkerContext(context);

            Assert.Equal(context.ServerId, contextCopy.ServerId);
            Assert.Same(context.Queues, contextCopy.Queues);
            Assert.Same(context.Storage, contextCopy.Storage);
            Assert.Same(context.PerformanceProcess, contextCopy.PerformanceProcess);
            Assert.Same(context.Activator, contextCopy.Activator);
            Assert.Same(context.StateMachineFactory, contextCopy.StateMachineFactory);
        }
 internal SharedWorkerContext(SharedWorkerContext context)
     : this(context.ServerId, context.Queues, context.Storage, context.PerformanceProcess, context.Activator, context.StateMachineFactory)
 {
 }
 internal SharedWorkerContext(SharedWorkerContext context)
     : this(context.ServerId, context.Queues, context.Storage, context.PerformanceProcess, context.Activator, context.StateMachineFactory)
 {
 }