예제 #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testIdleWaitTime()
        public virtual void testIdleWaitTime()
        {
            // given a job acquisition strategy and a job acquisition context
            // with no acquired jobs
            JobAcquisitionContext context = new JobAcquisitionContext();

            context.submitAcquiredJobs(ENGINE_NAME, buildAcquiredJobs(NUM_JOBS_TO_ACQUIRE, 0, 0));

            // when reconfiguring the strategy
            strategy.reconfigure(context);

            // then the job acquisition strategy returns the level 1 idle time
            Assert.assertEquals(BASE_IDLE_WAIT_TIME, strategy.WaitTime);

            // when resubmitting the same acquisition result
            for (int idleLevel = 1; idleLevel < 6; idleLevel++)
            {
                context.reset();
                context.submitAcquiredJobs(ENGINE_NAME, buildAcquiredJobs(NUM_JOBS_TO_ACQUIRE, 0, 0));

                strategy.reconfigure(context);
                Assert.assertEquals((long)(BASE_IDLE_WAIT_TIME * Math.Pow(IDLE_INCREASE_FACTOR, idleLevel)), strategy.WaitTime);
            }

            // and the maximum idle level is finally reached
            context.reset();
            context.submitAcquiredJobs(ENGINE_NAME, buildAcquiredJobs(NUM_JOBS_TO_ACQUIRE, 0, 0));

            strategy.reconfigure(context);
            Assert.assertEquals(MAX_IDLE_TIME, strategy.WaitTime);
        }
예제 #2
0
 /// <summary>
 /// Reconfigure the acquisition strategy based on the current cycle's acquisition context.
 /// A strategy implementation may update internal data structure to calculate a different wait time
 /// before the next cycle of acquisition is performed.
 /// </summary>
 protected internal virtual void configureNextAcquisitionCycle(JobAcquisitionContext acquisitionContext, JobAcquisitionStrategy acquisitionStrategy)
 {
     acquisitionStrategy.reconfigure(acquisitionContext);
 }