use of org.apache.apex.engine.util.StreamingAppFactory in project apex-core by apache.
the class StramAppLauncher method findAppConfigClasses.
/**
* Scan the application jar file entries for configuration classes.
* This needs to occur in a class loader with access to the application dependencies.
*/
private void findAppConfigClasses(List<String> classFileNames) {
URLClassLoader cl = URLClassLoader.newInstance(launchDependencies.toArray(new URL[launchDependencies.size()]));
for (final String classFileName : classFileNames) {
final String className = classFileName.replace('/', '.').substring(0, classFileName.length() - 6);
try {
final Class<?> clazz = cl.loadClass(className);
if (!Modifier.isAbstract(clazz.getModifiers()) && StreamingApplication.class.isAssignableFrom(clazz)) {
final AppFactory appConfig = new StreamingAppFactory(classFileName, clazz) {
@Override
public LogicalPlan createApp(LogicalPlanConfiguration planConfig) {
// load class from current context class loader
Class<? extends StreamingApplication> c = StramUtils.classForName(className, StreamingApplication.class);
StreamingApplication app = StramUtils.newInstance(c);
return super.createApp(app, planConfig);
}
};
appResourceList.add(appConfig);
}
} catch (Throwable e) {
// java.lang.NoClassDefFoundError
LOG.error("Unable to load class: " + className + " " + e);
}
}
}
use of org.apache.apex.engine.util.StreamingAppFactory in project apex-core by apache.
the class YarnAppLauncherImpl method launchApp.
@Override
public YarnAppHandleImpl launchApp(final StreamingApplication app, Configuration conf, Attribute.AttributeMap launchParameters) throws LauncherException {
if (launchParameters != null) {
for (Map.Entry<Attribute<?>, Object> entry : launchParameters.entrySet()) {
String property = propMapping.get(entry.getKey());
if (property != null) {
setConfiguration(conf, property, entry.getValue());
}
}
}
try {
String name = app.getClass().getName();
StramAppLauncher appLauncher = new StramAppLauncher(name, conf);
appLauncher.loadDependencies();
StreamingAppFactory appFactory = new StreamingAppFactory(name, app.getClass()) {
@Override
public LogicalPlan createApp(LogicalPlanConfiguration planConfig) {
return super.createApp(app, planConfig);
}
};
ApplicationId appId = appLauncher.launchApp(appFactory);
return new YarnAppHandleImpl(appId);
} catch (Exception ex) {
throw new LauncherException(ex);
}
}
use of org.apache.apex.engine.util.StreamingAppFactory in project apex-core by apache.
the class DAGSetupPluginTests method testJavaApplication.
@Test
public void testJavaApplication() {
Configuration conf = getConfiguration();
StreamingAppFactory factory = new StreamingAppFactory(Application.class.getName(), Application.class) {
@Override
public LogicalPlan createApp(LogicalPlanConfiguration planConfig) {
Class<? extends StreamingApplication> c = StramUtils.classForName(Application.class.getName(), StreamingApplication.class);
StreamingApplication app = StramUtils.newInstance(c);
return super.createApp(app, planConfig);
}
};
LogicalPlan dag = factory.createApp(new LogicalPlanConfiguration(conf));
validateProperties(dag);
}
Aggregations