NameNode之启动流程分析
NameNode启动流程分析
public staticvoid main(Stringargv[]) throws Exception {
if (DFSUtil.parseHelpArgument(argv, NameNode.USAGE, System.out,true)) {
System.exit(0);
}
try {
StringUtils.startupShutdownMessage(NameNode.class,argv, LOG);
//创建NameNode实例
NameNodenamenode = createNameNode(argv,null);
if (namenode !=null) {
namenode.join();
}
} catch (Throwable e) {
LOG.error("Failed to start namenode.",e);
terminate(1, e);
}
}
调用NameNode方法:
publicstatic NameNode createNameNode(Stringargv[], Configuration conf)
throws IOException {
LOG.info("createNameNode " + Arrays.asList(argv));
//加载HDFS配置文件
if (conf ==null)
conf = new HdfsConfiguration();
//解析传递的参数
StartupOptionstartOpt =parseArguments(argv);
if (startOpt ==null) {
printUsage(System.err);
return null;
}
setStartupOption(conf, startOpt);
//对参数进行判断,然后进行不同处理
switch (startOpt) {
case FORMAT: {
boolean aborted = format(conf, startOpt.getForceFormat(),
startOpt.getInteractiveFormat());
terminate(aborted ? 1 : 0);
return null;// avoidjavac warning
}
case GENCLUSTERID: {
System.err.println("Generating new cluster id:");
System.out.println(NNStorage.newClusterID());
terminate(0);
return null;
}
case FINALIZE: {
System.err.println("Use of the argument '" + StartupOption.FINALIZE +
"' is no longer supported. To finalizean upgrade, start the NN " +
" and then run `hdfs dfsadmin-finalizeUpgrade'");
terminate(1);
return null;// avoidjavac warning
}
case ROLLBACK: {
boolean aborted = doRollback(conf, true);
terminate(aborted ? 1 : 0);
return null;// avoidwarning
}
case BOOTSTRAPSTANDBY: {
StringtoolArgs[] = Arrays.copyOfRange(argv, 1,argv.length);
int rc = BootstrapStandby.run(toolArgs,conf);
terminate(rc);
return null;// avoidwarning
}
case INITIALIZESHAREDEDITS: {
boolean aborted = initializeSharedEdits(conf,
startOpt.getForceFormat(),
startOpt.getInteractiveFormat());
terminate(aborted ? 1 : 0);
return null;// avoidwarning
}
case BACKUP:
case CHECKPOINT: {
NamenodeRolerole = startOpt.toNodeRole();
DefaultMetricsSystem.initialize(role.toString().replace(" ",""));
return new BackupNode(conf,role);
}
case RECOVER: {
NameNode.doRecovery(startOpt,conf);
return null;
}
case METADATAVERSION: {
printMetadataVersion(conf);
terminate(0);
return null;// avoidjavac warning
}
case UPGRADEONLY: {
DefaultMetricsSystem.initialize("NameNode");
new NameNode(conf);
terminate(0);
return null;
}
default: {
DefaultMetricsSystem.initialize("NameNode");
return new NameNode(conf);
}
}
}
参数是format:
从配置文件获取NameNodeNameServicesId
获取所有的NameNode的id
进行初始化工作
>>登陆使用dfs.namenode.kerberos.principal作为用户名,否则使用当前linux的user作为用户。
>>如果当前NameNode角色是NameNode,则启动HttpServer,如果NameNode是backup NameNode或者是CheckPoint NameNode则略过这个步骤
privatevoid startHttpServer(final Configurationconf) throws IOException {
//创建NameNode HttpServer
httpServer =new NameNodeHttpServer(conf,this, getHttpServerBindAddress(conf));
//启动http server
httpServer.start();
httpServer.setStartupProgress(startupProgress);
}
NameNode之启动流程分析相关推荐
- 解析并符号 读取dll_Spring IOC容器之XmlBeanFactory启动流程分析和源码解析
一. 前言 Spring容器主要分为两类BeanFactory和ApplicationContext,后者是基于前者的功能扩展,也就是一个基础容器和一个高级容器的区别.本篇就以BeanFactory基 ...
- Zygote进程启动流程分析
文中的源代码版本为api23 Zygote进程启动流程分析 先说结论,zygote进程启动过程中主要做了下面这些事情: 启动DVM虚拟机 预加载部分资源,如一些通用类.通用资源.共享库等 启动syst ...
- c++builder启动了怎么停止_App 竟然是这样跑起来的 —— Android App/Activity 启动流程分析...
在我的上一篇文章: AJie:按下电源键后竟然发生了这一幕 -- Android 系统启动流程分析zhuanlan.zhihu.com 我们分析了系统在开机以后的一系列行为,其中最后一阶段 AMS( ...
- SpringBoot启动流程分析(四):IoC容器的初始化过程
SpringBoot系列文章简介 SpringBoot源码阅读辅助篇: Spring IoC容器与应用上下文的设计与实现 SpringBoot启动流程源码分析: SpringBoot启动流程分析(一) ...
- Exynos4412 Uboot 移植(二)—— Uboot 启动流程分析
uboot启动流程分析如下: 第一阶段: a -- 设置cpu工作模式为SVC模式 b -- 关闭中断,mmu,cache v -- 关看门狗 d -- 初始化内存,串口 e -- 设置栈 f -- ...
- bootloader启动流程分析
bootloader启动流程分析 1.Bootloader的概念和作用 Bootloader是嵌入式系统的引导加载程序,它是系统上电后运行的第一段程序.在完成对系统的初始化任务之后,它会将Flash中 ...
- MyBatis启动流程分析
目录 MyBatis简单介绍 启动流程分析 简单总结 附录 MyBatis内置别名转换 参考 MyBatis简单介绍 MyBatis是一个持久层框架,使用简单,学习成本较低.可以执行自己手写的SQL语 ...
- springboot中获得app_Spring Boot 应用程序启动流程分析
SpringBoot 有两个关键元素: @SpringBootApplication SpringApplication 以及 run() 方法 SpringApplication 这个类应该算是 S ...
- GEF入门实例_总结_04_Eclipse插件启动流程分析
一.前言 本文承接上一节:GEF入门实例_总结_03_显示菜单和工具栏 注意到app目录下的6个类文件. 这6个文件对RCP应用程序而言非常重要,可能我们现在对这几个文件的理解还是云里雾里,这一节我们 ...
最新文章
- linux下Tomcat开机自动启动!
- 数学表达式解析器简介
- 用上这个Python的Docker正式版镜像,你也能成为容器高玩
- java spring context_java将对象注册到spring context中 | 学步园
- linux命令查看cpu架构,Linux下如何查看CPU信息
- [note]浏览器兼容性(embed标签、字体兼容相关
- 41. First Missing Positive 缺失的第一个正数
- ios UISearchBar搜索框的基本使用
- Python的底气,是从哪儿来的?
- 企业微信2.6.0发布 可与微信用户群聊了
- 关于sql中处理日期的相关函数
- IDEA 2022 CPU占用100%问题解决
- A* operator/(A*, A*)‘ must have an argument of class or enumerated type
- Cocos野兽派 | 如何创造真正的优秀游戏
- PS抠发丝技巧 「选择并遮住…」
- 强化学习实战-使用Q-learning算法解决悬崖问题
- 赞!走心推荐这几个 BAT 大佬的公众号
- 面向开发人员的代码安全指南
- mysql redis缓存配置_SpringMVC + MyBatis + Mysql + Redis(作为二级缓存) 配置
- 华为内部论坛热帖:卷不动了!!!
热门文章
- mysql默认密码是多少_路由器192.168.1.1默认登录密码是多少?
- 华为鸿蒙开机不用广告,华为鸿蒙系统开机无广告:用户好评,友商品牌批评。只因树大招风...
- php 模板继承原理,模板继承体会
- 做系统的U盘如何格式化
- myeclipse需要配置服务器得项目是,【SpringMVC】使用Myeclipse创建SpringMVC项目【超详细教程】...
- oracle mysql 线程数_oracle线程数更改
- android 让dialog保持在最前_Android 面试进阶指南 —— 唠唠任务栈,返回栈和启动模式...
- java判断总共天数_java 判断两个时间相差的天数
- android 仿快递步骤_Android开发-类似物流快递进度效果
- django runserver开启服务(开启外网访问与ipv6访问)