/** * Run a balancer * @param args Command line arguments */ public static void main(String[] args) { if (DFSUtil.parseHelpArgument(args, USAGE, System.out, true)) { System.exit(0); } try { System.exit(ToolRunner.run(new HdfsConfiguration(), new Cli(), args)); } catch (Throwable e) { LOG.error("Exiting balancer due an exception", e); System.exit(-1); } } }
/** * Parse arguments and then run Balancer. * * @param args command specific arguments. * @return exit code. 0 indicates success, non-zero indicates failure. */ @Override public int run(String[] args) { final long startTime = Time.monotonicNow(); final Configuration conf = getConf(); try { checkReplicationPolicyCompatibility(conf); final Collection<URI> namenodes = DFSUtil.getInternalNsRpcUris(conf); return Balancer.run(namenodes, parse(args), conf); } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION.getExitCode(); } catch (InterruptedException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.INTERRUPTED.getExitCode(); } finally { System.out.format("%-24s ", DateFormat.getDateTimeInstance().format(new Date())); System.out.println("Balancing took " + time2Str(Time.monotonicNow() - startTime)); } }
i = processHostList(args, i, "exclude", excludedNodes); b.setExcludedNodes(excludedNodes); } else if ("-include".equalsIgnoreCase(args[i])) { includedNodes = new HashSet<>(); i = processHostList(args, i, "include", includedNodes); b.setIncludedNodes(includedNodes); } else if ("-source".equalsIgnoreCase(args[i])) { Set<String> sourceNodes = new HashSet<>(); i = processHostList(args, i, "source", sourceNodes); b.setSourceNodes(sourceNodes); } else if ("-blockpools".equalsIgnoreCase(args[i])) { "blockpools value is missing: args = " + Arrays.toString(args)); Set<String> blockpools = parseBlockPoolList(args[i]); LOG.info("Balancer will run on the following blockpools: " + blockpools.toString()); "-exclude and -include options cannot be specified together."); } catch(RuntimeException e) { printUsage(System.err); throw e;
"-exclude and -include options cannot be specified together."); } catch(RuntimeException e) { printUsage(System.err); throw e;
"-exclude and -include options cannot be specified together."); } catch(RuntimeException e) { printUsage(System.err); throw e;
"IllegalArgumentException is expected when value is not specified"; try { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) {
final Tool tool = new Cli(); tool.setConf(conf); final int r = tool.run(args.toArray(new String[0])); // start rebalancing
final Tool tool = new Cli(); tool.setConf(conf); int exitCode = tool.run(args); // start balancing
/** * Parse arguments and then run Balancer. * * @param args command specific arguments. * @return exit code. 0 indicates success, non-zero indicates failure. */ @Override public int run(String[] args) { final long startTime = Time.monotonicNow(); final Configuration conf = getConf(); try { checkReplicationPolicyCompatibility(conf); final Collection<URI> namenodes = DFSUtil.getInternalNsRpcUris(conf); return Balancer.run(namenodes, parse(args), conf); } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION.getExitCode(); } catch (InterruptedException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.INTERRUPTED.getExitCode(); } finally { System.out.format("%-24s ", DateFormat.getDateTimeInstance().format(new Date())); System.out.println("Balancing took " + time2Str(Time.monotonicNow() - startTime)); } }
/** * Parse arguments and then run Balancer. * * @param args command specific arguments. * @return exit code. 0 indicates success, non-zero indicates failure. */ @Override public int run(String[] args) { final long startTime = Time.monotonicNow(); final Configuration conf = getConf(); try { checkReplicationPolicyCompatibility(conf); final Collection<URI> namenodes = DFSUtil.getInternalNsRpcUris(conf); return Balancer.run(namenodes, parse(args), conf); } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION.getExitCode(); } catch (InterruptedException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.INTERRUPTED.getExitCode(); } finally { System.out.format("%-24s ", DateFormat.getDateTimeInstance().format(new Date())); System.out.println("Balancing took " + time2Str(Time.monotonicNow() - startTime)); } }
/** * Test parse method in Balancer#Cli class with threshold value out of * boundaries. */ @Test(timeout=100000) public void testBalancerCliParseWithThresholdOutOfBoundaries() { String parameters[] = new String[] { "-threshold", "0" }; String reason = "IllegalArgumentException is expected when threshold value" + " is out of boundary."; try { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { assertEquals("Number out of range: threshold = 0.0", e.getMessage()); } parameters = new String[] { "-threshold", "101" }; try { Balancer.Cli.parse(parameters); fail(reason); } catch (IllegalArgumentException e) { assertEquals("Number out of range: threshold = 101.0", e.getMessage()); } }
/** * Run a balancer * @param args Command line arguments */ public static void main(String[] args) { if (DFSUtil.parseHelpArgument(args, USAGE, System.out, true)) { System.exit(0); } try { System.exit(ToolRunner.run(new HdfsConfiguration(), new Cli(), args)); } catch (Throwable e) { LOG.error("Exiting balancer due an exception", e); System.exit(-1); } } }
/** * Run a balancer * @param args Command line arguments */ public static void main(String[] args) { if (DFSUtil.parseHelpArgument(args, USAGE, System.out, true)) { System.exit(0); } try { System.exit(ToolRunner.run(new HdfsConfiguration(), new Cli(), args)); } catch (Throwable e) { LOG.error("Exiting balancer due an exception", e); System.exit(-1); } } }