/** Adjusts curr and prev number of blocks scheduled every few minutes. */ private void rollBlocksScheduled(long now) { if (now - lastBlocksScheduledRollTime > BLOCKS_SCHEDULED_ROLL_INTERVAL) { prevApproxBlocksScheduled.set(currApproxBlocksScheduled); currApproxBlocksScheduled.reset(); lastBlocksScheduledRollTime = now; } }
/** Decrement the number of blocks scheduled. */ void decrementBlocksScheduled(StorageType t) { if (prevApproxBlocksScheduled.get(t) > 0) { prevApproxBlocksScheduled.subtract(t, 1); } else if (currApproxBlocksScheduled.get(t) > 0) { currApproxBlocksScheduled.subtract(t, 1); } // its ok if both counters are zero. }
/** @return Approximate number of blocks currently scheduled to be written to this datanode. */ public int getBlocksScheduled() { return (int) (currApproxBlocksScheduled.sum() + prevApproxBlocksScheduled.sum()); }
/** Increment the number of blocks scheduled. */ void incrementBlocksScheduled(StorageType t) { currApproxBlocksScheduled.add(t, 1); ; }
/** * @return Approximate number of blocks currently scheduled to be written to the given storage * type of this datanode. */ public int getBlocksScheduled(StorageType t) { return (int) (currApproxBlocksScheduled.get(t) + prevApproxBlocksScheduled.get(t)); }