Exemplo n.º 1
0
        public virtual void TestAcquireLessJobsOnRejection()
        {
            // given a job acquisition strategy and a job acquisition context
            // with acquired jobs, some of which have been rejected for execution
            var context = new JobAcquisitionContext();

            var acquiredJobs = BuildAcquiredJobs(NumJobsToAcquire, NumJobsToAcquire, 0);

            context.SubmitAcquiredJobs(EngineName, acquiredJobs);

            // when half of the jobs are rejected
            var numJobsRejected = 5;

            for (var i = 0; i < numJobsRejected; i++)
            {
                context.SubmitRejectedBatch(EngineName, acquiredJobs.JobIdBatches[i]);
            }

            // then the strategy only attempts to acquire the number of jobs that were successfully submitted
            Strategy.Reconfigure(context);

            Assert.AreEqual(NumJobsToAcquire - numJobsRejected, Strategy.GetNumJobsToAcquire(EngineName));

            // without a timeout
            Assert.AreEqual(0, Strategy.WaitTime);
        }
Exemplo n.º 2
0
        protected virtual AcquiredJobs AcquireJobs(JobAcquisitionContext context, IJobAcquisitionStrategy acquisitionStrategy, ProcessEngineImpl currentProcessEngine)
        {
            ICommandExecutor commandExecutor = ((ProcessEngineConfigurationImpl)currentProcessEngine.ProcessEngineConfiguration).CommandExecutorTxRequired;

            var numJobsToAcquire = acquisitionStrategy.GetNumJobsToAcquire(currentProcessEngine.Name);

            AcquiredJobs acquiredJobs = null;

            if (numJobsToAcquire > 0)
            {
                JobExecutor.LogAcquisitionAttempt(currentProcessEngine);
                acquiredJobs = commandExecutor.Execute(JobExecutor.GetAcquireJobsCmd(numJobsToAcquire));
            }
            else
            {
                acquiredJobs = new AcquiredJobs(numJobsToAcquire);
            }

            context.SubmitAcquiredJobs(currentProcessEngine.Name, acquiredJobs);

            JobExecutor.LogAcquiredJobs(currentProcessEngine, acquiredJobs.Size());
            JobExecutor.LogAcquisitionFailureJobs(currentProcessEngine, acquiredJobs.NumberOfJobsFailedToLock);

            Log.AcquiredJobs(currentProcessEngine.Name, acquiredJobs);

            return(acquiredJobs);
        }
 protected override AcquiredJobs AcquireJobs(JobAcquisitionContext context, IJobAcquisitionStrategy configuration, ProcessEngineImpl currentProcessEngine)
 {
     AcquisitionEvents.Add(new RecordedAcquisitionEvent(DateTime.Now.Ticks, configuration.GetNumJobsToAcquire(currentProcessEngine.Name)));
     return(base.AcquireJobs(context, configuration, currentProcessEngine));
 }