Search in sources :

Example 1 with GetServiceStatusResponseProto

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;
}
Also used : ServiceException(com.google.protobuf.ServiceException) HAServiceStatus(org.apache.hadoop.ha.HAServiceStatus) GetServiceStatusResponseProto(org.apache.hadoop.ha.proto.HAServiceProtocolProtos.GetServiceStatusResponseProto)

Example 2 with GetServiceStatusResponseProto

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();
}
Also used : ServiceException(com.google.protobuf.ServiceException) HAServiceStatus(org.apache.hadoop.ha.HAServiceStatus) IOException(java.io.IOException) GetServiceStatusResponseProto(org.apache.hadoop.ha.proto.HAServiceProtocolProtos.GetServiceStatusResponseProto) HAServiceStateProto(org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceStateProto)

Aggregations

ServiceException (com.google.protobuf.ServiceException)2 HAServiceStatus (org.apache.hadoop.ha.HAServiceStatus)2 GetServiceStatusResponseProto (org.apache.hadoop.ha.proto.HAServiceProtocolProtos.GetServiceStatusResponseProto)2 IOException (java.io.IOException)1 HAServiceStateProto (org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceStateProto)1