Search in sources :

Example 1 with ChainedPluginLocator

use of org.apache.apex.engine.plugin.loaders.ChainedPluginLocator in project apex-core by apache.

the class StreamingAppMasterService method initApexPluginDispatcher.

private void initApexPluginDispatcher() {
    PluginLocator<DAGExecutionPlugin> locator = new ChainedPluginLocator<>(new ServiceLoaderBasedPluginLocator<>(DAGExecutionPlugin.class), new PropertyBasedPluginLocator<>(DAGExecutionPlugin.class, PLUGINS_CONF_KEY));
    apexPluginDispatcher = new DefaultApexPluginDispatcher(locator, appContext, dnmgr, stats);
    dnmgr.apexPluginDispatcher = apexPluginDispatcher;
    addService(apexPluginDispatcher);
    apexPluginDispatcher.dispatch(new ApexPluginDispatcher.DAGChangeEvent(dnmgr.getLogicalPlan()));
}
Also used : ChainedPluginLocator(org.apache.apex.engine.plugin.loaders.ChainedPluginLocator) ApexPluginDispatcher(org.apache.apex.engine.plugin.ApexPluginDispatcher) DefaultApexPluginDispatcher(org.apache.apex.engine.plugin.DefaultApexPluginDispatcher) DefaultApexPluginDispatcher(org.apache.apex.engine.plugin.DefaultApexPluginDispatcher) DAGExecutionPlugin(org.apache.apex.engine.api.plugin.DAGExecutionPlugin)

Example 2 with ChainedPluginLocator

use of org.apache.apex.engine.plugin.loaders.ChainedPluginLocator in project apex-core by apache.

the class PluginTests method testStaticPluginLoader.

@Test
public void testStaticPluginLoader() {
    DAGExecutionPlugin plugin1 = new NoOpPlugin();
    DAGExecutionPlugin plugin2 = new DebugPlugin();
    StaticPluginLocator<DAGExecutionPlugin> locator1 = new StaticPluginLocator<>(plugin1);
    StaticPluginLocator<DAGExecutionPlugin> locator2 = new StaticPluginLocator<>(plugin2);
    Collection<DAGExecutionPlugin> discovered1 = locator1.discoverPlugins(conf);
    Assert.assertEquals("Number of plugins discovered ", 1, discovered1.size());
    Assert.assertEquals("Type is NoOpPlugin", discovered1.iterator().next().getClass(), NoOpPlugin.class);
    Assert.assertEquals("Type is NoOpPlugin", discovered1.iterator().next(), plugin1);
    Collection<DAGExecutionPlugin> discovered2 = locator2.discoverPlugins(conf);
    Assert.assertEquals("Number of plugins discovered ", 1, discovered2.size());
    Assert.assertEquals("Type is NoOpPlugin", discovered2.iterator().next().getClass(), DebugPlugin.class);
    Assert.assertEquals("Type is NoOpPlugin", discovered2.iterator().next(), plugin2);
    ChainedPluginLocator<DAGExecutionPlugin> chained = new ChainedPluginLocator<>(locator1, locator2);
    Collection<DAGExecutionPlugin> chainedDiscovered = chained.discoverPlugins(conf);
    Assert.assertEquals("Number of plugins discovered ", 2, chainedDiscovered.size());
    Assert.assertTrue(chainedDiscovered.contains(plugin1));
    Assert.assertTrue(chainedDiscovered.contains(plugin2));
}
Also used : ChainedPluginLocator(org.apache.apex.engine.plugin.loaders.ChainedPluginLocator) StaticPluginLocator(org.apache.apex.engine.plugin.loaders.StaticPluginLocator) DAGExecutionPlugin(org.apache.apex.engine.api.plugin.DAGExecutionPlugin) Test(org.junit.Test)

Aggregations

DAGExecutionPlugin (org.apache.apex.engine.api.plugin.DAGExecutionPlugin)2 ChainedPluginLocator (org.apache.apex.engine.plugin.loaders.ChainedPluginLocator)2 ApexPluginDispatcher (org.apache.apex.engine.plugin.ApexPluginDispatcher)1 DefaultApexPluginDispatcher (org.apache.apex.engine.plugin.DefaultApexPluginDispatcher)1 StaticPluginLocator (org.apache.apex.engine.plugin.loaders.StaticPluginLocator)1 Test (org.junit.Test)1