Search in sources :

Example 16 with EmbeddedGobblin

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);
    }
}
Also used : ClassAliasResolver(org.apache.gobblin.util.ClassAliasResolver) EmbeddedGobblin(org.apache.gobblin.runtime.embedded.EmbeddedGobblin) ExecutionException(java.util.concurrent.ExecutionException) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

EmbeddedGobblin (org.apache.gobblin.runtime.embedded.EmbeddedGobblin)16 Test (org.testng.annotations.Test)14 JobExecutionResult (org.apache.gobblin.runtime.api.JobExecutionResult)12 File (java.io.File)11 GenericRecord (org.apache.avro.generic.GenericRecord)7 EventBus (com.google.common.eventbus.EventBus)3 TestingEventBusAsserter (org.apache.gobblin.writer.test.TestingEventBusAsserter)2 TestingEventBuses (org.apache.gobblin.writer.test.TestingEventBuses)2 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 JobExecutionDriver (org.apache.gobblin.runtime.api.JobExecutionDriver)1 ClassAliasResolver (org.apache.gobblin.util.ClassAliasResolver)1 GobblinTestEventBusWriter (org.apache.gobblin.writer.test.GobblinTestEventBusWriter)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1