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()));
}
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));
}
Aggregations