Пример #1
0
        public CheckTriggersQueueFeeder(
            WaitHandle stopSignal,
            JobQueue <ProjectRelatedJob> buildQueue,
            IThreadFactory threadFactory,
            IWorkerMonitor workerMonitor,
            IProjectRegistry projectRegistry)
            : base("CheckTriggersQueueFeeder", stopSignal, threadFactory, workerMonitor)
        {
            this.projectRegistry    = projectRegistry;
            this.checkTriggersQueue = new JobQueue <ProjectRelatedJob> ("Check triggers queue", stopSignal);

            for (int i = 0; i < checkTriggersWorkersCount; i++)
            {
                CheckTriggersWorker worker = new CheckTriggersWorker(
                    string.Format(
                        CultureInfo.InvariantCulture,
                        "CheckTriggersWorker {0}",
                        i),
                    checkTriggersQueue,
                    buildQueue,
                    threadFactory,
                    projectRegistry,
                    workerMonitor);
                checkTriggersQueue.AddWorker(worker);
            }

            checkTriggersQueue.StartWorkers();
        }
Пример #2
0
        public void CheckTriggersQueue()
        {
            HeadlessMother mother        = new HeadlessMother();
            IThreadFactory threadFactory = new DefaultThreadFactory();
            IWorkerMonitor workerMonitor = mother.WorkerMonitor;

            using (ManualResetEvent stopSignal = new ManualResetEvent(false))
            {
                JobQueue <ProjectRelatedJob> buildQueue = new JobQueue <ProjectRelatedJob>("buildQueue", stopSignal);

                using (CheckTriggersQueueFeeder checkTriggersQueueFeeder = new CheckTriggersQueueFeeder(
                           stopSignal,
                           buildQueue,
                           threadFactory,
                           workerMonitor,
                           mother.ProjectRegistry))
                {
                    checkTriggersQueueFeeder.Start();
                    Thread.Sleep(TimeSpan.FromSeconds(10));
                    stopSignal.Set();

                    threadFactory.WaitForAllThreadsToStop(TimeSpan.FromSeconds(5));
                }
            }

            mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("ProjectPilot", ProjectStatus.CheckingTriggers));
            mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("Headless", ProjectStatus.CheckingTriggers));
            mother.ProjectRegistry.AssertWasCalled(r => r.ChangeProjectStatus("Flubu", ProjectStatus.CheckingTriggers));
            mother.ProjectRegistry.VerifyAllExpectations();
        }
Пример #3
0
 public CheckTriggersWorker(
     string workerName,
     JobQueue <ProjectRelatedJob> jobQueue,
     JobQueue <ProjectRelatedJob> buildQueue,
     IThreadFactory threadFactory,
     IProjectRegistry projectRegistry,
     IWorkerMonitor workerMonitor) : base(workerName, jobQueue, threadFactory, workerMonitor)
 {
     this.buildQueue      = buildQueue;
     this.projectRegistry = projectRegistry;
 }
Пример #4
0
 public HeadlessService(
     IProjectRegistry projectRegistry,
     IThreadFactory threadFactory,
     IWorkerMonitor workerMonitor,
     IHeadlessLogger headlessLogger)
 {
     this.projectRegistry = projectRegistry;
     this.threadFactory   = threadFactory;
     this.workerMonitor   = workerMonitor;
     this.headlessLogger  = headlessLogger;
 }
Пример #5
0
 public BuildWorker(
     string workerName,
     JobQueue <ProjectRelatedJob> buildQueue,
     IThreadFactory threadFactory,
     IProjectRegistry projectRegistry,
     IWorkerMonitor workerMonitor,
     IHeadlessLogger headlessLogger)
     : base(workerName, buildQueue, threadFactory, workerMonitor)
 {
     this.projectRegistry = projectRegistry;
     this.headlessLogger  = headlessLogger;
 }
Пример #6
0
 public TestWorker(string workerName, JobQueue <Job> jobQueue, IThreadFactory threadFactory, IWorkerMonitor workerMonitor)
     : base(workerName, jobQueue, threadFactory, workerMonitor)
 {
 }
Пример #7
0
 protected AbstractWorker(BusyWatcher busyWatcher)
 {
     _workerMonitor = new WorkerMonitor(busyWatcher, this);
 }
Пример #8
0
 protected QueuedWorker(string workerName, JobQueue <TJob> jobQueue, IThreadFactory threadFactory, IWorkerMonitor workerMonitor)
     : base(workerName, jobQueue.StopWorkingSignal, threadFactory, workerMonitor)
 {
     this.jobQueue = jobQueue;
 }
Пример #9
0
 protected Worker(string workerName, WaitHandle stopSignal, IThreadFactory threadFactory, IWorkerMonitor workerMonitor)
 {
     this.threadFactory = threadFactory;
     this.workerName    = workerName;
     this.stopSignal    = stopSignal;
     this.workerMonitor = workerMonitor;
 }