use of org.apache.slider.core.exceptions.SliderException in project hive by apache.
the class LlapStatusServiceDriver method populateAppStatusFromSlider.
/**
*
* @param appName
* @param sliderClient
* @param appStatusBuilder
* @return an ExitCode. An ExitCode other than ExitCode.SUCCESS implies future progress not possible
* @throws LlapStatusCliException
*/
private ExitCode populateAppStatusFromSlider(String appName, SliderClient sliderClient, AppStatusBuilder appStatusBuilder) throws LlapStatusCliException {
ClusterDescription clusterDescription;
try {
clusterDescription = sliderClient.getClusterDescription(appName);
} catch (SliderException e) {
throw new LlapStatusCliException(ExitCode.SLIDER_CLIENT_ERROR_OTHER, "Failed to get cluster description from slider. SliderErrorCode=" + (e).getExitCode(), e);
} catch (Exception e) {
throw new LlapStatusCliException(ExitCode.SLIDER_CLIENT_ERROR_OTHER, "Failed to get cluster description from slider", e);
}
if (clusterDescription == null) {
LOG.info("Slider ClusterDescription not available");
// ClusterDescription should always be present.
return ExitCode.SLIDER_CLIENT_ERROR_OTHER;
} else {
// Process the Cluster Status returned by slider.
appStatusBuilder.setOriginalConfigurationPath(clusterDescription.originConfigurationPath);
appStatusBuilder.setGeneratedConfigurationPath(clusterDescription.generatedConfigurationPath);
appStatusBuilder.setAppStartTime(clusterDescription.createTime);
// Finish populating AMInfo
appStatusBuilder.maybeCreateAndGetAmInfo().setAmWebUrl(clusterDescription.getInfo(StatusKeys.INFO_AM_WEB_URL));
appStatusBuilder.maybeCreateAndGetAmInfo().setHostname(clusterDescription.getInfo(StatusKeys.INFO_AM_HOSTNAME));
appStatusBuilder.maybeCreateAndGetAmInfo().setContainerId(clusterDescription.getInfo(StatusKeys.INFO_AM_CONTAINER_ID));
if (clusterDescription.statistics != null) {
Map<String, Integer> llapStats = clusterDescription.statistics.get(LLAP_KEY);
if (llapStats != null) {
int desiredContainers = llapStats.get(StatusKeys.STATISTICS_CONTAINERS_DESIRED);
int liveContainers = llapStats.get(StatusKeys.STATISTICS_CONTAINERS_LIVE);
appStatusBuilder.setDesiredInstances(desiredContainers);
appStatusBuilder.setLiveInstances(liveContainers);
} else {
throw new LlapStatusCliException(ExitCode.SLIDER_CLIENT_ERROR_OTHER, // Error since LLAP should always exist.
"Failed to get statistics for LLAP");
}
// TODO HIVE-13454 Use some information from here such as containers.start.failed
// and containers.failed.recently to provide an estimate of whether this app is healthy or not.
} else {
throw new LlapStatusCliException(ExitCode.SLIDER_CLIENT_ERROR_OTHER, // Error since statistics should always exist.
"Failed to get statistics");
}
// Code to locate container status via slider. Not using this at the moment.
if (clusterDescription.status != null) {
Object liveObject = clusterDescription.status.get(ClusterDescriptionKeys.KEY_CLUSTER_LIVE);
if (liveObject != null) {
Map<String, Map<String, Map<String, Object>>> liveEntity = (Map<String, Map<String, Map<String, Object>>>) liveObject;
Map<String, Map<String, Object>> llapEntity = liveEntity.get(LLAP_KEY);
if (llapEntity != null) {
// Not a problem. Nothing has come up yet.
for (Map.Entry<String, Map<String, Object>> containerEntry : llapEntity.entrySet()) {
String containerIdString = containerEntry.getKey();
Map<String, Object> containerParams = containerEntry.getValue();
String host = (String) containerParams.get("host");
LlapInstance llapInstance = new LlapInstance(host, containerIdString);
appStatusBuilder.addNewLlapInstance(llapInstance);
}
}
}
}
return ExitCode.SUCCESS;
}
}
Aggregations