use of com.datatorrent.api.StreamingApplication in project apex-core by apache.
the class LogicalPlanConfigurationTest method testOperatorLevelProperties.
@Test
public void testOperatorLevelProperties() {
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", "pv1");
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));
dagBuilder.addFromProperties(props, null);
String appPath = app.getClass().getName().replace(".", "/") + ".class";
LogicalPlan dag = new LogicalPlan();
dagBuilder.prepareDAG(dag, app, appPath);
Assert.assertEquals("apv1", operator1.getMyStringProperty());
Assert.assertEquals("pv1", operator2.getMyStringProperty());
Assert.assertEquals(true, operator2.isBooleanProperty());
}
use of com.datatorrent.api.StreamingApplication in project apex-core by apache.
the class LogicalPlanConfigurationTest method testAppAnnotationAlias.
@Test
public void testAppAnnotationAlias() {
StreamingApplication app = new AnnotatedApplication();
Configuration conf = new Configuration(false);
conf.addResource(StramClientUtils.DT_SITE_XML_FILE);
LogicalPlanConfiguration builder = new LogicalPlanConfiguration(conf);
LogicalPlan dag = new LogicalPlan();
String appPath = app.getClass().getName().replace(".", "/") + ".class";
builder.prepareDAG(dag, app, appPath);
Assert.assertEquals("Application name", "AnnotatedAlias", 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 testPrepareDAG.
@Test
public void testPrepareDAG() {
final MutableBoolean appInitialized = new MutableBoolean(false);
StreamingApplication app = new StreamingApplication() {
@Override
public void populateDAG(DAG dag, Configuration conf) {
Assert.assertEquals("", "hostname:9090", dag.getValue(DAG.GATEWAY_CONNECT_ADDRESS));
dag.setAttribute(DAG.GATEWAY_CONNECT_ADDRESS, "hostname:9091");
appInitialized.setValue(true);
}
};
Configuration conf = new Configuration(false);
conf.addResource(StramClientUtils.DT_SITE_XML_FILE);
LogicalPlanConfiguration pb = new LogicalPlanConfiguration(conf);
LogicalPlan dag = new LogicalPlan();
pb.prepareDAG(dag, app, "testconfig");
Assert.assertTrue("populateDAG called", appInitialized.booleanValue());
Assert.assertEquals("populateDAG overrides attribute", "hostname:9091", dag.getValue(DAG.GATEWAY_CONNECT_ADDRESS));
}
use of com.datatorrent.api.StreamingApplication in project apex-core by apache.
the class LogicalPlanConfigurationTest method testTestTupleClassAttrSetFromConfig.
@Test
public void testTestTupleClassAttrSetFromConfig() {
Configuration conf = new Configuration(false);
conf.set(StreamingApplication.APEX_PREFIX + "operator.o2.port.schemaRequiredPort.attr.TUPLE_CLASS", "com.datatorrent.stram.plan.logical.LogicalPlanConfigurationTest$TestSchema");
StreamingApplication streamingApplication = new StreamingApplication() {
@Override
public void populateDAG(DAG dag, Configuration conf) {
TestGeneratorInputOperator o1 = dag.addOperator("o1", new TestGeneratorInputOperator());
SchemaTestOperator o2 = dag.addOperator("o2", new SchemaTestOperator());
dag.addStream("stream", o1.outport, o2.schemaRequiredPort);
}
};
LogicalPlan dag = new LogicalPlan();
LogicalPlanConfiguration lpc = new LogicalPlanConfiguration(conf);
lpc.prepareDAG(dag, streamingApplication, "app");
dag.validate();
}
use of com.datatorrent.api.StreamingApplication in project apex-malhar by apache.
the class KeyedWindowedOperatorBenchmarkAppTest method test.
@Test
public void test() throws Exception {
Configuration conf = new Configuration(false);
LocalMode lma = LocalMode.newInstance();
DAG dag = lma.getDAG();
super.populateDAG(dag, conf);
StreamingApplication app = new StreamingApplication() {
@Override
public void populateDAG(DAG dag, Configuration conf) {
}
};
lma.prepareDAG(app, conf);
// Create local cluster
final LocalMode.Controller lc = lma.getController();
lc.run(3000000);
lc.shutdown();
}
Aggregations