Пример #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testAcquireLessJobsOnRejection()
        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
            JobAcquisitionContext context = new JobAcquisitionContext();

            AcquiredJobs acquiredJobs = buildAcquiredJobs(NUM_JOBS_TO_ACQUIRE, NUM_JOBS_TO_ACQUIRE, 0);

            context.submitAcquiredJobs(ENGINE_NAME, acquiredJobs);

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

            for (int i = 0; i < numJobsRejected; i++)
            {
                context.submitRejectedBatch(ENGINE_NAME, acquiredJobs.JobIdBatches[i]);
            }

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

            Assert.assertEquals(NUM_JOBS_TO_ACQUIRE - numJobsRejected, strategy.getNumJobsToAcquire(ENGINE_NAME));

            // without a timeout
            Assert.assertEquals(0, strategy.WaitTime);
        }
Пример #2
0
        protected internal virtual AcquiredJobs acquireJobs(JobAcquisitionContext context, JobAcquisitionStrategy acquisitionStrategy, ProcessEngineImpl currentProcessEngine)
        {
            CommandExecutor commandExecutor = currentProcessEngine.ProcessEngineConfiguration.CommandExecutorTxRequired;

            int 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);
        }
Пример #3
0
 protected internal override AcquiredJobs acquireJobs(JobAcquisitionContext context, JobAcquisitionStrategy configuration, ProcessEngineImpl currentProcessEngine)
 {
     acquisitionEvents.Add(new RecordedAcquisitionEvent(DateTimeHelper.CurrentUnixTimeMillis(), configuration.getNumJobsToAcquire(currentProcessEngine.Name)));
     return(base.acquireJobs(context, configuration, currentProcessEngine));
 }