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 687710eb28
commit c3a7f2f3bb
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();