scheduler.scheduleNextBlockReport(); return cmds.size() == 0 ? null : cmds;
"."); scheduler.scheduleNextBlockReport(); return cmds.size() == 0 ? null : cmds;
"."); scheduler.scheduleNextBlockReport(); return cmds.size() == 0 ? null : cmds;
/** * Tests the case when a block report was delayed past its scheduled time. * In that case the next block report should not be delayed for a full interval. */ @Test public void testScheduleNextBlockReport3() { for (final long now : getTimestamps()) { Scheduler scheduler = makeMockScheduler(now); scheduler.resetBlockReportTime = false; // Make it look like the block report was scheduled to be sent between 1-3 // intervals ago but sent just now. final long blockReportDelay = BLOCK_REPORT_INTERVAL_MS + random.nextInt(2 * (int) BLOCK_REPORT_INTERVAL_MS); final long origBlockReportTime = now - blockReportDelay; scheduler.nextBlockReportTime = origBlockReportTime; scheduler.scheduleNextBlockReport(); assertTrue(scheduler.nextBlockReportTime - now < BLOCK_REPORT_INTERVAL_MS); assertTrue(((scheduler.nextBlockReportTime - origBlockReportTime) % BLOCK_REPORT_INTERVAL_MS) == 0); } }
/** * If resetBlockReportTime is true then the next block report must be scheduled * in the range [now, now + BLOCK_REPORT_INTERVAL_SEC). */ @Test public void testScheduleNextBlockReport() { for (final long now : getTimestamps()) { Scheduler scheduler = makeMockScheduler(now); assertTrue(scheduler.resetBlockReportTime); scheduler.scheduleNextBlockReport(); assertTrue(scheduler.nextBlockReportTime - (now + BLOCK_REPORT_INTERVAL_MS) < 0); } }
/** * If resetBlockReportTime is false then the next block report must be scheduled * exactly at (now + BLOCK_REPORT_INTERVAL_SEC). */ @Test public void testScheduleNextBlockReport2() { for (final long now : getTimestamps()) { Scheduler scheduler = makeMockScheduler(now); scheduler.resetBlockReportTime = false; scheduler.scheduleNextBlockReport(); assertThat(scheduler.nextBlockReportTime, is(now + BLOCK_REPORT_INTERVAL_MS)); } }