Search in sources :

Example 1 with LocalMode

use of com.datatorrent.api.LocalMode 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();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) StreamingApplication(com.datatorrent.api.StreamingApplication) DAG(com.datatorrent.api.DAG) Test(org.junit.Test)

Example 2 with LocalMode

use of com.datatorrent.api.LocalMode in project apex-core by apache.

the class CustomControlTupleTest method testApp.

public void testApp(StreamingApplication app) throws Exception {
    try {
        LocalMode lma = LocalMode.newInstance();
        Configuration conf = new Configuration(false);
        lma.prepareDAG(app, conf);
        LocalMode.Controller lc = lma.getController();
        ((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                return endApp;
            }
        });
        // runs for 20 seconds and quits if terminating condition not reached
        lc.run(200000);
        LOG.info("Control Tuples received {} expected {}", numControlTuples, controlIndex);
        Assert.assertTrue("Incorrect Control Tuples", numControlTuples == controlIndex);
    } 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) ConstraintViolationException(javax.validation.ConstraintViolationException)

Example 3 with LocalMode

use of com.datatorrent.api.LocalMode in project apex-core by apache.

the class StramLocalClusterTest method testDynamicLoading.

@Test
public void testDynamicLoading() throws Exception {
    String generatedJar = generatejar("POJO");
    URLClassLoader uCl = URLClassLoader.newInstance(new URL[] { new File(generatedJar).toURI().toURL() });
    Class<?> pojo = uCl.loadClass("POJO");
    DynamicLoaderApp app = new DynamicLoaderApp();
    app.generatedJar = generatedJar;
    app.pojo = pojo;
    LocalMode lma = LocalMode.newInstance();
    lma.prepareDAG(app, new Configuration());
    LocalMode.Controller lc = lma.getController();
    lc.runAsync();
    DynamicLoaderApp.latch.await();
    Assert.assertTrue(DynamicLoaderApp.passed);
    lc.shutdown();
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) LocalMode(com.datatorrent.api.LocalMode) URLClassLoader(java.net.URLClassLoader) File(java.io.File) Test(org.junit.Test)

Example 4 with LocalMode

use of com.datatorrent.api.LocalMode in project apex-core 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"));
        lma.prepareDAG(new Application(), conf);
        LocalMode.Controller lc = lma.getController();
        // runs for 10 seconds and quits
        lc.run(10000);
    } 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) Application(com.example.mydtapp.Application) Test(org.junit.Test)

Aggregations

LocalMode (com.datatorrent.api.LocalMode)4 Configuration (org.apache.hadoop.conf.Configuration)4 Test (org.junit.Test)3 ConstraintViolationException (javax.validation.ConstraintViolationException)2 DAG (com.datatorrent.api.DAG)1 StreamingApplication (com.datatorrent.api.StreamingApplication)1 Application (com.example.mydtapp.Application)1 File (java.io.File)1 URLClassLoader (java.net.URLClassLoader)1