use of org.apache.hadoop.hive.llap.cli.status.LlapStatusHelpers.AppStatusBuilder in project hive by apache.
the class LlapStatusServiceDriver method run.
public int run(LlapStatusOptions options, long watchTimeoutMs) {
appStatusBuilder = new AppStatusBuilder();
try {
if (appName == null) {
// user provided configs
for (Map.Entry<Object, Object> props : options.getConf().entrySet()) {
conf.set((String) props.getKey(), (String) props.getValue());
}
appName = options.getName();
if (StringUtils.isEmpty(appName)) {
appName = HiveConf.getVar(conf, HiveConf.ConfVars.LLAP_DAEMON_SERVICE_HOSTS);
if (appName.startsWith("@") && appName.length() > 1) {
// This is a valid slider app name. Parse it out.
appName = appName.substring(1);
} else {
// Invalid app name. Checked later.
appName = null;
}
}
if (StringUtils.isEmpty(appName)) {
String message = "Invalid app name. This must be setup via config or passed in as a parameter." + " This tool works with clusters deployed by Slider/YARN";
LOG.info(message);
return ExitCode.INCORRECT_USAGE.getInt();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Using appName: {}", appName);
}
llapRegistryConf.set(HiveConf.ConfVars.LLAP_DAEMON_SERVICE_HOSTS.varname, "@" + appName);
}
try {
if (sliderClient == null) {
sliderClient = LlapSliderUtils.createSliderClient(conf);
}
} catch (Exception e) {
LlapStatusCliException le = new LlapStatusCliException(LlapStatusServiceDriver.ExitCode.SLIDER_CLIENT_ERROR_CREATE_FAILED, "Failed to create slider client", e);
logError(le);
return le.getExitCode().getInt();
}
// Get the App report from YARN
ApplicationReport appReport;
try {
appReport = LlapSliderUtils.getAppReport(appName, sliderClient, options.getFindAppTimeoutMs());
} catch (LlapStatusCliException e) {
logError(e);
return e.getExitCode().getInt();
}
// Process the report to decide whether to go to slider.
ExitCode ret;
try {
ret = processAppReport(appReport, appStatusBuilder);
} catch (LlapStatusCliException e) {
logError(e);
return e.getExitCode().getInt();
}
if (ret != ExitCode.SUCCESS) {
return ret.getInt();
} else if (NO_SLIDER_INFO_STATES.contains(appStatusBuilder.getState())) {
return ExitCode.SUCCESS.getInt();
} else {
// Get information from slider.
try {
ret = populateAppStatusFromSliderStatus(appName, sliderClient, appStatusBuilder);
} catch (LlapStatusCliException e) {
// In case of failure, send back whatever is constructed sop far - which wouldbe from the AppReport
logError(e);
return e.getExitCode().getInt();
}
}
if (ret != ExitCode.SUCCESS) {
return ret.getInt();
} else {
try {
ret = populateAppStatusFromSliderDiagnostics(appName, sliderClient, appStatusBuilder);
} catch (LlapStatusCliException e) {
logError(e);
return e.getExitCode().getInt();
}
}
if (ret != ExitCode.SUCCESS) {
return ret.getInt();
} else {
try {
ret = populateAppStatusFromLlapRegistry(appStatusBuilder, watchTimeoutMs);
} catch (LlapStatusCliException e) {
logError(e);
return e.getExitCode().getInt();
}
}
return ret.getInt();
} finally {
if (LOG.isDebugEnabled()) {
LOG.debug("Final AppState: " + appStatusBuilder.toString());
}
}
}
Aggregations