/** Remove the specified number of blocks to be invalidated */
 public Block[] getInvalidateBlocks(int maxblocks) {
   synchronized (invalidateBlocks) {
     Block[] deleteList =
         invalidateBlocks.pollToArray(new Block[Math.min(invalidateBlocks.size(), maxblocks)]);
     return deleteList.length == 0 ? null : deleteList;
   }
 }
Example #2
0
  /** Print the contents to out. */
  synchronized void dump(final PrintWriter out) {
    final int size = node2blocks.values().size();
    out.println("Metasave: Blocks " + numBlocks + " waiting deletion from " + size + " datanodes.");
    if (size == 0) {
      return;
    }

    for (Map.Entry<DatanodeInfo, LightWeightHashSet<Block>> entry : node2blocks.entrySet()) {
      final LightWeightHashSet<Block> blocks = entry.getValue();
      if (blocks.size() > 0) {
        out.println(entry.getKey());
        out.println(blocks);
      }
    }
  }
 @Override
 public String dumpDatanode() {
   StringBuilder sb = new StringBuilder(super.dumpDatanode());
   int repl = replicateBlocks.size();
   if (repl > 0) {
     sb.append(" ").append(repl).append(" blocks to be replicated;");
   }
   int inval = invalidateBlocks.size();
   if (inval > 0) {
     sb.append(" ").append(inval).append(" blocks to be invalidated;");
   }
   int recover = recoverBlocks.size();
   if (recover > 0) {
     sb.append(" ").append(recover).append(" blocks to be recovered;");
   }
   return sb.toString();
 }
Example #4
0
 /** Remove a storage from the invalidatesSet */
 synchronized void remove(final DatanodeInfo dn) {
   final LightWeightHashSet<Block> blocks = node2blocks.remove(dn);
   if (blocks != null) {
     numBlocks -= blocks.size();
   }
 }
 /** The number of block invalidation items that are pending to be sent to the datanode */
 int getNumberOfBlocksToBeInvalidated() {
   synchronized (invalidateBlocks) {
     return invalidateBlocks.size();
   }
 }