public static void main(String[] argv) {
    Configuration conf = new YarnConfiguration();
    Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
    StringUtils.startupShutdownMessage(Router.class, argv, LOG);
    Router router = new Router();
    try {
      GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
      argv = hParser.getRemainingArgs();
      if (argv.length > 1) {
        executeRouterCommand(conf, argv);
      } else {
        // Remove the old hook if we are rebooting.
        if (null != routerShutdownHook) {
          ShutdownHookManager.get().removeShutdownHook(routerShutdownHook);
        }
        routerShutdownHook = new CompositeServiceShutdownHook(router);
        ShutdownHookManager.get().addShutdownHook(routerShutdownHook, SHUTDOWN_HOOK_PRIORITY);
        router.init(conf);
        router.start();
      }
    } catch (Throwable t) {
      LOG.error("Error starting Router", t);
      System.exit(-1);
    }
  }
@Test
  public void testRouterCLI() {
    ByteArrayOutputStream dataOut = new ByteArrayOutputStream();
    ByteArrayOutputStream dataErr = new ByteArrayOutputStream();
    System.setOut(new PrintStream(dataOut));
    System.setErr(new PrintStream(dataErr));
    Router.main(new String[]{"-help", "-format-state-store"});
    assertTrue(dataErr.toString().contains(
        "Usage: yarn router [-format-state-store] | " +
        "[-remove-application-from-state-store <appId>]"));
  }