DFSTestUtil.getAllBlocks(fs.open(filePath));
raFile.close(); String datanodeId0 = dn0.getDatanodeUuid(); LocatedBlock lb = DFSTestUtil.getAllBlocks(fs, filePath).get(0); String storageId = lb.getStorageIDs()[0]; cluster.startDataNodes(conf, 1, true, null, null);
DFSTestUtil.createFile( fs, path, IO_SIZE, BLOCK_SIZE * 10, BLOCK_SIZE, REPLICATION, SEED); List<LocatedBlock> blocks = DFSTestUtil.getAllBlocks(fs, path); LOG.info("Block0 id is " + blocks.get(0).getBlock().getBlockId()); long nextBlockExpectedId = blocks.get(0).getBlock().getBlockId() + 1;
DFSTestUtil.getAllBlocks(fs.open(filePath));
try { in = fileSys.open(file); firstBlock = DFSTestUtil.getAllBlocks(in).get(0).getBlock(); } finally { IOUtils.closeStream(in);
DFSTestUtil.getAllBlocks(fs, testFile).get(1).getBlock(); FsVolumeSpi volumeWithBlock = dn.getFSDataset().getVolume(block); String basePath = volumeWithBlock.getBasePath();
util.waitReplication(dfs, path, repFactor); StringBuilder sb = new StringBuilder(); for (LocatedBlock lb: util.getAllBlocks(dfs, path)){ sb.append(lb.getBlock().getLocalBlock().getBlockName()+" ");
util.waitReplication(dfs, path, REPL_FACTOR); StringBuilder sb = new StringBuilder(); for (LocatedBlock lb: util.getAllBlocks(dfs, path)){ sb.append(lb.getBlock().getLocalBlock().getBlockName()+" ");
fs, path1, IO_SIZE, BLOCK_SIZE * blockCount, BLOCK_SIZE, REPLICATION, SEED); List<LocatedBlock> blocks1 = DFSTestUtil.getAllBlocks(fs, path1); fs, path2, IO_SIZE, BLOCK_SIZE * blockCount, BLOCK_SIZE, REPLICATION, SEED); List<LocatedBlock> blocks2 = DFSTestUtil.getAllBlocks(fs, path2); assertThat(blocks2.size(), is(blockCount));
assertEquals("There are active threads still referencing volume: " + volume.getBasePath(), 0, volume.getReferenceCount()); LocatedBlock lb = DFSTestUtil.getAllBlocks(fs, filePath).get(0); DatanodeInfo info = lb.getLocations()[0];
List<LocatedBlock> blocks = DFSTestUtil.getAllBlocks(in); LocatedBlock lb = blocks.get(0); DFSTestUtil.waitForReplication(cluster, lb.getBlock(), 1, 2, 0); blocks = DFSTestUtil.getAllBlocks(in); DatanodeInfo[] locations = null; for (LocatedBlock locatedBlock : blocks) {
@Test public void testEncryptedAppendRequiringBlockTransfer() throws IOException { setEncryptionConfigKeys(); // start up 4 DNs cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build(); fs = getFileSystem(conf); // Create a file with replication 3, so its block is on 3 / 4 DNs. writeTestDataToFile(fs); assertEquals(PLAIN_TEXT, DFSTestUtil.readFile(fs, TEST_PATH)); // Shut down one of the DNs holding a block replica. FSDataInputStream in = fs.open(TEST_PATH); List<LocatedBlock> locatedBlocks = DFSTestUtil.getAllBlocks(in); in.close(); assertEquals(1, locatedBlocks.size()); assertEquals(3, locatedBlocks.get(0).getLocations().length); DataNode dn = cluster.getDataNode( locatedBlocks.get(0).getLocations()[0].getIpcPort()); dn.shutdown(); // Reopen the file for append, which will need to add another DN to the // pipeline and in doing so trigger a block transfer. writeTestDataToFile(fs); assertEquals(PLAIN_TEXT + PLAIN_TEXT, DFSTestUtil.readFile(fs, TEST_PATH)); }
out.hsync(); List<LocatedBlock> blocks = DFSTestUtil.getAllBlocks(fs.open(path)); final LocatedBlock block = blocks.get(0); final DataNode dataNode = cluster.getDataNodes().get(0);
out.hflush(); FSDataInputStream in = fileSys.open(file1); firstBlock = DFSTestUtil.getAllBlocks(in).get(0).getBlock(); firstBlock.setNumBytes(2L); out.hflush(); in = fileSys.open(file); firstBlock = DFSTestUtil.getAllBlocks(in).get(0).getBlock(); firstBlock.setNumBytes(2L); newGS = firstBlock.getGenerationStamp() + 1;
util.waitReplication(dfs, path, REPL_FACTOR); StringBuilder sb = new StringBuilder(); for (LocatedBlock lb: util.getAllBlocks(dfs, path)){ sb.append(lb.getBlock().getLocalBlock().getBlockName()+" ");
try { in = fs.open(file); oldBlock = DFSTestUtil.getAllBlocks(in).get(0).getBlock(); } finally { IOUtils.closeStream(in);
try { in = fileSys.open(file); firstBlock = DFSTestUtil.getAllBlocks(in).get(0).getBlock(); } finally { IOUtils.closeStream(in);
try { in = fs.open(file); oldLoactedBlock = DFSTestUtil.getAllBlocks(in).get(0); oldBlock = oldLoactedBlock.getBlock(); } finally {
List<LocatedBlock> lblocks = DFSTestUtil.getAllBlocks(in1); for (LocatedBlock blk : lblocks) { assertTrue(SecurityTestUtil.isBlockTokenExpired(blk.getBlockToken())); List<LocatedBlock> lblocks2 = DFSTestUtil.getAllBlocks(in2); for (LocatedBlock blk : lblocks2) { assertTrue(SecurityTestUtil.isBlockTokenExpired(blk.getBlockToken())); List<LocatedBlock> lblocks3 = DFSTestUtil.getAllBlocks(in3); for (LocatedBlock blk : lblocks3) { assertTrue(SecurityTestUtil.isBlockTokenExpired(blk.getBlockToken())); lblocks = DFSTestUtil.getAllBlocks(in1); for (LocatedBlock blk : lblocks) { assertFalse(SecurityTestUtil.isBlockTokenExpired(blk.getBlockToken())); lblocks2 = DFSTestUtil.getAllBlocks(in2); for (LocatedBlock blk : lblocks2) { assertFalse(SecurityTestUtil.isBlockTokenExpired(blk.getBlockToken())); lblocks3 = DFSTestUtil.getAllBlocks(in3); for (LocatedBlock blk : lblocks3) { assertFalse(SecurityTestUtil.isBlockTokenExpired(blk.getBlockToken()));
out.hflush(); FSDataInputStream in = fileSys.open(file1); firstBlock = DFSTestUtil.getAllBlocks(in).get(0).getBlock(); firstBlock.setNumBytes(2L); out.hflush(); in = fileSys.open(file); firstBlock = DFSTestUtil.getAllBlocks(in).get(0).getBlock(); firstBlock.setNumBytes(2L); newGS = firstBlock.getGenerationStamp() + 1;