use of com.datatorrent.api.StreamingApplication in project apex-core by apache.
the class LogicalPlanConfigurationTest method testAppAlias.
@Test
public void testAppAlias() {
StreamingApplication app = new AnnotatedApplication();
Configuration conf = new Configuration(false);
conf.addResource(StramClientUtils.DT_SITE_XML_FILE);
LogicalPlanConfiguration builder = new LogicalPlanConfiguration(conf);
Properties properties = new Properties();
properties.put(StreamingApplication.APEX_PREFIX + "application.TestAliasApp.class", app.getClass().getName());
builder.addFromProperties(properties, null);
LogicalPlan dag = new LogicalPlan();
String appPath = app.getClass().getName().replace(".", "/") + ".class";
builder.prepareDAG(dag, app, appPath);
Assert.assertEquals("Application name", "TestAliasApp", dag.getAttributes().get(com.datatorrent.api.Context.DAGContext.APPLICATION_NAME));
}
use of com.datatorrent.api.StreamingApplication in project apex-core by apache.
the class LogicalPlanConfigurationTest method testApplicationLevelParameter.
@Test
public void testApplicationLevelParameter() {
String appName = "app1";
final GenericTestOperator operator1 = new GenericTestOperator();
final GenericTestOperator operator2 = new GenericTestOperator();
StreamingApplication app = new StreamingApplication() {
@Override
public void populateDAG(DAG dag, Configuration conf) {
dag.addOperator("operator1", operator1);
dag.addOperator("operator2", operator2);
}
};
Properties props = new Properties();
props.put(StreamingApplication.APEX_PREFIX + "application." + appName + ".class", app.getClass().getName());
props.put(StreamingApplication.APEX_PREFIX + "operator.*.myStringProperty", "foo ${xyz} bar ${zzz} baz");
props.put(StreamingApplication.APEX_PREFIX + "operator.*.booleanProperty", Boolean.TRUE.toString());
props.put(StreamingApplication.APEX_PREFIX + "application." + appName + ".operator.operator1.myStringProperty", "apv1");
LogicalPlanConfiguration dagBuilder = new LogicalPlanConfiguration(new Configuration(false));
Configuration vars = new Configuration(false);
vars.set("xyz", "123");
vars.set("zzz", "456");
dagBuilder.addFromProperties(props, vars);
String appPath = app.getClass().getName().replace(".", "/") + ".class";
LogicalPlan dag = new LogicalPlan();
dagBuilder.prepareDAG(dag, app, appPath);
Assert.assertEquals("apv1", operator1.getMyStringProperty());
Assert.assertEquals("foo 123 bar 456 baz", operator2.getMyStringProperty());
Assert.assertEquals(true, operator2.isBooleanProperty());
}
use of com.datatorrent.api.StreamingApplication 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 com.datatorrent.api.StreamingApplication in project apex-core by apache.
the class OperatorContextTest method testInjectionOfOperatorName.
@Test
public void testInjectionOfOperatorName() throws Exception {
StreamingApplication application = new StreamingApplication() {
@Override
public void populateDAG(DAG dag, Configuration conf) {
dag.addOperator("input", new MockInputOperator());
}
};
LocalMode lma = LocalMode.newInstance();
lma.prepareDAG(application, new Configuration());
LocalMode.Controller lc = lma.getController();
lc.runAsync();
latch.await();
Assert.assertEquals("operator name", "input", operatorName);
lc.shutdown();
}
use of com.datatorrent.api.StreamingApplication in project apex-core by apache.
the class TestModuleExpansion method testModuleExtreme.
@Test
public void testModuleExtreme() {
StreamingApplication app = new NestedModuleApp();
Configuration conf = new Configuration(false);
LogicalPlanConfiguration lpc = new LogicalPlanConfiguration(conf);
LogicalPlan dag = new LogicalPlan();
lpc.prepareDAG(dag, app, "ModuleApp");
dag.validate();
validateTopLevelOperators(dag);
validateTopLevelStreams(dag);
validatePublicMethods(dag);
}
Aggregations