Пример #1
0
 public void Setup()
 {
     _queuedExecutorSettings = new QueuedExecutorSettings{Name = "test"};
     _queue = new QueuedExecutor(_queuedExecutorSettings, NullPersister.Instance);
     _queue.TaskAdded += delegate {  };
     _task = new LongRunningTask(true);
     _executionEnvelope = new ExecutionEnvelope(_task, DefaultReleaser.Instance);
 }
Пример #2
0
        public QueuedExecutor(QueuedExecutorSettings settings, IPersister persister)
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings");
            }

            settings.Validate();

            _settings = settings;
            _persister = persister;
            _region = new Region(_settings.Name);
            _queue = new ConcurrentQueue<ExecutionEnvelope>();
        }
Пример #3
0
        public void Ordered_tasks_are_executed_serially()
        {
            var taskQueueSettings = new QueuedExecutorSettings{Name = "test"};
            var taskQueue = new QueuedExecutor(taskQueueSettings, NullPersister.Instance);
            var matcher = new NamespaceMatcher(taskQueue.Name, NamespaceMatcher.AnyWildCard);
            var taskRouter = new TaskRouter(matcher, new IExecutorImplementation[]{taskQueue });
            var dispatcher = new TaskDispatcher(2, new IExecutionQueue[] {taskQueue});
            var executor = new Executor(taskRouter, dispatcher, new DefaultReleaser());

            var tasks = Enumerable.Range(1, 2).Select(x => new LongRunningTask(true) {Name = "Task" + x}).ToArray();

            foreach (var task in tasks)
            {
                executor.Execute(task);
            }

            Assert.That(tasks[0].WaitForStart(1000), Is.True, "First task should start");

            Assert.That(tasks[1].WaitForStart(1000), Is.False, "Second task should not start");
        }
Пример #4
0
 public void MakeSettings()
 {
     _queuedExecutorSettings = new QueuedExecutorSettings { Name = "test" };
 }
        public void SetUp()
        {
            _tasks = new List<LongRunningTask>();
            var settings = new QueuedExecutorSettings{ Name = "test" };
            _queue = new QueuedExecutor(settings, NullPersister.Instance);

            var settings2 = new QueuedExecutorSettings{ Name = "test" };
            _queue2 = new QueuedExecutor(settings2, NullPersister.Instance);

            _taskDispatcher = new TaskDispatcher(2, new IExecutionQueue[] { _queue, _queue2 });
        }
Пример #6
0
 public ExecutorBuilder WithQueuedExecutors(QueuedExecutorSettings queuedExecutorSettings)
 {
     _queuedExecutors.Add(queuedExecutorSettings);
     return this;
 }
Пример #7
0
        private void RegisterQueuedExecutors()
        {
            if (_queuedExecutors.Count == 0)
            {
                var settings = new QueuedExecutorSettings { Name = "default" };
                _queuedExecutors.Add(settings);
            }

            foreach (QueuedExecutorSettings settings in _queuedExecutors)
            {
                Kernel.Register(
                    Component
                        .For<IExecutorImplementation, IExecutionQueue>()
                        .ImplementedBy<QueuedExecutor>()
                        .Named(settings.Name)
                        .DependsOn(new { settings })
                        .LifestyleSingleton()
                    );
            }
        }