use of org.apache.hadoop.ha.proto.HAServiceProtocolProtos.GetServiceStatusResponseProto in project hadoop by apache.
the class HAServiceProtocolClientSideTranslatorPB method getServiceStatus.
@Override
public HAServiceStatus getServiceStatus() throws IOException {
GetServiceStatusResponseProto status;
try {
status = rpcProxy.getServiceStatus(NULL_CONTROLLER, GET_SERVICE_STATUS_REQ);
} catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e);
}
HAServiceStatus ret = new HAServiceStatus(convert(status.getState()));
if (status.getReadyToBecomeActive()) {
ret.setReadyToBecomeActive();
} else {
ret.setNotReadyToBecomeActive(status.getNotReadyReason());
}
return ret;
}
use of org.apache.hadoop.ha.proto.HAServiceProtocolProtos.GetServiceStatusResponseProto in project hadoop by apache.
the class HAServiceProtocolServerSideTranslatorPB method getServiceStatus.
@Override
public GetServiceStatusResponseProto getServiceStatus(RpcController controller, GetServiceStatusRequestProto request) throws ServiceException {
HAServiceStatus s;
try {
s = server.getServiceStatus();
} catch (IOException e) {
throw new ServiceException(e);
}
HAServiceStateProto retState;
switch(s.getState()) {
case ACTIVE:
retState = HAServiceStateProto.ACTIVE;
break;
case STANDBY:
retState = HAServiceStateProto.STANDBY;
break;
case INITIALIZING:
default:
retState = HAServiceStateProto.INITIALIZING;
break;
}
GetServiceStatusResponseProto.Builder ret = GetServiceStatusResponseProto.newBuilder().setState(retState).setReadyToBecomeActive(s.isReadyToBecomeActive());
if (!s.isReadyToBecomeActive()) {
ret.setNotReadyReason(s.getNotReadyReason());
}
return ret.build();
}
Aggregations