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

The following examples show how to use org.apache.hadoop.hdfs.util.LightWeightHashSet#size() . 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 6 votes vote down vote up
/** 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);
    }
  }
}
 
Example 2
Source File: InvalidateBlocks.java    From big-c with Apache License 2.0 6 votes vote down vote up
/** 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);
    }
  }
}
 
Example 3
Source File: InvalidateBlocks.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/** 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();
  }
}
 
Example 4
Source File: InvalidateBlocks.java    From big-c with Apache License 2.0 5 votes vote down vote up
/** 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();
  }
}
 
Example 5
Source File: FSDataset.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
* Return a table of blocks being written data
 * @throws IOException 
*/
public Block[] getBlocksBeingWrittenReport(int namespaceId) throws IOException {
  LightWeightHashSet<Block> blockSet = new LightWeightHashSet<Block>();
  volumes.getBlocksBeingWrittenInfo(namespaceId, blockSet);
  Block blockTable[] = new Block[blockSet.size()];
  int i = 0;
    for (Iterator<Block> it = blockSet.iterator(); it.hasNext(); i++) {
  blockTable[i] = it.next();
  }
  return blockTable;
}
 
Example 6
Source File: FSDataset.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Return a table of block data for given namespace
 */
public Block[] getBlockReport(int namespaceId) {
  // getBlockReport doesn't grant the global lock as we believe it is
  // OK to get some inconsistent partial results. The inconsistent
  // information will finally be fixed by the next incremental
  LightWeightHashSet<Block> blockSet = new LightWeightHashSet<Block>();
  volumes.getBlockInfo(namespaceId, blockSet);
  Block blockTable[] = new Block[blockSet.size()];
  int i = 0;
  for (Iterator<Block> it = blockSet.iterator(); it.hasNext(); i++) {
    blockTable[i] = it.next();
  }
  return blockTable;
}