@Test public void testFail() { ExponentialSchedulePolicy policy = new ExponentialSchedulePolicy(10, 80); assertEquals(10, policy.fail(false)); assertEquals(20, policy.fail(false)); assertEquals(40, policy.fail(false)); assertEquals(80, policy.fail(false)); for (int i = 0; i < 100; i++) { assertEquals(80, policy.fail(false)); } }
@Override public long fail(boolean shouldSleep) { int delayTime = m_lastDelayTime; if (delayTime == 0) { delayTime = m_delayBase; } else { delayTime = Math.min(m_lastDelayTime << 1, m_delayUpperbound); } if (shouldSleep) { try { Thread.sleep(delayTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } m_lastDelayTime = delayTime; return delayTime; }
ExponentialSchedulePolicy implements SchedulePolicy { @Override public long fail(boolean shouldSleep) { int delayTime = m_lastDelayTime; if (delayTime == 0) { delayTime = m_delayBase; } else { delayTime = Math.min(m_lastDelayTime << 1, m_delayUpperbound); } if (shouldSleep) { try { Thread.sleep(delayTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } m_lastDelayTime = delayTime; return delayTime; } }
ExponentialSchedulePolicy implements SchedulePolicy { @Override public long fail(boolean shouldSleep) { int delayTime = m_lastDelayTime; if (delayTime == 0) { delayTime = m_delayBase; } else { delayTime = Math.min(m_lastDelayTime << 1, m_delayUpperbound); } if (shouldSleep) { try { Thread.sleep(delayTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } m_lastDelayTime = delayTime; return delayTime; } ExponentialSchedulePolicy(int delayBase, int delayUpperbound); }
ExponentialSchedulePolicy implements SchedulePolicy { @Override public long fail(boolean shouldSleep) { int delayTime = m_lastDelayTime; if (delayTime == 0) { delayTime = m_delayBase; } else { delayTime = Math.min(m_lastDelayTime << 1, m_delayUpperbound); } if (shouldSleep) { try { Thread.sleep(delayTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } m_lastDelayTime = delayTime; return delayTime; } ExponentialSchedulePolicy(int delayBase, int delayUpperbound); @Override long fail(boolean shouldSleep); @Override void succeess(); }
ExponentialSchedulePolicy implements SchedulePolicy { @Override public long fail(boolean shouldSleep) { int delayTime = m_lastDelayTime; if (delayTime == 0) { delayTime = m_delayBase; } else { delayTime = Math.min(m_lastDelayTime << 1, m_delayUpperbound); } if (shouldSleep) { try { Thread.sleep(delayTime); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } m_lastDelayTime = delayTime; return delayTime; } ExponentialSchedulePolicy(int delayBase, int delayUpperbound); @Override long fail(boolean shouldSleep); @Override void succeess();  }