use of com.twitter.ambrose.model.Workflow in project ambrose by twitter.
the class AmbroseHiveFinishHook method postDriverRun.
@Override
public void postDriverRun(HiveDriverRunHookContext hookContext) {
Configuration conf = hookContext.getConf();
EmbeddedAmbroseHiveProgressReporter reporter = getEmbeddedProgressReporter();
String workflowVersion = reporter.getWorkflowVersion();
String queryId = AmbroseHiveUtil.getHiveQueryId(conf);
if (workflowVersion == null) {
LOG.warn("ScriptFingerprint not set for this script - not saving stats.");
} else {
Workflow workflow = new Workflow(queryId, workflowVersion, reporter.getJobs());
outputStatsData(workflow);
reporter.flushJsonToDisk();
}
displayStatistics();
if (!isLastCommandProcessed(hookContext)) {
return;
}
reporter.restoreEventStack();
String sleepTime = System.getProperty(POST_SCRIPT_SLEEP_SECS_PARAM, "10");
try {
int sleepTimeSeconds = Integer.parseInt(sleepTime);
LOG.info("Script complete but sleeping for " + sleepTimeSeconds + " seconds to keep the HiveStats REST server running. Hit ctrl-c to exit.");
Thread.sleep(sleepTimeSeconds * 1000L);
reporter.stopServer();
} catch (NumberFormatException e) {
LOG.warn(POST_SCRIPT_SLEEP_SECS_PARAM + " param is not a valid number, not sleeping: " + sleepTime);
} catch (InterruptedException e) {
LOG.warn("Sleep interrupted", e);
}
}
Aggregations