NameNode之启动流程分析
来源:互联网 发布:新开淘宝店铺怎么宣传 编辑:程序博客网 时间:2024/05/18 02:32
NameNode启动流程分析
public staticvoidmain(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[], Configurationconf)
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: {
booleanaborted = format(conf,startOpt.getForceFormat(),
startOpt.getInteractiveFormat());
terminate(aborted ? 1 : 0);
returnnull;// avoidjavac warning
}
case GENCLUSTERID: {
System.err.println("Generating new cluster id:");
System.out.println(NNStorage.newClusterID());
terminate(0);
returnnull;
}
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);
returnnull;// avoidjavac warning
}
case ROLLBACK: {
booleanaborted = doRollback(conf,true);
terminate(aborted ? 1 : 0);
returnnull;// avoidwarning
}
case BOOTSTRAPSTANDBY: {
StringtoolArgs[] = Arrays.copyOfRange(argv, 1,argv.length);
intrc = BootstrapStandby.run(toolArgs,conf);
terminate(rc);
returnnull;// avoidwarning
}
case INITIALIZESHAREDEDITS: {
booleanaborted = initializeSharedEdits(conf,
startOpt.getForceFormat(),
startOpt.getInteractiveFormat());
terminate(aborted ? 1 : 0);
returnnull;// avoidwarning
}
case BACKUP:
case CHECKPOINT: {
NamenodeRolerole =startOpt.toNodeRole();
DefaultMetricsSystem.initialize(role.toString().replace(" ",""));
returnnew BackupNode(conf,role);
}
case RECOVER: {
NameNode.doRecovery(startOpt,conf);
returnnull;
}
case METADATAVERSION: {
printMetadataVersion(conf);
terminate(0);
returnnull;// avoidjavac warning
}
case UPGRADEONLY: {
DefaultMetricsSystem.initialize("NameNode");
new NameNode(conf);
terminate(0);
returnnull;
}
default: {
DefaultMetricsSystem.initialize("NameNode");
returnnew NameNode(conf);
}
}
}
参数是format:
从配置文件获取NameNodeNameServicesId
获取所有的NameNode的id
进行初始化工作
>>登陆使用dfs.namenode.kerberos.principal作为用户名,否则使用当前linux的user作为用户。
>>如果当前NameNode角色是NameNode,则启动HttpServer,如果NameNode是backup NameNode或者是CheckPoint NameNode则略过这个步骤
privatevoidstartHttpServer(final Configurationconf)throws IOException {
//创建NameNode HttpServer
httpServer =new NameNodeHttpServer(conf,this, getHttpServerBindAddress(conf));
//启动http server
httpServer.start();
httpServer.setStartupProgress(startupProgress);
}
- NameNode之启动流程分析
- HDFS2.X源码分析之:NameNode启动流程分析
- HDFS之NameNode的启动过程分析
- Hadoop Namenode以regular方式启动代码流程分析
- hadoop 2.7.3 源码分析(四):namenode启动流程
- hdfs2.6.2源码学习:Day1-NameNode启动流程分析
- Hadoop源码分析之NameNode的启动与停止
- Hadoop源码分析之NameNode的启动与停止(续)
- HDFS之NameNode分析
- Hadoop namenode启动瓶颈分析
- Hadoop namenode启动瓶颈分析
- uboot 分析之 启动流程
- uboot 分析之 启动流程
- uboot 分析之 启动流程
- uboot 分析之 启动流程
- uboot 分析之 启动流程
- NameNode启动中image文件处理流程
- uboot启动流程分析之二
- 【结合实例】信息增益的计算
- StringUtils api 中文 英文 对照
- GMSSL SM9-封装解封装流程
- Qt使用回调函数报错“函数调用缺少参数列表,请使用&xxx创建指向成员的指针”解决办法
- SHELL awk根据单引号切割
- NameNode之启动流程分析
- 04:网线主管
- Pandas初学者代码优化指南
- 第一部分:基础问题 1.5
- 字符串的正则表达式匹配
- 公众号根据openid获取用户信息,php通过openid得到用户详细信息
- 初识Hibernate(三)之查询操作
- 饼状统计图
- 创建者模式之工厂方法模式