Search in sources :

Example 46 with StramLocalCluster

use of com.datatorrent.stram.StramLocalCluster in project apex-malhar by apache.

the class TopWikipediaSessionsTest method TopWikipediaSessionsTest.

@Test
public void TopWikipediaSessionsTest() throws Exception {
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.set("dt.application.TopWikipediaSessions.operator.console.silent", "true");
    lma.prepareDAG(new TopWikipediaSessions(), conf);
    LocalMode.Controller lc = lma.getController();
    ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return TopWikipediaSessions.SessionGen.getTupleCount() >= 250;
        }
    });
    lc.run(30000);
    for (int i = 0; i < TopWikipediaSessions.Collector.getResult().size(); i++) {
        Assert.assertTrue(isInOrder(TopWikipediaSessions.Collector.getResult().get(i)));
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) Test(org.junit.Test)

Example 47 with StramLocalCluster

use of com.datatorrent.stram.StramLocalCluster in project apex-malhar by apache.

the class DeDupExampleTest method DeDupExampleTest.

@Test
public void DeDupExampleTest() throws Exception {
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.set("dt.application.DeDupExample.operator.console.silent", "true");
    DeDupExample app = new DeDupExample();
    lma.prepareDAG(app, conf);
    LocalMode.Controller lc = lma.getController();
    ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

        @Override
        public Boolean call() throws Exception {
            return DeDupExample.Collector.isDone();
        }
    });
    lc.run(50000);
    Assert.assertEquals(9, DeDupExample.Collector.getResult().getValue().size());
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) Test(org.junit.Test)

Example 48 with StramLocalCluster

use of com.datatorrent.stram.StramLocalCluster in project apex-malhar by apache.

the class ApplicationTest method testApplication.

@Test
public void testApplication() throws IOException, Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties.xml"));
        conf.set("dt.application.FilterExample.operator.selectedOutput.prop.filePath", outputDir);
        conf.set("dt.application.FilterExample.operator.rejectedOutput.prop.filePath", outputDir);
        final File selectedfile = FileUtils.getFile(outputDir, "selected.txt_8.0");
        final File rejectedfile = FileUtils.getFile(outputDir, "rejected.txt_6.0");
        lma.prepareDAG(new Application(), conf);
        LocalMode.Controller lc = lma.getController();
        ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                if (selectedfile.exists() && rejectedfile.exists()) {
                    return true;
                }
                return false;
            }
        });
    } catch (ConstraintViolationException e) {
        Assert.fail("constraint violations: " + e.getConstraintViolations());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) ConstraintViolationException(javax.validation.ConstraintViolationException) File(java.io.File) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) IOException(java.io.IOException) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 49 with StramLocalCluster

use of com.datatorrent.stram.StramLocalCluster in project apex-malhar by apache.

the class JdbcPojoOperatorApplicationTest method testApplication.

@Test
public void testApplication() throws Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        conf.addResource(this.getClass().getResourceAsStream("/JdbcProperties.xml"));
        lma.prepareDAG(new JdbcPojoOperatorApplication(), conf);
        LocalMode.Controller lc = lma.getController();
        lc.setHeartbeatMonitoringEnabled(false);
        ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                return getNumOfRowsinTable(TABLE_POJO_NAME) == 10;
            }
        });
        // runs for 10 seconds and quits
        lc.run(10000);
        Assert.assertEquals("rows in db", 10, getNumOfRowsinTable(TABLE_POJO_NAME));
    } catch (ConstraintViolationException e) {
        Assert.fail("constraint violations: " + e.getConstraintViolations());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) ConstraintViolationException(javax.validation.ConstraintViolationException) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) SQLException(java.sql.SQLException) ConstraintViolationException(javax.validation.ConstraintViolationException) Test(org.junit.Test)

Example 50 with StramLocalCluster

use of com.datatorrent.stram.StramLocalCluster in project apex-malhar by apache.

the class JdbcInputOperatorApplicationTest method testApplication.

public void testApplication(StreamingApplication streamingApplication) throws Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        conf.addResource(this.getClass().getResourceAsStream("/JdbcProperties.xml"));
        lma.prepareDAG(streamingApplication, conf);
        LocalMode.Controller lc = lma.getController();
        lc.setHeartbeatMonitoringEnabled(false);
        ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                return TupleCount == 10;
            }
        });
        // runs for 10 seconds and quits
        lc.run(10000);
        Assert.assertEquals("rows in db", TupleCount, getNumOfRowsinTable(TABLE_POJO_NAME));
    } catch (ConstraintViolationException e) {
        Assert.fail("constraint violations: " + e.getConstraintViolations());
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) ConstraintViolationException(javax.validation.ConstraintViolationException) StramLocalCluster(com.datatorrent.stram.StramLocalCluster) SQLException(java.sql.SQLException) ConstraintViolationException(javax.validation.ConstraintViolationException)

Aggregations

StramLocalCluster (com.datatorrent.stram.StramLocalCluster)57 Test (org.junit.Test)46 LocalMode (com.datatorrent.api.LocalMode)21 LogicalPlan (com.datatorrent.stram.plan.logical.LogicalPlan)20 Configuration (org.apache.hadoop.conf.Configuration)19 File (java.io.File)15 AsyncFSStorageAgent (com.datatorrent.common.util.AsyncFSStorageAgent)12 IOException (java.io.IOException)8 DAG (com.datatorrent.api.DAG)6 StreamMeta (com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta)6 MemoryStorageAgent (com.datatorrent.stram.support.StramTestSupport.MemoryStorageAgent)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ConstraintViolationException (javax.validation.ConstraintViolationException)5 StreamMeta (com.datatorrent.api.DAG.StreamMeta)4 PartitioningTest (com.datatorrent.stram.PartitioningTest)4 StreamingContainerManagerTest (com.datatorrent.stram.StreamingContainerManagerTest)4 TestGeneratorInputOperator (com.datatorrent.stram.engine.TestGeneratorInputOperator)4 LogicalPlanConfiguration (com.datatorrent.stram.plan.logical.LogicalPlanConfiguration)4 StramTestSupport (com.datatorrent.stram.support.StramTestSupport)4 SQLException (java.sql.SQLException)4