hadoop 之源码 ResourceManager
来源:互联网 发布:淘宝助理怎么同步手机 编辑:程序博客网 时间:2024/04/29 17:09
hadoop
RM
/** * The ResourceManager is the main class that is a set of components. * "I am the ResourceManager. All your resources belong to us..." * */@SuppressWarnings("unchecked")public class ResourceManager extends CompositeService implements Recoverable {
源码中关于ResourceManager的注释只有寥寥几句。大概意思就是管理集群所有的资源。
仔细看了下ResourceManager的方法列表,瞅到一mian()方法。
public static void main(String argv[]) { Thread.setDefaultUncaughtExceptionHandler(new YarnUncaughtExceptionHandler()); StringUtils.startupShutdownMessage(ResourceManager.class, argv, LOG); try { Configuration conf = new YarnConfiguration(); // If -format-state-store, then delete RMStateStore; else startup normally if (argv.length == 1 && argv[0].equals("-format-state-store")) { deleteRMStateStore(conf); } 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); } }
这里有一关键点,ResourceManager在启动时,首先调用父类init()方法,然后调用start().
这里面有必要说明下继承关系ResourceManager 继承了 CompositeService,CompositeService继承了AbstractService抽象类。
这里使用了模板方法。AbstractService类中定义了init(),start(),stop(),close()等方法的实现,这里就不一一列举其源码的实现了。
在init方法中分别调用了 setConfig 、serviceInit 和notifyListeners三个方法。ResourceManager复写了serviceInit(Configuration conf)方法。
这个方法主要做以下几件事情;
- 加载core-site.xml 并 refresh SuperUserGroupsConfiguration
- 加载yarn-site.xml 并验证配置文件
- 设置HA配置
用户登录
// Set UGI and do login// If security is enabled, use login user// If security is not enabled, use current userthis.rmLoginUGI = UserGroupInformation.getCurrentUser();try { doSecureLogin();} catch(IOException ie) { throw new YarnRuntimeException("Failed to login", ie);}
各种服务的注册(来回翻了下,没有注释,实在不知道是干嘛用的)
下面看看 serviceStart()做了些什么。
protected void serviceStart() throws Exception { if (this.rmContext.isHAEnabled()) { transitionToStandby(true); } else { transitionToActive(); } startWepApp(); if (getConfig().getBoolean(YarnConfiguration.IS_MINI_YARN_CLUSTER, false)) { int port = webApp.port(); WebAppUtils.setRMWebAppPort(conf, port); } super.serviceStart();}
- 首先设置下HAServiceState
/** * An HA service may be in active or standby state. During startup, it is in * an unknown INITIALIZING state. During shutdown, it is in the STOPPING state * and can no longer return to active/standby states. */public enum HAServiceState { INITIALIZING("initializing"), ACTIVE("active"), STANDBY("standby"), STOPPING("stopping");
- 启动webAPP
以上就是ResourceManager启动过程。
这里插一段,hadoop中service的生命周期
/** Constructed but not initialized */NOTINITED(0, "NOTINITED"),/** Initialized but not started or stopped */INITED(1, "INITED"),/** started and not stopped */STARTED(2, "STARTED"),/** stopped. No further state transitions are permitted */STOPPED(3, "STOPPED");
未完待续……
0 0
- hadoop 之源码 ResourceManager
- velocity源码分析:初始化之ResourceManager
- 研磨Hadoop源码(五)ResourceManager启动分析1
- 研磨Hadoop源码(六)ResourceManager启动分析2
- 研磨Hadoop源码(五)ResourceManager启动分析1
- 研磨Hadoop源码(六)ResourceManager启动分析2
- Hadoop-2.4.1学习之ResourceManager重启
- Hadoop-2.4.1学习之高可用ResourceManager
- hadoop集群之YARN`s ResourceManager HA(三)
- Hadoop -YARN ResourceManager 剖析
- Apache Hadoop YARN – ResourceManager
- Apache Hadoop YARN – ResourceManager
- Hadoop 2.0 ResourceManager HA原理
- Apache Hadoop YARN – ResourceManager
- Hadoop: Connecting to ResourceManager failed
- Yarn之ResourceManager资源管理
- YARN源码分析(三)-----ResourceManager HA之应用状态存储与恢复
- YARN源码分析(三)-----ResourceManager HA之应用状态存储与恢复
- hadoop之 mapreduce Combiner
- hadoop 之源码 job
- hadoop之 HDFS读写 java interface
- 河南省第四届ACM程序设计大赛 问题 G: BOBSLEDDING
- hadoop之 hdfs FilePattern
- hadoop 之源码 ResourceManager
- Exercise: Linear Regression
- 第十三周项目2-动物这样叫——1
- hadoop之 HDFS 数据I/O(一)
- hadoop之 yarn (简单了解)
- Android Studio使用CSDN Git 记要
- OkHttp
- spring <context:annotation-config> 跟 <context:component-scan>诠释及区别
- spark on yarn 配置