use of org.apache.gobblin.runtime.embedded.EmbeddedGobblin in project incubator-gobblin by apache.
the class CliEmbeddedGobblin method run.
@Override
public void run(String[] args) throws IOException {
int startOptions = 1;
Class<? extends EmbeddedGobblinCliFactory> factoryClass;
String alias = "";
if (args.length >= 2 && !args[1].startsWith("-")) {
alias = args[1];
startOptions = 2;
}
if (alias.equals(LIST_QUICK_APPS)) {
listQuickApps();
return;
}
EmbeddedGobblinCliFactory factory;
if (!Strings.isNullOrEmpty(alias)) {
try {
ClassAliasResolver<EmbeddedGobblinCliFactory> resolver = new ClassAliasResolver<>(EmbeddedGobblinCliFactory.class);
factoryClass = resolver.resolveClass(alias);
factory = factoryClass.newInstance();
} catch (ReflectiveOperationException roe) {
System.out.println("Error: Could not find job with alias " + alias);
System.out.println("For a list of jobs available: \"gobblin run " + LIST_QUICK_APPS + "\"");
return;
}
} else {
factory = new EmbeddedGobblin.CliFactory();
}
String usage;
if (Strings.isNullOrEmpty(alias)) {
usage = "gobblin run [listQuickApps] [<quick-app>] " + factory.getUsageString();
} else {
usage = "gobblin run " + alias + " " + factory.getUsageString();
}
EmbeddedGobblin embeddedGobblin = factory.buildObject(args, startOptions, true, usage);
try {
embeddedGobblin.run();
} catch (InterruptedException | TimeoutException | ExecutionException exc) {
throw new RuntimeException("Failed to run Gobblin job.", exc);
}
}
Aggregations