hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jxi...@apache.org
Subject git commit: HBASE-11880 NPE in MasterStatusServlet
Date Tue, 02 Sep 2014 21:58:57 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 1143dba61 -> 2a60b2a80


HBASE-11880 NPE in MasterStatusServlet


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/2a60b2a8
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/2a60b2a8
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/2a60b2a8

Branch: refs/heads/branch-1
Commit: 2a60b2a806a0003065ad1db9957ffc1bd63e5369
Parents: 1143dba
Author: Jimmy Xiang <jxiang@cloudera.com>
Authored: Tue Sep 2 12:07:19 2014 -0700
Committer: Jimmy Xiang <jxiang@cloudera.com>
Committed: Tue Sep 2 14:57:05 2014 -0700

----------------------------------------------------------------------
 .../main/java/org/apache/hadoop/hbase/master/HMaster.java    | 8 ++++++--
 .../org/apache/hadoop/hbase/master/MasterStatusServlet.java  | 7 +++----
 .../org/apache/hadoop/hbase/regionserver/HRegionServer.java  | 8 ++++++--
 3 files changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/2a60b2a8/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
index c4de9a5..cf2c30b 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/HMaster.java
@@ -483,8 +483,12 @@ public class HMaster extends HRegionServer implements MasterServices,
Server {
     ZKClusterId.setClusterId(this.zooKeeper, fileSystemManager.getClusterId());
     this.serverManager = createServerManager(this, this);
 
-    metaTableLocator = new MetaTableLocator();
-    shortCircuitConnection = createShortCircuitConnection();
+    synchronized (this) {
+      if (shortCircuitConnection == null) {
+        shortCircuitConnection = createShortCircuitConnection();
+        metaTableLocator = new MetaTableLocator();
+      }
+    }
 
     // Invalidate all write locks held previously
     this.tableLockManager.reapWriteLocks();

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a60b2a8/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
index 75def7b..3059096 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/master/MasterStatusServlet.java
@@ -27,8 +27,6 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.ServerName;
@@ -43,7 +41,6 @@ import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
  */
 @InterfaceAudience.Private
 public class MasterStatusServlet extends HttpServlet {
-  private static final Log LOG = LogFactory.getLog(MasterStatusServlet.class);
   private static final long serialVersionUID = 1L;
 
   @Override
@@ -88,7 +85,9 @@ public class MasterStatusServlet extends HttpServlet {
   }
 
   private ServerName getMetaLocationOrNull(HMaster master) {
-    return master.getMetaTableLocator().getMetaRegionLocation(master.getZooKeeper());
+    MetaTableLocator metaTableLocator = master.getMetaTableLocator();
+    return metaTableLocator == null ? null :
+      metaTableLocator.getMetaRegionLocation(master.getZooKeeper());
   }
 
   private Map<String, Integer> getFragmentationInfo(

http://git-wip-us.apache.org/repos/asf/hbase/blob/2a60b2a8/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 94d19d9..32ff083 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -636,8 +636,12 @@ public class HRegionServer extends HasThread implements
       this.abort("Failed to retrieve Cluster ID",e);
     }
 
-    shortCircuitConnection = createShortCircuitConnection();
-    metaTableLocator = new MetaTableLocator();
+    synchronized (this) {
+      if (shortCircuitConnection == null) {
+        shortCircuitConnection = createShortCircuitConnection();
+        metaTableLocator = new MetaTableLocator();
+      }
+    }
 
     // watch for snapshots and other procedures
     try {


Mime
View raw message