Beispiel #1
0
        public void TestWork_NoJobs()
        {
            JobQueue      queue    = new JobQueue();
            QueueExecutor executor = new QueueExecutor(queue);

            executor.Worker        = new WorkerImpl();
            executor.PluginFactory = new DudFactory();
            executor.Persister     = new DudPersister();

            // Shouldn't get any exceptions
            executor.Start();
        }
Beispiel #2
0
        public void TestWork_NoWorker()
        {
            ObjectJobDefinition d = new ObjectJobDefinition(
                new PipelineDefinition(
                    new AlgorithmDefinition[] { }),
                new JobInput[] { });
            JobRequest    r           = new JobRequest(d);
            JobTicket     ticket      = new JobTicket(r, new DudCancellationHandler());
            JobQueue      queue       = new JobQueue();
            QueueExecutor executor    = new QueueExecutor(queue);
            bool          didComplete = false;

            executor.ExhaustedQueue += (s, e) => didComplete = true;
            queue.Enqueue(ticket);

            executor.Start();
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BatchProcessor"/>
        /// class.
        /// </summary>
        /// <param name="factory">The <see cref="IPluginFactory"/> to use
        /// when converting definitions into jobs.</param>
        /// <param name="persister">The <see cref="IJobPersister"/> to save job
        /// results to</param>
        /// <exception cref="ArgumentNullException">factory or persister are
        /// null</exception>
        public BatchProcessor(IPluginFactory factory, IJobPersister persister)
        {
            if (factory == null)
            {
                throw new ArgumentNullException("factory");
            }

            if (persister == null)
            {
                throw new ArgumentNullException("persister");
            }

            _queue                  = new JobQueue();
            _executor               = new QueueExecutor(_queue);
            _executor.Worker        = new TicketWorker();
            _executor.PluginFactory = factory;
            _executor.Persister     = persister;
        }
Beispiel #4
0
        public void TestWork_OneJob()
        {
            ObjectJobDefinition d = new ObjectJobDefinition(
                new PipelineDefinition(
                    new AlgorithmDefinition[] { }),
                new JobInput[] { });
            JobRequest    r        = new JobRequest(d);
            JobTicket     ticket   = new JobTicket(r, new DudCancellationHandler());
            JobQueue      queue    = new JobQueue();
            WorkerImpl    worker   = new WorkerImpl();
            QueueExecutor executor = new QueueExecutor(queue);

            executor.Worker        = worker;
            executor.PluginFactory = new DudFactory();
            executor.Persister     = new DudPersister();
            bool didComplete = false;

            executor.ExhaustedQueue += (s, e) => didComplete = true;
            queue.Enqueue(ticket);

            executor.Start();

            int totalTime = 0;

            while (didComplete == false)
            {
                Thread.Sleep(1);
                totalTime += 1;
                if (totalTime > 10000)
                {
                    Assert.Fail("Did not complete job in less than 10s");
                }
            }

            Assert.IsTrue(worker.DidWork);
        }
Beispiel #5
0
 public void TestConstructor_ValidArgs()
 {
     QueueExecutor executor = new QueueExecutor(new JobQueue());
 }
Beispiel #6
0
 public void TestConstructor_NullQueue()
 {
     QueueExecutor executor = new QueueExecutor(null);
 }