KeyProviderCryptoExtension keyProvider = miniDFSCluster.getNameNode(0).getNamesystem().getProvider(); if (keyProvider != null) { try {
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.getNameNode() .getBlockLocations(filePath.toString(), FILE_START, fileSize).getLocatedBlocks(), null); }
private Block findBlock(Path path, long size) throws IOException { Block ret; List<LocatedBlock> lbs = cluster.getNameNode().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().getBlockId()); return ret; }
Suite(MiniDFSCluster cluster, final int nNameNodes, final int nDataNodes, Configuration conf) throws IOException { this.conf = conf; this.cluster = cluster; clients = new ClientProtocol[nNameNodes]; for(int i = 0; i < nNameNodes; i++) { clients[i] = cluster.getNameNode(i).getRpcServer(); } replication = (short)Math.max(1, nDataNodes - 1); } }
/** * Gets the started NameNode. May be null. */ public NameNode getNameNode() { checkSingleNameNode(); return getNameNode(0); }
Suite(MiniDFSCluster cluster, final int nNameNodes, final int nDataNodes) throws IOException { this.cluster = cluster; clients = new ClientProtocol[nNameNodes]; for(int i = 0; i < nNameNodes; i++) { clients[i] = cluster.getNameNode(i).getRpcServer(); } replication = (short)Math.max(1, nDataNodes - 1); }
/** * Get an instance of the NameNode's RPC handler. */ public NamenodeProtocols getNameNodeRpc(int nnIndex) { return getNameNode(nnIndex).getRpcServer(); }
@Override public Boolean get() { return ( cluster.getNameNode(0).getNamesystem().getCorruptReplicaBlocks() > 0); } }, 100, 5000);
private void addCrmThreads(MiniDFSCluster cluster, LinkedList<Thread> crmThreads) { for (int nn = 0; nn <= 1; nn++) { Thread thread = cluster.getNameNode(nn).getNamesystem(). getCacheManager().getCacheReplicationMonitor(); if (thread != null) { crmThreads.add(thread); } } }
private void restartActive() throws IOException { cluster.shutdownNameNode(0); // Set the safemode extension to be lengthy, so that the tests // can check the safemode message after the safemode conditions // have been achieved, without being racy. cluster.getConfiguration(0).setInt( DFSConfigKeys.DFS_NAMENODE_SAFEMODE_EXTENSION_KEY, 30000); cluster.restartNameNode(0); nn0 = cluster.getNameNode(0); }
public static void dumpTree(String message, MiniDFSCluster cluster ) throws UnresolvedLinkException { System.out.println("XXX " + message); cluster.getNameNode().getNamesystem().getFSDirectory().getINode("/" ).dumpTreeRecursively(System.out); } }
private void startCluster() throws IOException { conf = new HdfsConfiguration(); conf.setInt("dfs.blocksize", 1024*1024); cluster = new Builder(conf).numDataNodes(REPL_FACTOR).build(); cluster.waitActive(); fs = cluster.getFileSystem(); nn = cluster.getNameNode(0); assertNotNull(nn); dn0 = cluster.getDataNodes().get(0); assertNotNull(dn0); blockPoolId = cluster.getNameNode(0).getNamesystem().getBlockPoolId(); }
@Test public void testTryFailoverToSafeMode() throws Exception { conf.set(DFSConfigKeys.DFS_HA_FENCE_METHODS_KEY, TestDFSHAAdmin.getFencerTrueCommand()); tool.setConf(conf); NameNodeAdapter.enterSafeMode(cluster.getNameNode(0), false); assertEquals(-1, runTool("-failover", "nn2", "nn1")); assertTrue("Bad output: " + errOutput, errOutput.contains("is not ready to become active: " + "The NameNode is in safemode")); }
private void setProvider() { // Need to set the client's KeyProvider to the NN's for JKS, // else the updates do not get flushed properly fs.getClient().setKeyProvider(cluster.getNameNode().getNamesystem() .getProvider()); }
@Before public void startCluster() throws IOException { conf = new HdfsConfiguration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(DN_COUNT).build(); singletonNn = cluster.getNameNode(); singletonDn = cluster.getDataNodes().get(0); bpos = singletonDn.getAllBpOs()[0]; actor = bpos.getBPServiceActors().get(0); storageUuid = singletonDn.getFSDataset().getVolumes().get(0).getStorageID(); }
private void createAKey(String keyName, Configuration conf) throws NoSuchAlgorithmException, IOException { final KeyProvider provider = dfsCluster.getNameNode().getNamesystem().getProvider(); final KeyProvider.Options options = KeyProvider.options(conf); provider.createKey(keyName, options); provider.flush(); }
private int getBlockCount() { Assert.assertNotNull("Null cluster", mc); Assert.assertNotNull("No Namenode in cluster", mc.getNameNode()); FSNamesystem namesystem = mc.getNamesystem(); Assert.assertNotNull("Null Namesystem in cluster", namesystem); Assert.assertNotNull("Null Namesystem.blockmanager", namesystem.getBlockManager()); return (int) namesystem.getBlocksTotal(); }
@Test public void testSingleFailedEditsDirOnFlush() throws IOException { assertTrue(doAnEdit()); // Invalidate one edits journal. invalidateEditsDirAtIndex(0, true, false); // The NN has not terminated (no ExitException thrown) assertTrue(doAnEdit()); // A single journal failure should not result in a call to terminate assertFalse(cluster.getNameNode().isInSafeMode()); }
@Test public void testSingleFailedEditsDirOnSetReadyToFlush() throws IOException { assertTrue(doAnEdit()); // Invalidate one edits journal. invalidateEditsDirAtIndex(0, false, false); // The NN has not terminated (no ExitException thrown) assertTrue(doAnEdit()); // A single journal failure should not result in a call to terminate assertFalse(cluster.getNameNode().isInSafeMode()); }
@Test public void testGetServiceState() throws Exception { assertEquals(0, runTool("-getServiceState", "nn1")); assertEquals(0, runTool("-getServiceState", "nn2")); cluster.transitionToActive(0); assertEquals(0, runTool("-getServiceState", "nn1")); NameNodeAdapter.enterSafeMode(cluster.getNameNode(0), false); assertEquals(0, runTool("-getServiceState", "nn1")); }