Пример #1
0
        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();
        }
Пример #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;
        }
Пример #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;
        }
Пример #4
0
        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));
        }
Пример #5
0
 internal WorkerContext(SharedWorkerContext sharedContext, int workerNumber)
     : base(sharedContext)
 {
     WorkerNumber = workerNumber;
 }
Пример #6
0
 internal SharedWorkerContext(SharedWorkerContext context)
     : this(context.ServerId, context.Queues, context.Storage, context.PerformanceProcess, context.Activator, context.StateMachineFactory)
 {
 }
        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);
        }
Пример #8
0
 internal WorkerContext(SharedWorkerContext sharedContext, int workerNumber)
     : base(sharedContext)
 {
     WorkerNumber = workerNumber;
 }
Пример #9
0
 internal SharedWorkerContext(SharedWorkerContext context)
     : this(context.ServerId, context.Queues, context.Storage, context.PerformanceProcess, context.Activator, context.StateMachineFactory)
 {
 }