码迷,mamicode.com
首页 > 其他好文 > 详细

启动NameNode报NullPointerException

时间:2015-04-29 02:01:31      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:hadoop

在Hadoop版本0.20.10.21.0 存在一个bug,NameNode同步失败,current产生了一个edits.new,和fsimage同步时又出现异常,而SecondNameNode也产生了同样的目录结构和数据,并报如下异常:


Our secondary name node is not able to start on NullPointerException:
ERROR org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode: java.lang.NullPointerException
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.unprotectedSetTimes(FSDirectory.java:1232)
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.unprotectedSetTimes(FSDirectory.java:1221)
at org.apache.hadoop.hdfs.server.namenode.FSEditLog.loadFSEdits(FSEditLog.java:776)
at org.apache.hadoop.hdfs.server.namenode.FSImage.loadFSEdits(FSImage.java:992)
at
org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode$CheckpointStorage.doMerge(SecondaryNameNode.java:590)
at
org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode$CheckpointStorage.access$000(SecondaryNameNode.java:473)
at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.doMerge(SecondaryNameNode.java:350)
at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.doCheckpoint(SecondaryNameNode.java:314)
at org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode.run(SecondaryNameNode.java:225)
at java.lang.Thread.run(Thread.java:619)

This was caused by setting access time on a non-existent file.


修改Hadoop源码:

Index: src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java
===================================================================
--- src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java	(revision 823221)
+++ src/hdfs/org/apache/hadoop/hdfs/server/namenode/FSDirectory.java	(working copy)
@@ -33,6 +33,7 @@
 import org.apache.hadoop.hdfs.protocol.QuotaExceededException;
 import org.apache.hadoop.hdfs.server.common.HdfsConstants.StartupOption;
 import org.apache.hadoop.hdfs.server.namenode.BlocksMap.BlockInfo;
+import org.mortbay.log.Log;
 
 /*************************************************
  * FSDirectory stores the filesystem directory state.
@@ -1218,6 +1219,11 @@
   boolean unprotectedSetTimes(String src, long mtime, long atime, boolean force) 
                               throws IOException {
     INodeFile inode = getFileINode(src);
+    if (inode == null) {
+      NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedSetTimes: "
+          +"failed to setTimes " + src + " because source does not exist");
+      return false;
+    }
     return unprotectedSetTimes(src, inode, mtime, atime, force);
   }



启动NameNode报NullPointerException

标签:hadoop

原文地址:http://blog.csdn.net/u012841509/article/details/45354389

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!