Search in sources :

Example 1 with ProcessPlugin

use of org.apache.inlong.manager.workflow.plugin.ProcessPlugin in project incubator-inlong by apache.

the class ServiceTaskListenerFactory method acceptPlugin.

@Override
public void acceptPlugin(Plugin plugin) {
    if (!(plugin instanceof ProcessPlugin)) {
        return;
    }
    ProcessPlugin processPlugin = (ProcessPlugin) plugin;
    Map<DataSourceOperateListener, EventSelector> pluginDsOperateListeners = processPlugin.createSourceOperateListeners();
    if (MapUtils.isNotEmpty(pluginDsOperateListeners)) {
        sourceOperateListeners.putAll(processPlugin.createSourceOperateListeners());
    }
    Map<SinkOperateListener, EventSelector> pluginSinkOperateListeners = processPlugin.createSinkOperateListeners();
    if (MapUtils.isNotEmpty(pluginSinkOperateListeners)) {
        sinkOperateListeners.putAll(pluginSinkOperateListeners);
    }
    Map<QueueOperateListener, EventSelector> pluginQueueOperateListeners = processPlugin.createQueueOperateListeners();
    if (MapUtils.isNotEmpty(pluginQueueOperateListeners)) {
        queueOperateListeners.putAll(pluginQueueOperateListeners);
    }
    Map<SortOperateListener, EventSelector> pluginSortOperateListeners = processPlugin.createSortOperateListeners();
    if (MapUtils.isNotEmpty(pluginSortOperateListeners)) {
        sortOperateListeners.putAll(pluginSortOperateListeners);
    }
}
Also used : QueueOperateListener(org.apache.inlong.manager.workflow.event.task.QueueOperateListener) CreateHiveTableEventSelector(org.apache.inlong.manager.service.thirdparty.hive.CreateHiveTableEventSelector) SourceDeleteEventSelector(org.apache.inlong.manager.service.source.listener.SourceDeleteEventSelector) PulsarEventSelector(org.apache.inlong.manager.service.thirdparty.mq.PulsarEventSelector) TubeEventSelector(org.apache.inlong.manager.service.thirdparty.mq.TubeEventSelector) ZkDisabledEventSelector(org.apache.inlong.manager.service.thirdparty.sort.ZkDisabledEventSelector) SourceRestartEventSelector(org.apache.inlong.manager.service.source.listener.SourceRestartEventSelector) SourceStopEventSelector(org.apache.inlong.manager.service.source.listener.SourceStopEventSelector) ZkEnabledEventSelector(org.apache.inlong.manager.service.thirdparty.sort.ZkEnabledEventSelector) EventSelector(org.apache.inlong.manager.workflow.event.EventSelector) SortOperateListener(org.apache.inlong.manager.workflow.event.task.SortOperateListener) DataSourceOperateListener(org.apache.inlong.manager.workflow.event.task.DataSourceOperateListener) SinkOperateListener(org.apache.inlong.manager.workflow.event.task.SinkOperateListener) ProcessPlugin(org.apache.inlong.manager.workflow.plugin.ProcessPlugin)

Example 2 with ProcessPlugin

use of org.apache.inlong.manager.workflow.plugin.ProcessPlugin in project incubator-inlong by apache.

the class PluginClassLoaderTest method testLoadPlugin.

@Test
public void testLoadPlugin() {
    String path = this.getClass().getClassLoader().getResource("").getPath();
    PluginClassLoader pluginClassLoader = PluginClassLoader.getFromPluginUrl(path + "plugins", Thread.currentThread().getContextClassLoader());
    Map<String, PluginDefinition> pluginDefinitionMap = pluginClassLoader.getPluginDefinitions();
    Assert.assertEquals(1, pluginDefinitionMap.size());
    PluginDefinition pluginDefinition = Lists.newArrayList(pluginDefinitionMap.values()).get(0);
    Assert.assertNotNull(pluginDefinition);
    String pluginClass = pluginDefinition.getPluginClass();
    Assert.assertTrue(StringUtils.isNotEmpty(pluginClass));
    try {
        Class cls = pluginClassLoader.loadClass(pluginClass);
        Plugin plugin = (Plugin) cls.getDeclaredConstructor().newInstance();
        Assert.assertTrue(plugin instanceof ProcessPlugin);
    } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
        Assert.assertTrue(e instanceof ClassNotFoundException);
        Assert.fail();
    }
}
Also used : InvocationTargetException(java.lang.reflect.InvocationTargetException) PluginDefinition(org.apache.inlong.manager.workflow.plugin.PluginDefinition) ProcessPlugin(org.apache.inlong.manager.workflow.plugin.ProcessPlugin) Plugin(org.apache.inlong.manager.workflow.plugin.Plugin) ProcessPlugin(org.apache.inlong.manager.workflow.plugin.ProcessPlugin) Test(org.junit.Test)

Aggregations

ProcessPlugin (org.apache.inlong.manager.workflow.plugin.ProcessPlugin)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 SourceDeleteEventSelector (org.apache.inlong.manager.service.source.listener.SourceDeleteEventSelector)1 SourceRestartEventSelector (org.apache.inlong.manager.service.source.listener.SourceRestartEventSelector)1 SourceStopEventSelector (org.apache.inlong.manager.service.source.listener.SourceStopEventSelector)1 CreateHiveTableEventSelector (org.apache.inlong.manager.service.thirdparty.hive.CreateHiveTableEventSelector)1 PulsarEventSelector (org.apache.inlong.manager.service.thirdparty.mq.PulsarEventSelector)1 TubeEventSelector (org.apache.inlong.manager.service.thirdparty.mq.TubeEventSelector)1 ZkDisabledEventSelector (org.apache.inlong.manager.service.thirdparty.sort.ZkDisabledEventSelector)1 ZkEnabledEventSelector (org.apache.inlong.manager.service.thirdparty.sort.ZkEnabledEventSelector)1 EventSelector (org.apache.inlong.manager.workflow.event.EventSelector)1 DataSourceOperateListener (org.apache.inlong.manager.workflow.event.task.DataSourceOperateListener)1 QueueOperateListener (org.apache.inlong.manager.workflow.event.task.QueueOperateListener)1 SinkOperateListener (org.apache.inlong.manager.workflow.event.task.SinkOperateListener)1 SortOperateListener (org.apache.inlong.manager.workflow.event.task.SortOperateListener)1 Plugin (org.apache.inlong.manager.workflow.plugin.Plugin)1 PluginDefinition (org.apache.inlong.manager.workflow.plugin.PluginDefinition)1 Test (org.junit.Test)1