Search in sources :

Example 16 with LogicalPlanConfiguration

use of com.datatorrent.stram.plan.logical.LogicalPlanConfiguration in project apex-core by apache.

the class AutoMetricTest method testDefaultMetricsAggregator.

@Test
public void testDefaultMetricsAggregator() throws Exception {
    LogicalPlanConfiguration lpc = new LogicalPlanConfiguration(new Configuration());
    TestGeneratorInputOperator inputOperator = dag.addOperator("input", TestGeneratorInputOperator.class);
    CountDownLatch latch = new CountDownLatch(1);
    OperatorAndAggregator o1 = dag.addOperator("o1", new OperatorAndAggregator(latch));
    dag.setAttribute(Context.OperatorContext.STORAGE_AGENT, new StramTestSupport.MemoryStorageAgent());
    dag.addStream("TestTuples", inputOperator.outport, o1.inport1);
    lpc.prepareDAG(dag, null, "AutoMetricTest");
    LogicalPlan.OperatorMeta o1meta = dag.getOperatorMeta("o1");
    Assert.assertNotNull("default aggregator injected", o1meta.getMetricAggregatorMeta().getAggregator());
    lpc.prepareDAG(dag, null, "AutoMetricTest");
    StramLocalCluster lc = new StramLocalCluster(dag);
    lc.runAsync();
    latch.await();
    Assert.assertEquals("progress", 1, o1.result.get("progress"));
    lc.shutdown();
}
Also used : LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) Configuration(org.apache.hadoop.conf.Configuration) StramTestSupport(com.datatorrent.stram.support.StramTestSupport) LogicalPlan(com.datatorrent.stram.plan.logical.LogicalPlan) CountDownLatch(java.util.concurrent.CountDownLatch) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) Test(org.junit.Test)

Example 17 with LogicalPlanConfiguration

use of com.datatorrent.stram.plan.logical.LogicalPlanConfiguration in project apex-core by apache.

the class ModuleAppTest method validateTestApplication.

@Test
public void validateTestApplication() {
    Configuration conf = new Configuration(false);
    LogicalPlanConfiguration lpc = new LogicalPlanConfiguration(conf);
    LogicalPlan dag = new LogicalPlan();
    lpc.prepareDAG(dag, new Application(), "TestApp");
    Assert.assertEquals(2, dag.getAllModules().size(), 2);
    Assert.assertEquals(5, dag.getAllOperators().size());
    Assert.assertEquals(4, dag.getAllStreams().size());
    dag.validate();
}
Also used : LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) Configuration(org.apache.hadoop.conf.Configuration) LogicalPlan(com.datatorrent.stram.plan.logical.LogicalPlan) StreamingApplication(com.datatorrent.api.StreamingApplication) Test(org.junit.Test)

Example 18 with LogicalPlanConfiguration

use of com.datatorrent.stram.plan.logical.LogicalPlanConfiguration in project apex-core by apache.

the class TestModuleExpansion method testLoadFromPropertiesFile.

@Test
public void testLoadFromPropertiesFile() throws IOException {
    Properties props = new Properties();
    String resourcePath = "/testModuleTopology.properties";
    InputStream is = this.getClass().getResourceAsStream(resourcePath);
    if (is == null) {
        throw new RuntimeException("Could not load " + resourcePath);
    }
    props.load(is);
    LogicalPlanConfiguration pb = new LogicalPlanConfiguration(new Configuration(false)).addFromProperties(props, null);
    LogicalPlan dag = new LogicalPlan();
    pb.populateDAG(dag);
    pb.prepareDAG(dag, null, "testApplication");
    dag.validate();
    validateTopLevelOperators(dag);
    validateTopLevelStreams(dag);
    validatePublicMethods(dag);
}
Also used : LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) Configuration(org.apache.hadoop.conf.Configuration) InputStream(java.io.InputStream) LogicalPlan(com.datatorrent.stram.plan.logical.LogicalPlan) Properties(java.util.Properties) Test(org.junit.Test)

Example 19 with LogicalPlanConfiguration

use of com.datatorrent.stram.plan.logical.LogicalPlanConfiguration in project apex-core by apache.

the class TestModuleExpansion method testLoadFromJson.

@Test
public void testLoadFromJson() throws Exception {
    String resourcePath = "/testModuleTopology.json";
    InputStream is = this.getClass().getResourceAsStream(resourcePath);
    if (is == null) {
        throw new RuntimeException("Could not load " + resourcePath);
    }
    StringWriter writer = new StringWriter();
    IOUtils.copy(is, writer);
    JSONObject json = new JSONObject(writer.toString());
    Configuration conf = new Configuration(false);
    conf.set(StreamingApplication.APEX_PREFIX + "operator.operator3.prop.myStringProperty", "o3StringFromConf");
    LogicalPlanConfiguration planConf = new LogicalPlanConfiguration(conf);
    LogicalPlan dag = planConf.createFromJson(json, "testLoadFromJson");
    planConf.prepareDAG(dag, null, "testApplication");
    dag.validate();
    validateTopLevelOperators(dag);
    validateTopLevelStreams(dag);
    validatePublicMethods(dag);
}
Also used : LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) StringWriter(java.io.StringWriter) JSONObject(org.codehaus.jettison.json.JSONObject) LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) Configuration(org.apache.hadoop.conf.Configuration) InputStream(java.io.InputStream) LogicalPlan(com.datatorrent.stram.plan.logical.LogicalPlan) Test(org.junit.Test)

Aggregations

LogicalPlanConfiguration (com.datatorrent.stram.plan.logical.LogicalPlanConfiguration)19 Configuration (org.apache.hadoop.conf.Configuration)17 Test (org.junit.Test)16 LogicalPlan (com.datatorrent.stram.plan.logical.LogicalPlan)12 StramTestSupport (com.datatorrent.stram.support.StramTestSupport)5 StramLocalCluster (com.datatorrent.stram.StramLocalCluster)4 Properties (java.util.Properties)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 StreamingApplication (com.datatorrent.api.StreamingApplication)3 JSONObject (org.codehaus.jettison.json.JSONObject)3 GenericTestOperator (com.datatorrent.stram.engine.GenericTestOperator)2 TestGeneratorInputOperator (com.datatorrent.stram.engine.TestGeneratorInputOperator)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 StreamingAppFactory (org.apache.apex.engine.util.StreamingAppFactory)2 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)2 Ignore (org.junit.Ignore)2 Attribute (com.datatorrent.api.Attribute)1 StramAppLauncher (com.datatorrent.stram.client.StramAppLauncher)1