List of usage examples for org.apache.hadoop.hdfs.protocol BlockListAsLongs getNumberOfBlocks
abstract public int getNumberOfBlocks();
From source file:common.DataNode.java
License:Apache License
/** * Report the list blocks to the Namenode * @throws IOException//from ww w .j a va2s . 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; }
From source file:common.NameNode.java
License:Apache License
public DatanodeCommand blockReport(DatanodeRegistration nodeReg, long[] blocks) throws IOException { verifyRequest(nodeReg);// ww w. jav a2 s.co m BlockListAsLongs blist = new BlockListAsLongs(blocks); stateChangeLog.debug("*BLOCK* NameNode.blockReport: " + "from " + nodeReg.getName() + " " + blist.getNumberOfBlocks() + " blocks"); namesystem.processReport(nodeReg, blist); if (getFSImage().isUpgradeFinalized()) return DatanodeCommand.FINALIZE; return null; }