Search in sources :

Example 6 with HAServiceState

use of org.apache.hadoop.ha.HAServiceProtocol.HAServiceState in project hadoop by apache.

the class PBHelper method convert.

public static NamespaceInfoProto convert(NamespaceInfo info) {
    NamespaceInfoProto.Builder builder = NamespaceInfoProto.newBuilder();
    builder.setBlockPoolID(info.getBlockPoolID()).setBuildVersion(info.getBuildVersion()).setUnused(0).setStorageInfo(PBHelper.convert((StorageInfo) info)).setSoftwareVersion(info.getSoftwareVersion()).setCapabilities(info.getCapabilities());
    HAServiceState state = info.getState();
    if (state != null) {
        builder.setState(convert(info.getState()));
    }
    return builder.build();
}
Also used : StorageInfo(org.apache.hadoop.hdfs.server.common.StorageInfo) HAServiceState(org.apache.hadoop.ha.HAServiceProtocol.HAServiceState) NamespaceInfoProto(org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.NamespaceInfoProto)

Example 7 with HAServiceState

use of org.apache.hadoop.ha.HAServiceProtocol.HAServiceState in project hadoop by apache.

the class RMHAUtils method findActiveRMHAId.

public static String findActiveRMHAId(YarnConfiguration conf) {
    YarnConfiguration yarnConf = new YarnConfiguration(conf);
    Collection<String> rmIds = yarnConf.getStringCollection(YarnConfiguration.RM_HA_IDS);
    for (String currentId : rmIds) {
        yarnConf.set(YarnConfiguration.RM_HA_ID, currentId);
        try {
            HAServiceState haState = getHAState(yarnConf);
            if (haState.equals(HAServiceState.ACTIVE)) {
                return currentId;
            }
        } catch (Exception e) {
        // Couldn't check if this RM is active. Do nothing. Worst case,
        // we wouldn't find an Active RM and return null.
        }
    }
    // Couldn't find an Active RM
    return null;
}
Also used : YarnConfiguration(org.apache.hadoop.yarn.conf.YarnConfiguration) HAServiceState(org.apache.hadoop.ha.HAServiceProtocol.HAServiceState)

Aggregations

HAServiceState (org.apache.hadoop.ha.HAServiceProtocol.HAServiceState)7 IOException (java.io.IOException)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 InstanceSpec (org.apache.curator.test.InstanceSpec)1 HAServiceProtocol (org.apache.hadoop.ha.HAServiceProtocol)1 HAServiceStatus (org.apache.hadoop.ha.HAServiceStatus)1 HAServiceTarget (org.apache.hadoop.ha.HAServiceTarget)1 ServiceFailedException (org.apache.hadoop.ha.ServiceFailedException)1 NamespaceInfoProto (org.apache.hadoop.hdfs.protocol.proto.HdfsServerProtos.NamespaceInfoProto)1 StorageInfo (org.apache.hadoop.hdfs.server.common.StorageInfo)1 RMHAServiceTarget (org.apache.hadoop.yarn.client.RMHAServiceTarget)1 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)1 ZooKeeper (org.apache.zookeeper.ZooKeeper)1 Test (org.junit.Test)1