HBASE-12399 Master startup race between metrics and RpcServer

This commit is contained in:
Nick Dimiduk 2014-10-31 17:48:09 -07:00
parent 3c06b48181
commit b5764a8e74
1 changed files with 10 additions and 6 deletions

View File

@ -27,9 +27,13 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
this.server = server;
}
private boolean isServerStarted() {
return this.server != null && this.server.isStarted();
}
@Override
public long getTotalQueueSize() {
if (this.server == null) {
if (!isServerStarted()) {
return 0;
}
return server.callQueueSize.get();
@ -37,7 +41,7 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
@Override
public int getGeneralQueueLength() {
if (this.server == null || this.server.getScheduler() == null) {
if (!isServerStarted() || this.server.getScheduler() == null) {
return 0;
}
return server.getScheduler().getGeneralQueueLength();
@ -45,7 +49,7 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
@Override
public int getReplicationQueueLength() {
if (this.server == null || this.server.getScheduler() == null) {
if (!isServerStarted() || this.server.getScheduler() == null) {
return 0;
}
return server.getScheduler().getReplicationQueueLength();
@ -53,7 +57,7 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
@Override
public int getPriorityQueueLength() {
if (this.server == null || this.server.getScheduler() == null) {
if (!isServerStarted() || this.server.getScheduler() == null) {
return 0;
}
return server.getScheduler().getPriorityQueueLength();
@ -61,7 +65,7 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
@Override
public int getNumOpenConnections() {
if (this.server == null || this.server.connectionList == null) {
if (!isServerStarted() || this.server.connectionList == null) {
return 0;
}
return server.connectionList.size();
@ -69,7 +73,7 @@ public class MetricsHBaseServerWrapperImpl implements MetricsHBaseServerWrapper
@Override
public int getActiveRpcHandlerCount() {
if (this.server == null || this.server.getScheduler() == null) {
if (!isServerStarted() || this.server.getScheduler() == null) {
return 0;
}
return server.getScheduler().getActiveRpcHandlerCount();