use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.
the class GobblinHelixJobLauncherTest method setUp.
@BeforeClass
public void setUp() throws Exception {
TestingServer testingZKServer = this.closer.register(new TestingServer(-1));
LOG.info("Testing ZK Server listening on: " + testingZKServer.getConnectString());
URL url = GobblinHelixJobLauncherTest.class.getClassLoader().getResource(GobblinHelixJobLauncherTest.class.getSimpleName() + ".conf");
Assert.assertNotNull(url, "Could not find resource " + url);
this.appWorkDir = new Path(GobblinHelixJobLauncherTest.class.getSimpleName());
// Prepare the source Json file
File sourceJsonFile = new File(this.appWorkDir.toString(), TestHelper.TEST_JOB_NAME + ".json");
TestHelper.createSourceJsonFile(sourceJsonFile);
baseConfig = ConfigFactory.parseURL(url).withValue("gobblin.cluster.zk.connection.string", ConfigValueFactory.fromAnyRef(testingZKServer.getConnectString())).withValue(ConfigurationKeys.SOURCE_FILEBASED_FILES_TO_PULL, ConfigValueFactory.fromAnyRef(sourceJsonFile.getAbsolutePath())).withValue(ConfigurationKeys.JOB_STATE_IN_STATE_STORE, ConfigValueFactory.fromAnyRef("true")).resolve();
String zkConnectingString = baseConfig.getString(GobblinClusterConfigurationKeys.ZK_CONNECTION_STRING_KEY);
String helixClusterName = baseConfig.getString(GobblinClusterConfigurationKeys.HELIX_CLUSTER_NAME_KEY);
HelixUtils.createGobblinHelixCluster(zkConnectingString, helixClusterName);
this.helixManager = HelixManagerFactory.getZKHelixManager(helixClusterName, TestHelper.TEST_HELIX_INSTANCE_NAME, InstanceType.CONTROLLER, zkConnectingString);
this.closer.register(new Closeable() {
@Override
public void close() throws IOException {
helixManager.disconnect();
}
});
this.helixManager.connect();
this.localFs = FileSystem.getLocal(new Configuration());
this.closer.register(new Closeable() {
@Override
public void close() throws IOException {
if (localFs.exists(appWorkDir)) {
localFs.delete(appWorkDir, true);
}
}
});
this.gobblinTaskRunner = new GobblinTaskRunner(TestHelper.TEST_APPLICATION_NAME, TestHelper.TEST_HELIX_INSTANCE_NAME, TestHelper.TEST_APPLICATION_ID, TestHelper.TEST_TASK_RUNNER_ID, baseConfig, Optional.of(appWorkDir));
String stateStoreType = ConfigUtils.getString(baseConfig, ConfigurationKeys.STATE_STORE_TYPE_KEY, ConfigurationKeys.DEFAULT_STATE_STORE_TYPE);
ClassAliasResolver<DatasetStateStore.Factory> resolver = new ClassAliasResolver<>(DatasetStateStore.Factory.class);
DatasetStateStore.Factory stateStoreFactory = resolver.resolveClass(stateStoreType).newInstance();
this.datasetStateStore = stateStoreFactory.createStateStore(baseConfig);
this.thread = new Thread(new Runnable() {
@Override
public void run() {
gobblinTaskRunner.start();
}
});
this.thread.start();
}
use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.
the class MysqlDatasetStateStoreTest method setUp.
@BeforeClass
public void setUp() throws Exception {
testMetastoreDatabase = TestMetastoreDatabaseFactory.get();
String jdbcUrl = testMetastoreDatabase.getJdbcUrl();
ConfigBuilder configBuilder = ConfigBuilder.create();
BasicDataSource mySqlDs = new BasicDataSource();
mySqlDs.setDriverClassName(ConfigurationKeys.DEFAULT_STATE_STORE_DB_JDBC_DRIVER);
mySqlDs.setDefaultAutoCommit(false);
mySqlDs.setUrl(jdbcUrl);
mySqlDs.setUsername(TEST_USER);
mySqlDs.setPassword(TEST_PASSWORD);
dbJobStateStore = new MysqlStateStore<>(mySqlDs, TEST_STATE_STORE, false, JobState.class);
configBuilder.addPrimitive(ConfigurationKeys.STATE_STORE_DB_URL_KEY, jdbcUrl);
configBuilder.addPrimitive(ConfigurationKeys.STATE_STORE_DB_USER_KEY, TEST_USER);
configBuilder.addPrimitive(ConfigurationKeys.STATE_STORE_DB_PASSWORD_KEY, TEST_PASSWORD);
ClassAliasResolver<DatasetStateStore.Factory> resolver = new ClassAliasResolver<>(DatasetStateStore.Factory.class);
DatasetStateStore.Factory stateStoreFactory = resolver.resolveClass("mysql").newInstance();
dbDatasetStateStore = stateStoreFactory.createStateStore(configBuilder.build());
// clear data that may have been left behind by a prior test run
dbJobStateStore.delete(TEST_JOB_NAME);
dbDatasetStateStore.delete(TEST_JOB_NAME);
dbJobStateStore.delete(TEST_JOB_NAME2);
dbDatasetStateStore.delete(TEST_JOB_NAME2);
}
use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.
the class MRCompactor method getCompactionCompleteListener.
private CompactorCompletionListener getCompactionCompleteListener() {
ClassAliasResolver<CompactorCompletionListenerFactory> classAliasResolver = new ClassAliasResolver<>(CompactorCompletionListenerFactory.class);
String listenerName = this.state.getProp(MRCompactor.COMPACTION_COMPLETE_LISTERNER, MRCompactor.DEFAULT_COMPACTION_COMPLETE_LISTERNER);
try {
CompactorCompletionListenerFactory factory = GobblinConstructorUtils.invokeFirstConstructor(classAliasResolver.resolveClass(listenerName), ImmutableList.of());
return factory.createCompactorCompactionListener(this.state);
} 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 DatasetStateStore method buildDatasetStateStore.
static DatasetStateStore buildDatasetStateStore(Config config) throws IOException {
ClassAliasResolver<Factory> resolver = new ClassAliasResolver<>(DatasetStateStore.Factory.class);
String stateStoreType = ConfigUtils.getString(config, ConfigurationKeys.STATE_STORE_TYPE_KEY, ConfigurationKeys.DEFAULT_STATE_STORE_TYPE);
try {
DatasetStateStore.Factory stateStoreFactory = resolver.resolveClass(stateStoreType).newInstance();
return stateStoreFactory.createStateStore(config);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new IOException(e);
}
}
use of org.apache.gobblin.util.ClassAliasResolver in project incubator-gobblin by apache.
the class ServiceBasedAppLauncher method createAdminServer.
public static Service createAdminServer(Properties properties, URI executionInfoServerURI) {
String factoryClassName = properties.getProperty(ConfigurationKeys.ADMIN_SERVER_FACTORY_CLASS_KEY, ConfigurationKeys.DEFAULT_ADMIN_SERVER_FACTORY_CLASS);
ClassAliasResolver<AdminWebServerFactory> classResolver = new ClassAliasResolver<>(AdminWebServerFactory.class);
try {
AdminWebServerFactory factoryInstance = classResolver.resolveClass(factoryClassName).newInstance();
return factoryInstance.createInstance(properties, executionInfoServerURI);
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
throw new RuntimeException("Unable to instantiate the AdminWebServer factory. " + "Have you included the module in the gobblin distribution? :" + e, e);
}
}
Aggregations