/// <summary>Checks whether a block is sufficiently replicated for decommissioning.</summary> /// <remarks> /// Checks whether a block is sufficiently replicated for decommissioning. /// Full-strength replication is not always necessary, hence "sufficient". /// </remarks> /// <returns>true if sufficient, else false.</returns> private bool IsSufficientlyReplicated(BlockInfoContiguous block, BlockCollection bc, NumberReplicas numberReplicas) { int numExpected = bc.GetBlockReplication(); int numLive = numberReplicas.LiveReplicas(); if (!blockManager.IsNeededReplication(block, numExpected, numLive)) { // Block doesn't need replication. Skip. Log.Trace("Block {} does not need replication.", block); return(true); } // Block is under-replicated Log.Trace("Block {} numExpected={}, numLive={}", block, numExpected, numLive); if (numExpected > numLive) { if (bc.IsUnderConstruction() && block.Equals(bc.GetLastBlock())) { // Can decom a UC block as long as there will still be minReplicas if (numLive >= blockManager.minReplication) { Log.Trace("UC block {} sufficiently-replicated since numLive ({}) " + ">= minR ({})" , block, numLive, blockManager.minReplication); return(true); } else { Log.Trace("UC block {} insufficiently-replicated since numLive " + "({}) < minR ({})" , block, numLive, blockManager.minReplication); } } else { // Can decom a non-UC as long as the default replication is met if (numLive >= blockManager.defaultReplication) { return(true); } } } return(false); }