List of usage examples for org.apache.hadoop.hdfs.server.protocol ReceivedDeletedBlockInfo ReceivedDeletedBlockInfo
public ReceivedDeletedBlockInfo(Block blk, BlockStatus status, String delHints)
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;//w w w. ja v a 2s . co m 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; }