From 6b2437de2ccc19fa383442f81b9096c81b2c8bb5 Mon Sep 17 00:00:00 2001 From: jxiang Date: Fri, 14 Mar 2014 03:02:21 +0000 Subject: [PATCH] HBASE-10739 RS web UI NPE if master shuts down sooner git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1577415 13f79535-47bb-0310-9956-ffa450edef68 --- .../tmpl/master/BackupMasterStatusTmpl.jamon | 2 +- .../tmpl/regionserver/RSStatusTmpl.jamon | 10 +++++++--- .../apache/hadoop/hbase/master/HMaster.java | 12 +++++------ .../hbase/regionserver/HRegionServer.java | 18 ++++++++--------- .../hbase/regionserver/RSStatusServlet.java | 3 +-- .../apache/hadoop/hbase/TestZooKeeper.java | 2 +- .../hbase/master/TestMasterStatusServlet.java | 2 +- .../hbase/master/TestSplitLogManager.java | 2 +- ...ger.java => TestMasterAddressTracker.java} | 20 +++++++++---------- .../regionserver/TestRSStatusServlet.java | 2 +- 10 files changed, 38 insertions(+), 35 deletions(-) rename hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/{TestMasterAddressManager.java => TestMasterAddressTracker.java} (88%) diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon index d4a5408d9ac..e6c86136cea 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/BackupMasterStatusTmpl.jamon @@ -32,7 +32,7 @@ if (master.isActiveMaster()) { ClusterStatus status = master.getClusterStatus(); masters = status.getBackupMasters(); } else{ - ServerName sn = master.getMasterAddressManager().getMasterAddress(); + ServerName sn = master.getMasterAddressTracker().getMasterAddress(); assert sn != null : "Failed to retreive master's ServerName!"; masters = Collections.singletonList(sn); } diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon index bd51662f284..1efb0b011e5 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RSStatusTmpl.jamon @@ -24,13 +24,12 @@ String format = "html"; <%import> java.util.*; org.apache.hadoop.hbase.regionserver.HRegionServer; -org.apache.hadoop.hbase.util.Bytes; org.apache.hadoop.hbase.HRegionInfo; org.apache.hadoop.hbase.ServerName; org.apache.hadoop.hbase.HBaseConfiguration; org.apache.hadoop.hbase.protobuf.ProtobufUtil; org.apache.hadoop.hbase.protobuf.generated.AdminProtos.ServerInfo; -org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad; +org.apache.hadoop.hbase.zookeeper.MasterAddressTracker; <%if format.equals("json") %> <& ../common/TaskMonitorTmpl; filter = filter; format = "json" &> @@ -41,6 +40,9 @@ org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad; ServerName serverName = ProtobufUtil.toServerName(serverInfo.getServerName()); List onlineRegions = ProtobufUtil.getOnlineRegions(regionServer); int masterInfoPort = regionServer.getConfiguration().getInt("hbase.master.info.port", 16010); + MasterAddressTracker masterAddressTracker = regionServer.getMasterAddressTracker(); + ServerName masterServerName = masterAddressTracker == null ? null + : masterAddressTracker.getMasterAddress();