/** * This methods arranges for the data node to send the block report at * the next heartbeat. */ long scheduleBlockReport(long delay) { if (delay > 0) { // send BR after random delay // Numerical overflow is possible here and is okay. nextBlockReportTime = monotonicNow() + ThreadLocalRandom.current().nextInt((int) (delay)); } else { // send at next heartbeat nextBlockReportTime = monotonicNow(); } resetBlockReportTime = true; // reset future BRs for randomness return nextBlockReportTime; }
/** * Schedule the next block report after the block report interval. If the * current block report was delayed then the next block report is sent per * the original schedule. * Numerical overflow is possible here. */ void scheduleNextBlockReport() { // If we have sent the first set of block reports, then wait a random // time before we start the periodic block reports. if (resetBlockReportTime) { nextBlockReportTime = monotonicNow() + ThreadLocalRandom.current().nextInt((int)(blockReportIntervalMs)); resetBlockReportTime = false; } else { /* say the last block report was at 8:20:14. The current report * should have started around 14:20:14 (default 6 hour interval). * If current time is : * 1) normal like 14:20:18, next report should be at 20:20:14. * 2) unexpected like 21:35:43, next report should be at 2:20:14 * on the next day. */ nextBlockReportTime += (((monotonicNow() - nextBlockReportTime + blockReportIntervalMs) / blockReportIntervalMs)) * blockReportIntervalMs; } }
private void sendLifelineIfDue() throws IOException { long startTime = scheduler.monotonicNow(); if (!scheduler.isLifelineDue(startTime)) { if (LOG.isDebugEnabled()) { LOG.debug("Skipping sending lifeline for " + BPServiceActor.this + ", because it is not due."); } return; } if (dn.areHeartbeatsDisabledForTests()) { if (LOG.isDebugEnabled()) { LOG.debug("Skipping sending lifeline for " + BPServiceActor.this + ", because heartbeats are disabled for tests."); } return; } sendLifeline(); dn.getMetrics().addLifeline(scheduler.monotonicNow() - startTime); scheduler.scheduleNextLifeline(scheduler.monotonicNow()); }
long getHeartbeatWaitTime() { return nextHeartbeatTime - monotonicNow(); }
boolean isBlockReportDue() { return nextBlockReportTime - monotonicNow() <= 0; }
long getHeartbeatWaitTime() { return nextHeartbeatTime - monotonicNow(); }
private Scheduler makeMockScheduler(long now) { LOG.info("Using now = " + now); Scheduler mockScheduler = spy(new Scheduler(HEARTBEAT_INTERVAL_MS, BLOCK_REPORT_INTERVAL_MS)); doReturn(now).when(mockScheduler).monotonicNow(); mockScheduler.nextBlockReportTime = now; mockScheduler.nextHeartbeatTime = now; return mockScheduler; }
boolean isBlockReportDue() { return nextBlockReportTime - monotonicNow() <= 0; }
long scheduleHeartbeat() { nextHeartbeatTime = monotonicNow(); return nextHeartbeatTime; }
long scheduleHeartbeat() { nextHeartbeatTime = monotonicNow(); return nextHeartbeatTime; }
long scheduleNextHeartbeat() { // Numerical overflow is possible here and is okay. nextHeartbeatTime = monotonicNow() + heartbeatIntervalMs; return nextHeartbeatTime; }
long scheduleNextHeartbeat() { // Numerical overflow is possible here and is okay. nextHeartbeatTime = monotonicNow() + heartbeatIntervalMs; return nextHeartbeatTime; }
try { DataNodeFaultInjector.get().startOfferService(); final long startTime = scheduler.monotonicNow(); dn.getMetrics().addHeartbeat(scheduler.monotonicNow() - startTime); scheduler.monotonicNow() - startTime);
long getLifelineWaitTime() { return nextLifelineTime - monotonicNow(); }
long getLastBlockReportTime() { return (monotonicNow() - lastBlockReportTime)/1000; }
void scheduleNextOutlierReport() { nextOutliersReportTime = monotonicNow() + outliersReportIntervalMs; }
long scheduleNextHeartbeat() { // Numerical overflow is possible here and is okay. nextHeartbeatTime = monotonicNow() + heartbeatIntervalMs; scheduleNextLifeline(nextHeartbeatTime); return nextHeartbeatTime; }
long getLastHearbeatTime() { return (monotonicNow() - lastHeartbeatTime)/1000; }
long scheduleHeartbeat() { nextHeartbeatTime = monotonicNow(); scheduleNextLifeline(nextHeartbeatTime); return nextHeartbeatTime; }
long getHeartbeatWaitTime() { return nextHeartbeatTime - monotonicNow(); }