final LocatedBlocks locations = np.getBlockLocations(path, offset, 1); final int count = locations.locatedBlockCount(); if (count > 0) {
@Override public LocatedBlocks answer(InvocationOnMock invocation) throws IOException { Object args[] = invocation.getArguments(); LocatedBlocks realAnswer = realNN.getBlockLocations( (String)args[0], (Long)args[1], (Long)args[2]); if (failuresLeft-- > 0) { NameNode.LOG.info("FailNTimesAnswer injecting failure."); return makeBadBlockList(realAnswer); } NameNode.LOG.info("FailNTimesAnswer no longer failing."); return realAnswer; }
private ArrayList<Block> prepareForRide(final Path filePath, final String METHOD_NAME, long fileSize) throws IOException { LOG.info("Running test " + METHOD_NAME); DFSTestUtil.createFile(fs, filePath, fileSize, REPL_FACTOR, rand.nextLong()); return locatedToBlocks(cluster.getNameNodeRpc() .getBlockLocations(filePath.toString(), FILE_START, fileSize).getLocatedBlocks(), null); }
/** Test assumes that the file has a single block */ private File getBlockForFile(Path path, boolean exists) throws IOException { LocatedBlocks blocks = nn.getRpcServer().getBlockLocations(path.toString(), 0, Long.MAX_VALUE); assertEquals("The test helper functions assume that each file has a single block", 1, blocks.getLocatedBlocks().size()); ExtendedBlock block = blocks.getLocatedBlocks().get(0).getBlock(); BlockLocalPathInfo bInfo = dn0.getFSDataset().getBlockLocalPathInfo(block); File blockFile = new File(bInfo.getBlockPath()); assertEquals(exists, blockFile.exists()); return blockFile; }
private Block findBlock(Path path, long size) throws IOException { Block ret; List<LocatedBlock> lbs = cluster.getNameNodeRpc() .getBlockLocations(path.toString(), FILE_START, size).getLocatedBlocks(); LocatedBlock lb = lbs.get(lbs.size() - 1); // Get block from the first DN ret = cluster.getDataNodes().get(DN_N0). data.getStoredBlock(lb.getBlock() .getBlockPoolId(), lb.getBlock().getBlockId()); return ret; }
private int getBlockCount(LocatedBlock ret) throws IOException { LocatedBlocks lb = cluster.getNameNodeRpc().getBlockLocations(src, 0, Long.MAX_VALUE); assertEquals(lb.getLastLocatedBlock().getBlock(), ret.getBlock()); return lb.getLocatedBlocks().size(); }
cluster.getNameNode().getRpcServer().getBlockLocations( TEST_FILE, 0, TEST_FILE_LEN).getLocatedBlocks(); LocatedBlock lblock = locatedBlocks.get(0); // first block
final LocatedBlocks lb = namenode.getBlockLocations(src, 0, len); final List<LocatedBlock> blocks = lb.getLocatedBlocks(); assertEquals(i, blocks.size());
nn.getBlockLocations(path, 0, size).getLocatedBlocks();
/** * go to each block on the 2nd DataNode until it fails... * @param path * @param size * @throws IOException */ private void triggerFailure(String path, long size) throws IOException { NamenodeProtocols nn = cluster.getNameNodeRpc(); List<LocatedBlock> locatedBlocks = nn.getBlockLocations(path, 0, size).getLocatedBlocks(); for (LocatedBlock lb : locatedBlocks) { DatanodeInfo dinfo = lb.getLocations()[1]; ExtendedBlock b = lb.getBlock(); try { accessBlock(dinfo, lb); } catch (IOException e) { System.out.println("Failure triggered, on block: " + b.getBlockId() + "; corresponding volume should be removed by now"); break; } } }
LocatedBlocks locatedBlocks = cluster.getNameNodeRpc().getBlockLocations( fileName, 0, 1000); while (locatedBlocks.getLastLocatedBlock() == null) { Thread.sleep(100); locatedBlocks = cluster.getNameNodeRpc().getBlockLocations(fileName, 0, 1000);
LocatedBlocks locations = cluster.getNameNodeRpc().getBlockLocations( file.toString(), 0, count); ExtendedBlock block = locations.get(0).getBlock();
((DFSOutputStream) ofs.getWrappedStream()).hflush(); List<LocatedBlock> lb = cluster.getNameNodeRpc().getBlockLocations( filePath.toString(), FILE_SIZE - 1, FILE_SIZE).getLocatedBlocks();
ExtendedBlock block = cluster.getNameNode().getRpcServer().getBlockLocations( TEST_PATH, 0, Long.MAX_VALUE).get(0).getBlock(); String fadvisedFileName = cluster.getBlockFile(0, block).getName();
ExtendedBlock block = cluster.getNameNode().getRpcServer().getBlockLocations( TEST_PATH, 0, Long.MAX_VALUE).get(0).getBlock(); String fadvisedFileName = cluster.getBlockFile(0, block).getName();
DFSTestUtil.createFile(fs, new Path("/tmp/x"), 16, (short) 1, 23); LocatedBlocks lb = cluster.getNameNode().getRpcServer() .getBlockLocations("/tmp/x", 0, 16);
ExtendedBlock block = cluster.getNameNode().getRpcServer().getBlockLocations( TEST_PATH, 0, Long.MAX_VALUE).get(0).getBlock(); String fadvisedFileName = cluster.getBlockFile(0, block).getName();
assertTrue("Penultimate block must be complete", checkFileProgress(src, false)); LocatedBlocks lbs = nn.getBlockLocations(src, 0, Long.MAX_VALUE); assertEquals("Must be one block", 1, lbs.getLocatedBlocks().size()); LocatedBlock lb2 = lbs.get(0); lbs = nn.getBlockLocations(src, 0, Long.MAX_VALUE); assertEquals("Must be one block", 1, lbs.getLocatedBlocks().size()); LocatedBlock lb1 = lbs.get(0);
ExtendedBlock block = cluster.getNameNode().getRpcServer().getBlockLocations( TEST_PATH, 0, Long.MAX_VALUE).get(0).getBlock(); String fadvisedFileName = cluster.getBlockFile(0, block).getName();
.getBlockLocations(path.toString(), 0, 1).get(0); proxy = DFSUtil.createClientDatanodeProtocolProxy( lb.getLocations()[0], conf, 60000, false); .getBlockLocations(path.toString(), 0, 1).get(0); final long newGS = lb.getBlock().getGenerationStamp(); Assert.assertTrue(newGS > originalGS);