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;
}
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();
}
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));
}
Aggregations