Example usage for org.apache.hadoop.hdfs.server.protocol BlocksWithLocations getBlocks

List of usage examples for org.apache.hadoop.hdfs.server.protocol BlocksWithLocations getBlocks

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.server.protocol BlocksWithLocations getBlocks.

Prototype

public BlockWithLocations[] getBlocks() 

Source Link

Document

getter

Usage

From source file:com.sun.grid.herd.HerdLoadSensor.java

License:Open Source License

public void doMeasurement() {
    try {/*www  .j a  v a 2 s.  c  o m*/
        rackName = node.getNetworkLocation();

        BlocksWithLocations blocks = namenode.getBlocks(node, Long.MAX_VALUE);

        List<Long> blockIds = new ArrayList<Long>(100);

        for (BlocksWithLocations.BlockWithLocations block : blocks.getBlocks()) {
            blockIds.add(block.getBlock().getBlockId());
        }

        blockStrings = buildBlockStrings(blockIds);

        log.fine("Rack is " + rackName);
        log.fine("Blocks are: " + blockStrings);
    } catch (IOException e) {
        log.warning("load sensor threw I/O exception while communicating with namenode: " + e.getMessage());
    }
}