Example usage for org.apache.hadoop.hdfs.protocol BlockListAsLongs getBlockListAsLongs

List of usage examples for org.apache.hadoop.hdfs.protocol BlockListAsLongs getBlockListAsLongs

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs.protocol BlockListAsLongs getBlockListAsLongs.

Prototype

abstract public long[] getBlockListAsLongs();

Source Link

Document

Convert block report to old-style list of longs.

Usage

From source file:common.DataNode.java

License:Apache License

/**
 * Report the list blocks to the Namenode
 * @throws IOException// www.j  a v a  2 s .  co  m
 */
private DatanodeCommand blockReport() throws IOException {
    // send block report
    DatanodeCommand cmd = null;
    long startTime = now();
    if (startTime - lastBlockReport > blockReportInterval) {
        //
        // Send latest block report if timer has expired.
        // Get back a list of local block(s) that are obsolete
        // and can be safely GC'ed.
        //
        long brStartTime = now();
        BlockListAsLongs bReport = data.getBlockReport();

        cmd = namenode.blockReport(dnRegistration, bReport.getBlockListAsLongs());
        long brTime = now() - brStartTime;
        myMetrics.blockReports.inc(brTime);
        LOG.info("BlockReport of " + bReport.getNumberOfBlocks() + " blocks got processed in " + brTime
                + " msecs");
        //
        // If we have sent the first block report, then wait a random
        // time before we start the periodic block reports.
        //
        if (resetBlockReportTime) {
            lastBlockReport = startTime - R.nextInt((int) (blockReportInterval));
            resetBlockReportTime = false;
        } else {
            /* say the last block report was at 8:20:14. The current report
             * should have started around 9:20:14 (default 1 hour interval).
             * If current time is :
             *   1) normal like 9:20:18, next report should be at 10:20:14
             *   2) unexpected like 11:35:43, next report should be at 12:20:14
             */
            lastBlockReport += (now() - lastBlockReport) / blockReportInterval * blockReportInterval;
        }
    }
    return cmd;
}