HBASE-11880 NPE in MasterStatusServlet

This commit is contained in:
Jimmy Xiang 2014-09-02 12:07:19 -07:00
parent 211c1e8ad4
commit 842f4808db
3 changed files with 15 additions and 8 deletions

View File

@ -480,8 +480,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();

View File

@ -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(

View File

@ -637,8 +637,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 {