HBASE-20670 NPE in HMaster#isInMaintenanceMode

This commit is contained in:
Andrew Purtell 2018-06-01 15:22:18 -07:00
parent 3673e54a40
commit d7b09de854
3 changed files with 27 additions and 7 deletions

View File

@ -2822,7 +2822,10 @@ public class HMaster extends HRegionServer implements MasterServices {
* @return true if master is in maintenanceMode
*/
@Override
public boolean isInMaintenanceMode() {
public boolean isInMaintenanceMode() throws IOException {
if (!isInitialized()) {
throw new PleaseHoldException("Master is initializing");
}
return maintenanceModeTracker.isInMaintenanceMode();
}
@ -3359,9 +3362,13 @@ public class HMaster extends HRegionServer implements MasterServices {
* @return The state of the load balancer, or false if the load balancer isn't defined.
*/
public boolean isBalancerOn() {
try {
if (null == loadBalancerTracker || isInMaintenanceMode()) {
return false;
}
} catch (IOException e) {
return false;
}
return loadBalancerTracker.isBalancerOn();
}
@ -3370,8 +3377,12 @@ public class HMaster extends HRegionServer implements MasterServices {
* false is returned.
*/
public boolean isNormalizerOn() {
try {
return (null == regionNormalizerTracker || isInMaintenanceMode()) ?
false: regionNormalizerTracker.isNormalizerOn();
} catch (IOException e) {
return false;
}
}
/**
@ -3382,9 +3393,13 @@ public class HMaster extends HRegionServer implements MasterServices {
*/
@Override
public boolean isSplitOrMergeEnabled(MasterSwitchType switchType) {
try {
if (null == splitOrMergeTracker || isInMaintenanceMode()) {
return false;
}
} catch (IOException e) {
return false;
}
return splitOrMergeTracker.isSplitOrMergeEnabled(switchType);
}

View File

@ -1489,7 +1489,11 @@ public class MasterRpcServices extends RSRpcServices
final RpcController controller,
final IsInMaintenanceModeRequest request) throws ServiceException {
IsInMaintenanceModeResponse.Builder response = IsInMaintenanceModeResponse.newBuilder();
try {
response.setInMaintenanceMode(master.isInMaintenanceMode());
} catch (IOException e) {
throw new ServiceException(e);
}
return response.build();
}

View File

@ -352,8 +352,9 @@ public interface MasterServices extends Server {
/**
* @return true if master is in maintanceMode
* @throws IOException if the inquiry failed due to an IO problem
*/
boolean isInMaintenanceMode();
boolean isInMaintenanceMode() throws IOException;
/**
* Abort a procedure.