protected JobAcquisitionStrategy initializeAcquisitionStrategy() { return new BackoffJobAcquisitionStrategy(jobExecutor); }
@Override public void reconfigure(JobAcquisitionContext context) { reconfigureIdleLevel(context); reconfigureBackoffLevel(context); reconfigureNumberOfJobsToAcquire(context); executionSaturated = allSubmittedJobsRejected(context); }
@Override public long getWaitTime() { if (idleLevel > 0) { return calculateIdleTime(); } else if (backoffLevel > 0) { return calculateBackoffTime(); } else if (executionSaturated) { return executionSaturationWaitTime; } else { return 0; } }
protected void initializeMaxLevels() { if (baseIdleWaitTime > 0 && maxIdleWaitTime > 0 && idleIncreaseFactor > 0 && maxIdleWaitTime >= baseIdleWaitTime) { // the maximum level that produces an idle time <= maxIdleTime: // see class docs for an explanation maxIdleLevel = (int) log(idleIncreaseFactor, maxIdleWaitTime / baseIdleWaitTime) + 1; // + 1 to get the minimum level that produces an idle time > maxIdleTime maxIdleLevel += 1; } else { maxIdleLevel = 0; } if (baseBackoffWaitTime > 0 && maxBackoffWaitTime > 0 && backoffIncreaseFactor > 0 && maxBackoffWaitTime >= baseBackoffWaitTime) { // the maximum level that produces a backoff time < maxBackoffTime: // see class docs for an explanation maxBackoffLevel = (int) log(backoffIncreaseFactor, maxBackoffWaitTime / baseBackoffWaitTime) + 1; // + 1 to get the minimum level that produces a backoff time > maxBackoffTime maxBackoffLevel += 1; } else { maxBackoffLevel = 0; } }
public BackoffJobAcquisitionStrategy( long baseIdleWaitTime, float idleIncreaseFactor, long maxIdleTime, long baseBackoffWaitTime, float backoffIncreaseFactor, long maxBackoffTime, int backoffDecreaseThreshold, int baseNumJobsToAcquire) { this.baseIdleWaitTime = baseIdleWaitTime; this.idleIncreaseFactor = idleIncreaseFactor; this.idleLevel = 0; this.maxIdleWaitTime = maxIdleTime; this.baseBackoffWaitTime = baseBackoffWaitTime; this.backoffIncreaseFactor = backoffIncreaseFactor; this.backoffLevel = 0; this.maxBackoffWaitTime = maxBackoffTime; this.backoffDecreaseThreshold = backoffDecreaseThreshold; this.baseNumJobsToAcquire = baseNumJobsToAcquire; initializeMaxLevels(); }
protected void initializeMaxLevels() { if (baseIdleWaitTime > 0 && maxIdleWaitTime > 0 && idleIncreaseFactor > 0 && maxIdleWaitTime >= baseIdleWaitTime) { // the maximum level that produces an idle time <= maxIdleTime: // see class docs for an explanation maxIdleLevel = (int) log(idleIncreaseFactor, maxIdleWaitTime / baseIdleWaitTime) + 1; // + 1 to get the minimum level that produces an idle time > maxIdleTime maxIdleLevel += 1; } else { maxIdleLevel = 0; } if (baseBackoffWaitTime > 0 && maxBackoffWaitTime > 0 && backoffIncreaseFactor > 0 && maxBackoffWaitTime >= baseBackoffWaitTime) { // the maximum level that produces a backoff time < maxBackoffTime: // see class docs for an explanation maxBackoffLevel = (int) log(backoffIncreaseFactor, maxBackoffWaitTime / baseBackoffWaitTime) + 1; // + 1 to get the minimum level that produces a backoff time > maxBackoffTime maxBackoffLevel += 1; } else { maxBackoffLevel = 0; } }
public BackoffJobAcquisitionStrategy( long baseIdleWaitTime, float idleIncreaseFactor, long maxIdleTime, long baseBackoffWaitTime, float backoffIncreaseFactor, long maxBackoffTime, int backoffDecreaseThreshold, int baseNumJobsToAcquire) { this.baseIdleWaitTime = baseIdleWaitTime; this.idleIncreaseFactor = idleIncreaseFactor; this.idleLevel = 0; this.maxIdleWaitTime = maxIdleTime; this.baseBackoffWaitTime = baseBackoffWaitTime; this.backoffIncreaseFactor = backoffIncreaseFactor; this.backoffLevel = 0; this.maxBackoffWaitTime = maxBackoffTime; this.backoffDecreaseThreshold = backoffDecreaseThreshold; this.baseNumJobsToAcquire = baseNumJobsToAcquire; initializeMaxLevels(); }
@Override public void reconfigure(JobAcquisitionContext context) { reconfigureIdleLevel(context); reconfigureBackoffLevel(context); reconfigureNumberOfJobsToAcquire(context); executionSaturated = allSubmittedJobsRejected(context); }
@Override public long getWaitTime() { if (idleLevel > 0) { return calculateIdleTime(); } else if (backoffLevel > 0) { return calculateBackoffTime(); } else if (executionSaturated) { return executionSaturationWaitTime; } else { return 0; } }
protected JobAcquisitionStrategy initializeAcquisitionStrategy() { return new BackoffJobAcquisitionStrategy(jobExecutor); }
protected void initializeMaxLevels() { if (baseIdleWaitTime > 0 && maxIdleWaitTime > 0 && idleIncreaseFactor > 0 && maxIdleWaitTime >= baseIdleWaitTime) { // the maximum level that produces an idle time <= maxIdleTime: // see class docs for an explanation maxIdleLevel = (int) log(idleIncreaseFactor, maxIdleWaitTime / baseIdleWaitTime) + 1; // + 1 to get the minimum level that produces an idle time > maxIdleTime maxIdleLevel += 1; } else { maxIdleLevel = 0; } if (baseBackoffWaitTime > 0 && maxBackoffWaitTime > 0 && backoffIncreaseFactor > 0 && maxBackoffWaitTime >= baseBackoffWaitTime) { // the maximum level that produces a backoff time < maxBackoffTime: // see class docs for an explanation maxBackoffLevel = (int) log(backoffIncreaseFactor, maxBackoffWaitTime / baseBackoffWaitTime) + 1; // + 1 to get the minimum level that produces a backoff time > maxBackoffTime maxBackoffLevel += 1; } else { maxBackoffLevel = 0; } }
public BackoffJobAcquisitionStrategy( long baseIdleWaitTime, float idleIncreaseFactor, long maxIdleTime, long baseBackoffWaitTime, float backoffIncreaseFactor, long maxBackoffTime, int backoffDecreaseThreshold, int baseNumJobsToAcquire) { this.baseIdleWaitTime = baseIdleWaitTime; this.idleIncreaseFactor = idleIncreaseFactor; this.idleLevel = 0; this.maxIdleWaitTime = maxIdleTime; this.baseBackoffWaitTime = baseBackoffWaitTime; this.backoffIncreaseFactor = backoffIncreaseFactor; this.backoffLevel = 0; this.maxBackoffWaitTime = maxBackoffTime; this.backoffDecreaseThreshold = backoffDecreaseThreshold; this.baseNumJobsToAcquire = baseNumJobsToAcquire; initializeMaxLevels(); }
@Override public void reconfigure(JobAcquisitionContext context) { reconfigureIdleLevel(context); reconfigureBackoffLevel(context); reconfigureNumberOfJobsToAcquire(context); executionSaturated = allSubmittedJobsRejected(context); }
@Override public long getWaitTime() { if (idleLevel > 0) { return calculateIdleTime(); } else if (backoffLevel > 0) { return calculateBackoffTime(); } else if (executionSaturated) { return executionSaturationWaitTime; } else { return 0; } }
@Before public void setUp() { strategy = new BackoffJobAcquisitionStrategy( BASE_IDLE_WAIT_TIME, IDLE_INCREASE_FACTOR, MAX_IDLE_TIME, BASE_BACKOFF_WAIT_TIME, BACKOFF_INCREASE_FACTOR, MAX_BACKOFF_TIME, DECREASE_THRESHOLD, NUM_JOBS_TO_ACQUIRE); }
protected JobAcquisitionStrategy initializeAcquisitionStrategy() { return new BackoffJobAcquisitionStrategy(jobExecutor); }
@Before public void setUp() { strategy = new BackoffJobAcquisitionStrategy( BASE_IDLE_WAIT_TIME, IDLE_INCREASE_FACTOR, MAX_IDLE_TIME, BASE_BACKOFF_WAIT_TIME, BACKOFF_INCREASE_FACTOR, MAX_BACKOFF_TIME, DECREASE_THRESHOLD, NUM_JOBS_TO_ACQUIRE); }