/** * main() has some simple utility methods. * @param argv Command line parameters. * @exception Exception if the filesystem does not exist. */ public static void main(String[] argv) throws Exception { int res = ToolRunner.run(new DFSAdmin(), argv); System.exit(res); } }
/** * main() has some simple utility methods. * @param argv Command line parameters. * @exception Exception if the filesystem does not exist. */ public static void main(String[] argv) throws Exception { int res = ToolRunner.run(new DFSAdmin(), argv); System.exit(res); } }
/** * main() has some simple utility methods. * @param argv Command line parameters. * @exception Exception if the filesystem does not exist. */ public static void main(String[] argv) throws Exception { int res = ToolRunner.run(new DFSAdmin(), argv); System.exit(res); } }
/** * main() has some simple utility methods. * @param argv Command line parameters. * @exception Exception if the filesystem does not exist. */ public static void main(String[] argv) throws Exception { int res = ToolRunner.run(new DFSAdmin(), argv); System.exit(res); } }
/** * main() has some simple utility methods. * @param argv Command line parameters. * @exception Exception if the filesystem does not exist. */ public static void main(String[] argv) throws Exception { int res = ToolRunner.run(new DFSAdmin(), argv); System.exit(res); } }
/** * If the NameNode is running, attempt to finalize a previous upgrade. * When this method return, the NameNode should be finalized, but * DataNodes may not be since that occurs asynchronously. * * @throws IllegalStateException if the Namenode is not running. */ public void finalizeCluster(Configuration conf) throws Exception { if (nameNode == null) { throw new IllegalStateException("Attempting to finalize " + "Namenode but it is not running"); } ToolRunner.run(new DFSAdmin(conf), new String[] {"-finalizeUpgrade"}); }
private void refreshPolicy(Configuration conf) throws IOException { DFSAdmin dfsAdmin = new DFSAdmin(conf); dfsAdmin.refreshServiceAcl(); }
/** * Finalize the namenode. Block pools corresponding to the namenode are * finalized on the datanode. */ private void finalizeNamenode(NameNode nn, Configuration conf) throws Exception { if (nn == null) { throw new IllegalStateException("Attempting to finalize " + "Namenode but it is not running"); } ToolRunner.run(new DFSAdmin(conf), new String[] {"-finalizeUpgrade"}); }
private void expectDfsAdminPrint(String[] args) { try { ToolRunner.run(new DFSAdmin(), args); } catch (Exception ex) { fail("expectDelegationTokenFetcherExit ex error " + ex); } }
public static void DFSAdminRun(String cmd, int retcode, String contain, Configuration conf) throws Exception { DFSAdmin admin = new DFSAdmin(new Configuration(conf)); toolRun(admin, cmd, retcode, contain); }
@Override public CommandExecutor getExecutor(String tag) throws IllegalArgumentException { if (getType() instanceof CLICommandDFSAdmin) return new FSCmdExecutor(tag, new DFSAdmin()); return super.getExecutor(tag); } }
private void runFinalizeCommand(MiniDFSCluster cluster) throws IOException { HATestUtil.setFailoverConfigurations(cluster, conf); new DFSAdmin(conf).finalizeUpgrade(); }
@Test public void testValidIdentifier() throws Exception { DFSAdmin admin = new DFSAdmin(config); String[] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "firstHandler"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should succeed", 0, exitCode); Mockito.verify(firstHandler).handleRefresh("firstHandler", new String[]{}); // Second handler was never called Mockito.verify(secondHandler, Mockito.never()) .handleRefresh(Mockito.anyString(), Mockito.any(String[].class)); }
@Test public void testInvalidCommand() throws Exception { DFSAdmin admin = new DFSAdmin(config); String [] args = new String[]{"-refresh", "nn"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should fail due to bad args", -1, exitCode); }
@Before public void setUp() throws Exception { Configuration conf = new Configuration(); cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build(); cluster.waitActive(); admin = new DFSAdmin(); datanode = cluster.getDataNodes().get(0); }
@Test public void testInvalidIdentifier() throws Exception { DFSAdmin admin = new DFSAdmin(config); String [] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "unregisteredIdentity"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should fail due to no handler registered", -1, exitCode); }
private void startRollingUpgrade() throws Exception { LOG.info("Starting rolling upgrade"); fs.setSafeMode(SafeModeAction.SAFEMODE_ENTER); final DFSAdmin dfsadmin = new DFSAdmin(conf); TestRollingUpgrade.runCmd(dfsadmin, true, "-rollingUpgrade", "prepare"); triggerHeartBeats(); // Ensure datanode rolling upgrade is started assertTrue(dn0.getFSDataset().trashEnabled(blockPoolId)); }
@Test public void testVariableArgs() throws Exception { DFSAdmin admin = new DFSAdmin(config); String[] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "secondHandler", "one"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should return 2", 2, exitCode); exitCode = admin.run(new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "secondHandler", "one", "two"}); assertEquals("DFSAdmin should now return 3", 3, exitCode); Mockito.verify(secondHandler).handleRefresh("secondHandler", new String[]{"one"}); Mockito.verify(secondHandler).handleRefresh("secondHandler", new String[]{"one", "two"}); }
@Test public void testUnregistration() throws Exception { RefreshRegistry.defaultRegistry().unregisterAll("firstHandler"); // And now this should fail DFSAdmin admin = new DFSAdmin(config); String[] args = new String[]{"-refresh", "localhost:" + cluster.getNameNodePort(), "firstHandler"}; int exitCode = admin.run(args); assertEquals("DFSAdmin should return -1", -1, exitCode); }
private void finalizeRollingUpgrade() throws Exception { LOG.info("Finalizing rolling upgrade"); final DFSAdmin dfsadmin = new DFSAdmin(conf); TestRollingUpgrade.runCmd(dfsadmin, true, "-rollingUpgrade", "finalize"); triggerHeartBeats(); // Ensure datanode rolling upgrade is started assertFalse(dn0.getFSDataset().trashEnabled(blockPoolId)); BlockPoolSliceStorage bps = dn0.getStorage().getBPStorage(blockPoolId); assertFalse(bps.trashEnabled()); }