Java Code Examples for org.apache.hadoop.hdfs.util.LightWeightHashSet#pollN()

The following examples show how to use org.apache.hadoop.hdfs.util.LightWeightHashSet#pollN() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InvalidateBlocks.java    From hadoop with Apache License 2.0 5 votes vote down vote up
synchronized List<Block> invalidateWork(final DatanodeDescriptor dn) {
  final long delay = getInvalidationDelay();
  if (delay > 0) {
    if (BlockManager.LOG.isDebugEnabled()) {
      BlockManager.LOG
          .debug("Block deletion is delayed during NameNode startup. "
                     + "The deletion will start after " + delay + " ms.");
    }
    return null;
  }
  final LightWeightHashSet<Block> set = node2blocks.get(dn);
  if (set == null) {
    return null;
  }

  // # blocks that can be sent in one message is limited
  final int limit = blockInvalidateLimit;
  final List<Block> toInvalidate = set.pollN(limit);

  // If we send everything in this message, remove this node entry
  if (set.isEmpty()) {
    remove(dn);
  }

  dn.addBlocksToBeInvalidated(toInvalidate);
  numBlocks -= toInvalidate.size();
  return toInvalidate;
}
 
Example 2
Source File: InvalidateBlocks.java    From big-c with Apache License 2.0 5 votes vote down vote up
synchronized List<Block> invalidateWork(final DatanodeDescriptor dn) {
  final long delay = getInvalidationDelay();
  if (delay > 0) {
    if (BlockManager.LOG.isDebugEnabled()) {
      BlockManager.LOG
          .debug("Block deletion is delayed during NameNode startup. "
                     + "The deletion will start after " + delay + " ms.");
    }
    return null;
  }
  final LightWeightHashSet<Block> set = node2blocks.get(dn);
  if (set == null) {
    return null;
  }

  // # blocks that can be sent in one message is limited
  final int limit = blockInvalidateLimit;
  final List<Block> toInvalidate = set.pollN(limit);

  // If we send everything in this message, remove this node entry
  if (set.isEmpty()) {
    remove(dn);
  }

  dn.addBlocksToBeInvalidated(toInvalidate);
  numBlocks -= toInvalidate.size();
  return toInvalidate;
}