Search in sources :

Example 6 with HAServiceStatus

use of org.apache.hadoop.ha.HAServiceStatus 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 7 with HAServiceStatus

use of org.apache.hadoop.ha.HAServiceStatus 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)

Example 8 with HAServiceStatus

use of org.apache.hadoop.ha.HAServiceStatus in project cdap by caskdata.

the class AbstractHDFSStats method getHAWebURL.

@Nullable
private URL getHAWebURL() throws IOException {
    String activeNamenode = null;
    String nameService = getNameService();
    HdfsConfiguration hdfsConf = new HdfsConfiguration(conf);
    String nameNodePrincipal = conf.get(DFSConfigKeys.DFS_NAMENODE_USER_NAME_KEY, "");
    hdfsConf.set(CommonConfigurationKeys.HADOOP_SECURITY_SERVICE_USER_NAME_KEY, nameNodePrincipal);
    for (String nnId : DFSUtil.getNameNodeIds(conf, nameService)) {
        HAServiceTarget haServiceTarget = new NNHAServiceTarget(hdfsConf, nameService, nnId);
        HAServiceProtocol proxy = haServiceTarget.getProxy(hdfsConf, 10000);
        HAServiceStatus serviceStatus = proxy.getServiceStatus();
        if (HAServiceProtocol.HAServiceState.ACTIVE != serviceStatus.getState()) {
            continue;
        }
        activeNamenode = DFSUtil.getNamenodeServiceAddr(hdfsConf, nameService, nnId);
    }
    if (activeNamenode == null) {
        throw new IllegalStateException("Could not find an active namenode");
    }
    return rpcToHttpAddress(URI.create(activeNamenode));
}
Also used : HAServiceProtocol(org.apache.hadoop.ha.HAServiceProtocol) NNHAServiceTarget(org.apache.hadoop.hdfs.tools.NNHAServiceTarget) HAServiceStatus(org.apache.hadoop.ha.HAServiceStatus) NNHAServiceTarget(org.apache.hadoop.hdfs.tools.NNHAServiceTarget) HAServiceTarget(org.apache.hadoop.ha.HAServiceTarget) HdfsConfiguration(org.apache.hadoop.hdfs.HdfsConfiguration) Nullable(javax.annotation.Nullable)

Aggregations

HAServiceStatus (org.apache.hadoop.ha.HAServiceStatus)8 HAServiceProtocol (org.apache.hadoop.ha.HAServiceProtocol)3 ServiceException (com.google.protobuf.ServiceException)2 IOException (java.io.IOException)2 HAServiceTarget (org.apache.hadoop.ha.HAServiceTarget)2 GetServiceStatusResponseProto (org.apache.hadoop.ha.proto.HAServiceProtocolProtos.GetServiceStatusResponseProto)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 ConnectException (java.net.ConnectException)1 InetSocketAddress (java.net.InetSocketAddress)1 Nullable (javax.annotation.Nullable)1 Configuration (org.apache.hadoop.conf.Configuration)1 HAServiceState (org.apache.hadoop.ha.HAServiceProtocol.HAServiceState)1 ServiceFailedException (org.apache.hadoop.ha.ServiceFailedException)1 HAServiceStateProto (org.apache.hadoop.ha.proto.HAServiceProtocolProtos.HAServiceStateProto)1 HdfsConfiguration (org.apache.hadoop.hdfs.HdfsConfiguration)1 NNHAServiceTarget (org.apache.hadoop.hdfs.tools.NNHAServiceTarget)1 RMHAServiceTarget (org.apache.hadoop.yarn.client.RMHAServiceTarget)1 ResourceManagerAdministrationProtocol (org.apache.hadoop.yarn.server.api.ResourceManagerAdministrationProtocol)1