/** 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 the given storage * type of this datanode. */ public int getBlocksScheduled(StorageType t) { return (int) (currApproxBlocksScheduled.get(t) + prevApproxBlocksScheduled.get(t)); }