List of usage examples for org.apache.hadoop.hdfs.server.protocol DatanodeProtocol blockReceivedAndDeleted
@Idempotent public void blockReceivedAndDeleted(DatanodeRegistration registration, String poolId, StorageReceivedDeletedBlocks[] rcvdAndDeletedBlocks) throws IOException;
From source file:io.hops.experiments.benchmarks.blockreporting.TinyDatanodes.java
License:Apache License
private ExtendedBlock addBlocks(ClientProtocol nameNodeProto, DatanodeProtocol datanodeProto, String fileName, String clientName) throws IOException, SQLException { ExtendedBlock prevBlock = null;// www .j av a 2 s .c om for (int jdx = 0; jdx < blocksPerFile; jdx++) { LocatedBlock loc = null; try { loc = nameNodeProto.addBlock(fileName, clientName, prevBlock, helper.getExcludedDatanodes()); prevBlock = loc.getBlock(); for (DatanodeInfo dnInfo : loc.getLocations()) { int dnIdx = Arrays.binarySearch(datanodes, dnInfo.getXferAddr()); datanodes[dnIdx].addBlock(loc.getBlock().getLocalBlock()); ReceivedDeletedBlockInfo[] rdBlocks = { new ReceivedDeletedBlockInfo(loc.getBlock().getLocalBlock(), ReceivedDeletedBlockInfo.BlockStatus.RECEIVED_BLOCK, null) }; StorageReceivedDeletedBlocks[] report = { new StorageReceivedDeletedBlocks( datanodes[dnIdx].dnRegistration.getStorageID(), rdBlocks) }; datanodeProto.blockReceivedAndDeleted(datanodes[dnIdx].dnRegistration, loc.getBlock().getBlockPoolId(), report); } } catch (IndexOutOfBoundsException e) { System.out.println(e); System.out.println("Located block " + Arrays.toString(loc.getLocations())); System.out.println("Excluded Nodes are " + Arrays.toString(helper.getExcludedDatanodes())); } } return prevBlock; }