public virtual void TestIdleWaitTime() { // given a job acquisition strategy and a job acquisition context // with no acquired jobs var context = new JobAcquisitionContext(); context.SubmitAcquiredJobs(EngineName, BuildAcquiredJobs(NumJobsToAcquire, 0, 0)); // when reconfiguring the strategy Strategy.Reconfigure(context); // then the job acquisition strategy returns the level 1 idle time Assert.AreEqual(BaseIdleWaitTime, Strategy.WaitTime); // when resubmitting the same acquisition result for (var idleLevel = 1; idleLevel < 6; idleLevel++) { context.Reset(); context.SubmitAcquiredJobs(EngineName, BuildAcquiredJobs(NumJobsToAcquire, 0, 0)); Strategy.Reconfigure(context); Assert.AreEqual((long)(BaseIdleWaitTime * Math.Pow(IdleIncreaseFactor, idleLevel)), Strategy.WaitTime); } // and the maximum idle level is finally reached context.Reset(); context.SubmitAcquiredJobs(EngineName, BuildAcquiredJobs(NumJobsToAcquire, 0, 0)); Strategy.Reconfigure(context); Assert.AreEqual(MaxIdleTime, Strategy.WaitTime); }
/// <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, IJobAcquisitionStrategy acquisitionStrategy) { acquisitionStrategy.Reconfigure(acquisitionContext); }