Search in sources :

Example 1 with HAServiceStateProto

use of org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceStateProto 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)1 IOException (java.io.IOException)1 HAServiceStatus (org.apache.hadoop.ha.HAServiceStatus)1 GetServiceStatusResponseProto (org.apache.hadoop.ha.proto.HAServiceProtocolProtos.GetServiceStatusResponseProto)1 HAServiceStateProto (org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceStateProto)1