ResourceManager Main方法

 

public static void main(String argv[]) {
  Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler());
  StringUtils.startupShutdownMessage(ResourceManager.class, argv, LOG);
  try {
    Configuration conf = new YarnConfiguration();
    GenericOptionsParser hParser = new GenericOptionsParser(conf, argv);
    argv = hParser.getRemainingArgs();
    // If -format-state-store, then delete RMStateStore; else startup normally
    if (argv.length >= 1) { //先不看这部分处理,直接看else启动
      if (argv[0].equals("-format-state-store")) {
        deleteRMStateStore(conf);
      } else if (argv[0].equals("-remove-application-from-state-store")
          && argv.length == 2) {
        removeApplication(conf, argv[1]);
      } else {
        printUsage(System.err);
      }
   } else {
      ResourceManager resourceManager = new ResourceManager();
      ShutdownHookManager.get().addShutdownHook(
        new CompositeServiceShutdownHook(resourceManager),
        SHUTDOWN_HOOK_PRIORITY);
      resourceManager.init(conf);
      resourceManager.start();
    }
  } catch (Throwable t) {
    LOG.fatal("Error starting ResourceManager", t);
    System.exit(-1);
  }
}

new ResourceManager();

public ResourceManager() {
  super("ResourceManager");//初始化服务名称

}

resourceManager.init(conf);

其中Configuration conf = new YarnConfiguration(); YarnConfiguration继承自Configuration
Configuration初始化实现,默认加载两个配置文件

addDefaultResource("core-default.xml");
addDefaultResource("core-site.xml");

YarnConfiguration初始化,加载Configuration初始化实现

static {
  addDeprecatedKeys();
  Configuration.addDefaultResource(YARN_DEFAULT_CONFIGURATION_FILE);//yarn-default.xml
  Configuration.addDefaultResource(YARN_SITE_CONFIGURATION_FILE);//yarn-site.xml
}


posted @ 2015-08-18 19:11  闫昆  阅读(246)  评论(0编辑  收藏  举报