Search in sources :

Example 6 with LogicalPlanConfiguration

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

the class TestModuleExpansion method conflictingNamesWithOperator2.

/**
   * Module and Operator with same name is not allowed in a DAG, to prevent properties
   * conflict.
   */
@Test(expected = java.lang.IllegalArgumentException.class)
public void conflictingNamesWithOperator2() {
    Configuration conf = new Configuration(false);
    LogicalPlanConfiguration lpc = new LogicalPlanConfiguration(conf);
    LogicalPlan dag = new LogicalPlan();
    Level2ModuleA module = dag.addModule("M1", new Level2ModuleA());
    DummyInputOperator in = dag.addOperator("M1", new DummyInputOperator());
    dag.addStream("s1", in.out, module.mIn);
    lpc.prepareDAG(dag, null, "ModuleApp");
    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) Test(org.junit.Test)

Example 7 with LogicalPlanConfiguration

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

the class TestModuleExpansion method conflictingNamesWithOperator1.

/**
   * Module and Operator with same name is not allowed in a DAG, to prevent properties
   * conflict.
   */
@Test(expected = java.lang.IllegalArgumentException.class)
public void conflictingNamesWithOperator1() {
    Configuration conf = new Configuration(false);
    LogicalPlanConfiguration lpc = new LogicalPlanConfiguration(conf);
    LogicalPlan dag = new LogicalPlan();
    DummyInputOperator in = dag.addOperator("M1", new DummyInputOperator());
    Level2ModuleA module = dag.addModule("M1", new Level2ModuleA());
    dag.addStream("s1", in.out, module.mIn);
    lpc.prepareDAG(dag, null, "ModuleApp");
    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) Test(org.junit.Test)

Example 8 with LogicalPlanConfiguration

use of com.datatorrent.stram.plan.logical.LogicalPlanConfiguration 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);
}
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 9 with LogicalPlanConfiguration

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

the class TestModuleExpansion method conflictingNamesWithExpandedModule.

/**
   * Generate a conflict, Add a top level operator with name "m1_O1",
   * and add a module "m1" which will populate operator "O1", causing name conflict with
   * top level operator.
   */
@Test(expected = java.lang.IllegalArgumentException.class)
public void conflictingNamesWithExpandedModule() {
    Configuration conf = new Configuration(false);
    LogicalPlanConfiguration lpc = new LogicalPlanConfiguration(conf);
    LogicalPlan dag = new LogicalPlan();
    DummyInputOperator in = dag.addOperator(componentName("m1", "O1"), new DummyInputOperator());
    Level2ModuleA module = dag.addModule("m1", new Level2ModuleA());
    dag.addStream("s1", in.out, module.mIn);
    lpc.prepareDAG(dag, null, "ModuleApp");
    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) Test(org.junit.Test)

Example 10 with LogicalPlanConfiguration

use of com.datatorrent.stram.plan.logical.LogicalPlanConfiguration 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);
        }
    }
}
Also used : LogicalPlanConfiguration(com.datatorrent.stram.plan.logical.LogicalPlanConfiguration) StreamingAppFactory(org.apache.apex.engine.util.StreamingAppFactory) URLClassLoader(java.net.URLClassLoader) StreamingApplication(com.datatorrent.api.StreamingApplication) StreamingAppFactory(org.apache.apex.engine.util.StreamingAppFactory) URL(java.net.URL)

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