/// <summary>How many copies of this block is pending replication?</summary>
 internal virtual int GetNumReplicas(Block block)
 {
     lock (pendingReplications)
     {
         PendingReplicationBlocks.PendingBlockInfo found = pendingReplications[block];
         if (found != null)
         {
             return(found.GetNumReplicas());
         }
     }
     return(0);
 }
 /// <summary>One replication request for this block has finished.</summary>
 /// <remarks>
 /// One replication request for this block has finished.
 /// Decrement the number of pending replication requests
 /// for this block.
 /// </remarks>
 /// <param name="The">DataNode that finishes the replication</param>
 internal virtual void Decrement(Block block, DatanodeDescriptor dn)
 {
     lock (pendingReplications)
     {
         PendingReplicationBlocks.PendingBlockInfo found = pendingReplications[block];
         if (found != null)
         {
             if (Log.IsDebugEnabled())
             {
                 Log.Debug("Removing pending replication for " + block);
             }
             found.DecrementReplicas(dn);
             if (found.GetNumReplicas() <= 0)
             {
                 Sharpen.Collections.Remove(pendingReplications, block);
             }
         }
     }
 }
 /// <summary>Iterate through all items and print them.</summary>
 internal virtual void MetaSave(PrintWriter @out)
 {
     lock (pendingReplications)
     {
         @out.WriteLine("Metasave: Blocks being replicated: " + pendingReplications.Count);
         IEnumerator <KeyValuePair <Block, PendingReplicationBlocks.PendingBlockInfo> > iter =
             pendingReplications.GetEnumerator();
         while (iter.HasNext())
         {
             KeyValuePair <Block, PendingReplicationBlocks.PendingBlockInfo> entry = iter.Next(
                 );
             PendingReplicationBlocks.PendingBlockInfo pendingBlock = entry.Value;
             Block block = entry.Key;
             @out.WriteLine(block + " StartTime: " + Sharpen.Extensions.CreateDate(pendingBlock
                                                                                   .timeStamp) + " NumReplicaInProgress: " + pendingBlock.GetNumReplicas());
         }
     }
 }