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
This commit is contained in:
parent
1160171e64
commit
6b2437de2c
|
@ -32,7 +32,7 @@ if (master.isActiveMaster()) {
|
||||||
ClusterStatus status = master.getClusterStatus();
|
ClusterStatus status = master.getClusterStatus();
|
||||||
masters = status.getBackupMasters();
|
masters = status.getBackupMasters();
|
||||||
} else{
|
} else{
|
||||||
ServerName sn = master.getMasterAddressManager().getMasterAddress();
|
ServerName sn = master.getMasterAddressTracker().getMasterAddress();
|
||||||
assert sn != null : "Failed to retreive master's ServerName!";
|
assert sn != null : "Failed to retreive master's ServerName!";
|
||||||
masters = Collections.singletonList(sn);
|
masters = Collections.singletonList(sn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,12 @@ String format = "html";
|
||||||
<%import>
|
<%import>
|
||||||
java.util.*;
|
java.util.*;
|
||||||
org.apache.hadoop.hbase.regionserver.HRegionServer;
|
org.apache.hadoop.hbase.regionserver.HRegionServer;
|
||||||
org.apache.hadoop.hbase.util.Bytes;
|
|
||||||
org.apache.hadoop.hbase.HRegionInfo;
|
org.apache.hadoop.hbase.HRegionInfo;
|
||||||
org.apache.hadoop.hbase.ServerName;
|
org.apache.hadoop.hbase.ServerName;
|
||||||
org.apache.hadoop.hbase.HBaseConfiguration;
|
org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||||
org.apache.hadoop.hbase.protobuf.generated.AdminProtos.ServerInfo;
|
org.apache.hadoop.hbase.protobuf.generated.AdminProtos.ServerInfo;
|
||||||
org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad;
|
org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
|
||||||
</%import>
|
</%import>
|
||||||
<%if format.equals("json") %>
|
<%if format.equals("json") %>
|
||||||
<& ../common/TaskMonitorTmpl; filter = filter; format = "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());
|
ServerName serverName = ProtobufUtil.toServerName(serverInfo.getServerName());
|
||||||
List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(regionServer);
|
List<HRegionInfo> onlineRegions = ProtobufUtil.getOnlineRegions(regionServer);
|
||||||
int masterInfoPort = regionServer.getConfiguration().getInt("hbase.master.info.port", 16010);
|
int masterInfoPort = regionServer.getConfiguration().getInt("hbase.master.info.port", 16010);
|
||||||
|
MasterAddressTracker masterAddressTracker = regionServer.getMasterAddressTracker();
|
||||||
|
ServerName masterServerName = masterAddressTracker == null ? null
|
||||||
|
: masterAddressTracker.getMasterAddress();
|
||||||
</%java>
|
</%java>
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -146,9 +148,11 @@ org.apache.hadoop.hbase.protobuf.generated.ClusterStatusProtos.RegionLoad;
|
||||||
<td>
|
<td>
|
||||||
<%if (masterInfoPort < 0) %>
|
<%if (masterInfoPort < 0) %>
|
||||||
No hbase.master.info.port found
|
No hbase.master.info.port found
|
||||||
|
<%elseif masterServerName == null %>
|
||||||
|
No master found
|
||||||
<%else>
|
<%else>
|
||||||
<%java>
|
<%java>
|
||||||
String host = regionServer.getMasterAddressManager().getMasterAddress().getHostname() + ":" + masterInfoPort;
|
String host = masterServerName.getHostname() + ":" + masterInfoPort;
|
||||||
String url = "//" + host + "/";
|
String url = "//" + host + "/";
|
||||||
</%java>
|
</%java>
|
||||||
<a href="<% url %>"><% host %></a>
|
<a href="<% url %>"><% host %></a>
|
||||||
|
|
|
@ -294,8 +294,8 @@ MasterServices, Server {
|
||||||
private DrainingServerTracker drainingServerTracker;
|
private DrainingServerTracker drainingServerTracker;
|
||||||
// Tracker for load balancer state
|
// Tracker for load balancer state
|
||||||
private LoadBalancerTracker loadBalancerTracker;
|
private LoadBalancerTracker loadBalancerTracker;
|
||||||
// master address manager and watcher
|
// master address tracker
|
||||||
private MasterAddressTracker masterAddressManager;
|
private MasterAddressTracker masterAddressTracker;
|
||||||
|
|
||||||
// RPC server for the HMaster
|
// RPC server for the HMaster
|
||||||
private final RpcServerInterface rpcServer;
|
private final RpcServerInterface rpcServer;
|
||||||
|
@ -586,8 +586,8 @@ MasterServices, Server {
|
||||||
startupStatus.setDescription("Master startup");
|
startupStatus.setDescription("Master startup");
|
||||||
masterStartTime = System.currentTimeMillis();
|
masterStartTime = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
this.masterAddressManager = new MasterAddressTracker(getZooKeeperWatcher(), this);
|
this.masterAddressTracker = new MasterAddressTracker(getZooKeeperWatcher(), this);
|
||||||
this.masterAddressManager.start();
|
this.masterAddressTracker.start();
|
||||||
|
|
||||||
// Put up info server.
|
// Put up info server.
|
||||||
int port = this.conf.getInt("hbase.master.info.port", HConstants.DEFAULT_MASTER_INFOPORT);
|
int port = this.conf.getInt("hbase.master.info.port", HConstants.DEFAULT_MASTER_INFOPORT);
|
||||||
|
@ -1164,8 +1164,8 @@ MasterServices, Server {
|
||||||
return this.activeMasterManager;
|
return this.activeMasterManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MasterAddressTracker getMasterAddressManager() {
|
public MasterAddressTracker getMasterAddressTracker() {
|
||||||
return this.masterAddressManager;
|
return this.masterAddressTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -429,8 +429,8 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
||||||
// zookeeper connection and watcher
|
// zookeeper connection and watcher
|
||||||
private ZooKeeperWatcher zooKeeper;
|
private ZooKeeperWatcher zooKeeper;
|
||||||
|
|
||||||
// master address manager and watcher
|
// master address tracker
|
||||||
private MasterAddressTracker masterAddressManager;
|
private MasterAddressTracker masterAddressTracker;
|
||||||
|
|
||||||
// Cluster Status Tracker
|
// Cluster Status Tracker
|
||||||
private ClusterStatusTracker clusterStatusTracker;
|
private ClusterStatusTracker clusterStatusTracker;
|
||||||
|
@ -723,12 +723,12 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
||||||
this.zooKeeper = new ZooKeeperWatcher(conf, REGIONSERVER + ":" +
|
this.zooKeeper = new ZooKeeperWatcher(conf, REGIONSERVER + ":" +
|
||||||
this.isa.getPort(), this);
|
this.isa.getPort(), this);
|
||||||
|
|
||||||
// Create the master address manager, register with zk, and start it. Then
|
// Create the master address tracker, register with zk, and start it. Then
|
||||||
// block until a master is available. No point in starting up if no master
|
// block until a master is available. No point in starting up if no master
|
||||||
// running.
|
// running.
|
||||||
this.masterAddressManager = new MasterAddressTracker(this.zooKeeper, this);
|
this.masterAddressTracker = new MasterAddressTracker(this.zooKeeper, this);
|
||||||
this.masterAddressManager.start();
|
this.masterAddressTracker.start();
|
||||||
blockAndCheckIfStopped(this.masterAddressManager);
|
blockAndCheckIfStopped(this.masterAddressTracker);
|
||||||
|
|
||||||
// Wait on cluster being up. Master will set this flag up in zookeeper
|
// Wait on cluster being up. Master will set this flag up in zookeeper
|
||||||
// when ready.
|
// when ready.
|
||||||
|
@ -1588,8 +1588,8 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
||||||
/**
|
/**
|
||||||
* @return Master address tracker instance.
|
* @return Master address tracker instance.
|
||||||
*/
|
*/
|
||||||
public MasterAddressTracker getMasterAddressManager() {
|
public MasterAddressTracker getMasterAddressTracker() {
|
||||||
return this.masterAddressManager;
|
return this.masterAddressTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1960,7 +1960,7 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
|
||||||
boolean interrupted = false;
|
boolean interrupted = false;
|
||||||
try {
|
try {
|
||||||
while (keepLooping() && master == null) {
|
while (keepLooping() && master == null) {
|
||||||
sn = this.masterAddressManager.getMasterAddress(refresh);
|
sn = this.masterAddressTracker.getMasterAddress(refresh);
|
||||||
if (sn == null) {
|
if (sn == null) {
|
||||||
if (!keepLooping()) {
|
if (!keepLooping()) {
|
||||||
// give up with no connection.
|
// give up with no connection.
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class RSStatusServlet extends HttpServlet {
|
||||||
tmpl.setFormat(req.getParameter("format"));
|
tmpl.setFormat(req.getParameter("format"));
|
||||||
if (req.getParameter("filter") != null)
|
if (req.getParameter("filter") != null)
|
||||||
tmpl.setFilter(req.getParameter("filter"));
|
tmpl.setFilter(req.getParameter("filter"));
|
||||||
if (hrs != null) tmpl.render(resp.getWriter(), hrs);
|
tmpl.render(resp.getWriter(), hrs);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,7 +388,7 @@ public class TestZooKeeper {
|
||||||
// Assumes the root of the ZooKeeper space is writable as it creates a node
|
// Assumes the root of the ZooKeeper space is writable as it creates a node
|
||||||
// wherever the cluster home is defined.
|
// wherever the cluster home is defined.
|
||||||
ZooKeeperWatcher zk2 = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
ZooKeeperWatcher zk2 = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||||
"testMasterAddressManagerFromZK", null);
|
"testCreateSilentIsReallySilent", null);
|
||||||
|
|
||||||
// Save the previous ACL
|
// Save the previous ACL
|
||||||
Stat s = null;
|
Stat s = null;
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class TestMasterStatusServlet {
|
||||||
|
|
||||||
// Fake MasterAddressTracker
|
// Fake MasterAddressTracker
|
||||||
MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);
|
MasterAddressTracker tracker = Mockito.mock(MasterAddressTracker.class);
|
||||||
Mockito.doReturn(tracker).when(master).getMasterAddressManager();
|
Mockito.doReturn(tracker).when(master).getMasterAddressTracker();
|
||||||
Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();
|
Mockito.doReturn(FAKE_HOST).when(tracker).getMasterAddress();
|
||||||
|
|
||||||
// Mock admin
|
// Mock admin
|
||||||
|
|
|
@ -58,7 +58,7 @@ import org.apache.hadoop.hbase.Stoppable;
|
||||||
import org.apache.hadoop.hbase.Waiter;
|
import org.apache.hadoop.hbase.Waiter;
|
||||||
import org.apache.hadoop.hbase.master.SplitLogManager.Task;
|
import org.apache.hadoop.hbase.master.SplitLogManager.Task;
|
||||||
import org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch;
|
import org.apache.hadoop.hbase.master.SplitLogManager.TaskBatch;
|
||||||
import org.apache.hadoop.hbase.regionserver.TestMasterAddressManager.NodeCreationListener;
|
import org.apache.hadoop.hbase.regionserver.TestMasterAddressTracker.NodeCreationListener;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKSplitLog;
|
import org.apache.hadoop.hbase.zookeeper.ZKSplitLog;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
|
||||||
|
|
|
@ -36,8 +36,8 @@ import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
@Category(MediumTests.class)
|
@Category(MediumTests.class)
|
||||||
public class TestMasterAddressManager {
|
public class TestMasterAddressTracker {
|
||||||
private static final Log LOG = LogFactory.getLog(TestMasterAddressManager.class);
|
private static final Log LOG = LogFactory.getLog(TestMasterAddressTracker.class);
|
||||||
|
|
||||||
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
|
||||||
|
|
||||||
|
@ -56,17 +56,17 @@ public class TestMasterAddressManager {
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testMasterAddressManagerFromZK() throws Exception {
|
public void testMasterAddressTrackerFromZK() throws Exception {
|
||||||
|
|
||||||
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
ZooKeeperWatcher zk = new ZooKeeperWatcher(TEST_UTIL.getConfiguration(),
|
||||||
"testMasterAddressManagerFromZK", null);
|
"testMasterAddressTrackerFromZK", null);
|
||||||
ZKUtil.createAndFailSilent(zk, zk.baseZNode);
|
ZKUtil.createAndFailSilent(zk, zk.baseZNode);
|
||||||
|
|
||||||
// Should not have a master yet
|
// Should not have a master yet
|
||||||
MasterAddressTracker addressManager = new MasterAddressTracker(zk, null);
|
MasterAddressTracker addressTracker = new MasterAddressTracker(zk, null);
|
||||||
addressManager.start();
|
addressTracker.start();
|
||||||
assertFalse(addressManager.hasMaster());
|
assertFalse(addressTracker.hasMaster());
|
||||||
zk.registerListener(addressManager);
|
zk.registerListener(addressTracker);
|
||||||
|
|
||||||
// Use a listener to capture when the node is actually created
|
// Use a listener to capture when the node is actually created
|
||||||
NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
|
NodeCreationListener listener = new NodeCreationListener(zk, zk.getMasterAddressZNode());
|
||||||
|
@ -83,8 +83,8 @@ public class TestMasterAddressManager {
|
||||||
LOG.info("Waiting for master address manager to be notified");
|
LOG.info("Waiting for master address manager to be notified");
|
||||||
listener.waitForCreation();
|
listener.waitForCreation();
|
||||||
LOG.info("Master node created");
|
LOG.info("Master node created");
|
||||||
assertTrue(addressManager.hasMaster());
|
assertTrue(addressTracker.hasMaster());
|
||||||
ServerName pulledAddress = addressManager.getMasterAddress();
|
ServerName pulledAddress = addressTracker.getMasterAddress();
|
||||||
assertTrue(pulledAddress.equals(sn));
|
assertTrue(pulledAddress.equals(sn));
|
||||||
|
|
||||||
}
|
}
|
|
@ -78,7 +78,7 @@ public class TestRSStatusServlet {
|
||||||
// Fake MasterAddressTracker
|
// Fake MasterAddressTracker
|
||||||
MasterAddressTracker mat = Mockito.mock(MasterAddressTracker.class);
|
MasterAddressTracker mat = Mockito.mock(MasterAddressTracker.class);
|
||||||
Mockito.doReturn(fakeMasterAddress).when(mat).getMasterAddress();
|
Mockito.doReturn(fakeMasterAddress).when(mat).getMasterAddress();
|
||||||
Mockito.doReturn(mat).when(rs).getMasterAddressManager();
|
Mockito.doReturn(mat).when(rs).getMasterAddressTracker();
|
||||||
|
|
||||||
MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
|
MetricsRegionServer rms = Mockito.mock(MetricsRegionServer.class);
|
||||||
Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
|
Mockito.doReturn(new MetricsRegionServerWrapperStub()).when(rms).getRegionServerWrapper();
|
||||||
|
|
Loading…
Reference in New Issue