Search in sources :

Example 1 with ClassAliasResolver

use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.

the class DatasetHelper method createRecompactionCondition.

private RecompactionCondition createRecompactionCondition() {
    ClassAliasResolver<RecompactionConditionFactory> conditionClassAliasResolver = new ClassAliasResolver<>(RecompactionConditionFactory.class);
    String factoryName = this.dataset.jobProps().getProp(MRCompactor.COMPACTION_RECOMPACT_CONDITION, MRCompactor.DEFAULT_COMPACTION_RECOMPACT_CONDITION);
    try {
        RecompactionConditionFactory factory = GobblinConstructorUtils.invokeFirstConstructor(conditionClassAliasResolver.resolveClass(factoryName), ImmutableList.of());
        return factory.createRecompactionCondition(dataset);
    } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : ClassAliasResolver(org.apache.gobblin.util.ClassAliasResolver) RecompactionConditionFactory(org.apache.gobblin.compaction.conditions.RecompactionConditionFactory) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with ClassAliasResolver

use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.

the class AzkabanJobLauncher method initJobListener.

protected JobListener initJobListener() {
    CompositeJobListener compositeJobListener = new CompositeJobListener();
    List<String> listeners = new State(props).getPropAsList(GOBBLIN_CUSTOM_JOB_LISTENERS, EmailNotificationJobListener.class.getSimpleName());
    try {
        for (String listenerAlias : listeners) {
            ClassAliasResolver<JobListener> conditionClassAliasResolver = new ClassAliasResolver<>(JobListener.class);
            compositeJobListener.addJobListener(conditionClassAliasResolver.resolveClass(listenerAlias).newInstance());
        }
    } catch (IllegalAccessException | InstantiationException | ClassNotFoundException e) {
        throw new IllegalArgumentException(e);
    }
    return compositeJobListener;
}
Also used : EmailNotificationJobListener(org.apache.gobblin.runtime.listeners.EmailNotificationJobListener) JobListener(org.apache.gobblin.runtime.listeners.JobListener) CompositeJobListener(org.apache.gobblin.runtime.listeners.CompositeJobListener) EmailNotificationJobListener(org.apache.gobblin.runtime.listeners.EmailNotificationJobListener) CompositeJobListener(org.apache.gobblin.runtime.listeners.CompositeJobListener) State(org.apache.gobblin.configuration.State) ClassAliasResolver(org.apache.gobblin.util.ClassAliasResolver)

Example 3 with ClassAliasResolver

use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.

the class CompactionAuditCountVerifier method getClientFactory.

/**
 * Obtain a client factory
 * @param state job state
 * @return a factory which creates {@link AuditCountClient}.
 *         If no factory is set or an error occurred, a {@link EmptyAuditCountClientFactory} is
 *         returned which creates a <code>null</code> {@link AuditCountClient}
 */
private static AuditCountClientFactory getClientFactory(State state) {
    if (!state.contains(AuditCountClientFactory.AUDIT_COUNT_CLIENT_FACTORY)) {
        return new EmptyAuditCountClientFactory();
    }
    try {
        String factoryName = state.getProp(AuditCountClientFactory.AUDIT_COUNT_CLIENT_FACTORY);
        ClassAliasResolver<AuditCountClientFactory> conditionClassAliasResolver = new ClassAliasResolver<>(AuditCountClientFactory.class);
        AuditCountClientFactory factory = conditionClassAliasResolver.resolveClass(factoryName).newInstance();
        return factory;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : AuditCountClientFactory(org.apache.gobblin.compaction.audit.AuditCountClientFactory) ClassAliasResolver(org.apache.gobblin.util.ClassAliasResolver) IOException(java.io.IOException)

Example 4 with ClassAliasResolver

use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.

the class ZkDatasetStateStoreTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    ConfigBuilder configBuilder = ConfigBuilder.create();
    testingServer = new TestingServer(-1);
    zkJobStateStore = new ZkStateStore<>(testingServer.getConnectString(), "/STATE_STORE/TEST", false, JobState.class);
    configBuilder.addPrimitive(ZkStateStoreConfigurationKeys.STATE_STORE_ZK_CONNECT_STRING_KEY, testingServer.getConnectString());
    configBuilder.addPrimitive(ConfigurationKeys.STATE_STORE_ROOT_DIR_KEY, "/STATE_STORE/TEST2");
    ClassAliasResolver<DatasetStateStore.Factory> resolver = new ClassAliasResolver<>(DatasetStateStore.Factory.class);
    DatasetStateStore.Factory stateStoreFactory = resolver.resolveClass("zk").newInstance();
    zkDatasetStateStore = stateStoreFactory.createStateStore(configBuilder.build());
    // clear data that may have been left behind by a prior test run
    zkJobStateStore.delete(TEST_JOB_NAME);
    zkDatasetStateStore.delete(TEST_JOB_NAME);
    zkJobStateStore.delete(TEST_JOB_NAME2);
    zkDatasetStateStore.delete(TEST_JOB_NAME2);
}
Also used : TestingServer(org.apache.curator.test.TestingServer) ClassAliasResolver(org.apache.gobblin.util.ClassAliasResolver) ConfigBuilder(org.apache.gobblin.config.ConfigBuilder) DatasetStateStore(org.apache.gobblin.metastore.DatasetStateStore) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with ClassAliasResolver

use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.

the class JobContext method createStateStore.

protected DatasetStateStore createStateStore(Config jobConfig) throws IOException {
    boolean stateStoreEnabled = !jobConfig.hasPath(ConfigurationKeys.STATE_STORE_ENABLED) || jobConfig.getBoolean(ConfigurationKeys.STATE_STORE_ENABLED);
    String stateStoreType;
    if (!stateStoreEnabled) {
        stateStoreType = ConfigurationKeys.STATE_STORE_TYPE_NOOP;
    } else {
        stateStoreType = ConfigUtils.getString(jobConfig, ConfigurationKeys.DATASET_STATE_STORE_TYPE_KEY, ConfigUtils.getString(jobConfig, ConfigurationKeys.STATE_STORE_TYPE_KEY, ConfigurationKeys.DEFAULT_STATE_STORE_TYPE));
    }
    ClassAliasResolver<DatasetStateStore.Factory> resolver = new ClassAliasResolver<>(DatasetStateStore.Factory.class);
    try {
        DatasetStateStore.Factory stateStoreFactory = resolver.resolveClass(stateStoreType).newInstance();
        return stateStoreFactory.createStateStore(jobConfig);
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new IOException(e);
    }
}
Also used : ClassAliasResolver(org.apache.gobblin.util.ClassAliasResolver) LoggerFactory(org.slf4j.LoggerFactory) IOException(java.io.IOException) DatasetStateStore(org.apache.gobblin.metastore.DatasetStateStore) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ClassAliasResolver (org.apache.gobblin.util.ClassAliasResolver)13 IOException (java.io.IOException)6 DatasetStateStore (org.apache.gobblin.metastore.DatasetStateStore)5 ExecutionException (java.util.concurrent.ExecutionException)3 BeforeClass (org.testng.annotations.BeforeClass)3 ConfigFactory (com.typesafe.config.ConfigFactory)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 TestingServer (org.apache.curator.test.TestingServer)2 ConfigBuilder (org.apache.gobblin.config.ConfigBuilder)2 LoggerFactory (org.slf4j.LoggerFactory)2 ConfigValueFactory (com.typesafe.config.ConfigValueFactory)1 Closeable (java.io.Closeable)1 File (java.io.File)1 URL (java.net.URL)1 Comparator (java.util.Comparator)1 NoSuchElementException (java.util.NoSuchElementException)1 TimeoutException (java.util.concurrent.TimeoutException)1 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)1 AuditCountClientFactory (org.apache.gobblin.compaction.audit.AuditCountClientFactory)1 RecompactionConditionFactory (org.apache.gobblin.compaction.conditions.RecompactionConditionFactory)1