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);
}
}
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;
}
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);
}
}
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);
}
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);
}
}
Aggregations