healchow commented on a change in pull request #2319:
URL: https://github.com/apache/incubator-inlong/pull/2319#discussion_r792318165



##########
File path: 
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/plugin/ProcessPlugin.java
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.plugin;
+
+import java.util.Map;
+import org.apache.inlong.manager.common.event.EventSelector;
+import org.apache.inlong.manager.common.event.task.DatasourceOperateListener;
+import org.apache.inlong.manager.common.event.task.QueueOperateListener;
+import org.apache.inlong.manager.common.event.task.SortOperateListener;
+import org.apache.inlong.manager.common.event.task.StorageOperateListener;
+
+public interface ProcessPlugin extends Plugin {
+
+    default Map<DatasourceOperateListener, EventSelector> 
createDSOperateListeners() {

Review comment:
       It is better to change all `DS` to `Stream`.

##########
File path: 
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/event/task/DatasourceOperateListener.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.event.task;
+
+import org.apache.inlong.manager.common.event.ListenerResult;
+import org.apache.inlong.manager.common.model.WorkflowContext;
+
+public interface DatasourceOperateListener extends TaskEventListener {
+
+    DatasourceOperateListener DEFAULT_DS_OPERATE_LISTENER = new 
DatasourceOperateListener() {

Review comment:
       It is better to change all `DS` to `Stream`.

##########
File path: 
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/thirdpart/hive/HiveStoreEventSelector.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.thirdpart.hive;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.inlong.manager.common.enums.BizConstant;
+import org.apache.inlong.manager.common.event.EventSelector;
+import org.apache.inlong.manager.common.model.WorkflowContext;
+import org.apache.inlong.manager.dao.entity.DataStreamEntity;
+import org.apache.inlong.manager.dao.mapper.DataStreamEntityMapper;
+import org.apache.inlong.manager.service.core.StorageService;
+import 
org.apache.inlong.manager.service.workflow.business.BusinessResourceWorkflowForm;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class HiveStoreEventSelector implements EventSelector {

Review comment:
       `HiveEventSelector` is much clearer.

##########
File path: 
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/plugin/PluginsService.java
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.core.plugin;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.inlong.manager.common.plugin.Plugin;
+import org.apache.inlong.manager.common.plugin.PluginBinder;
+import org.apache.inlong.manager.common.plugin.PluginDefinition;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class PluginsService {

Review comment:
       Please use `PluginService`, as it's not recommended to use plural forms 
when nouns are involved in class naming.

##########
File path: 
inlong-manager/manager-plugin-examples/src/main/java/org/apache/inlong/manager/plugin/EmptyProcessPlugin.java
##########
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.plugin;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import org.apache.inlong.manager.common.event.EventSelector;
+import org.apache.inlong.manager.common.event.task.DatasourceOperateListener;
+import org.apache.inlong.manager.common.event.task.QueueOperateListener;
+import org.apache.inlong.manager.common.event.task.SortOperateListener;
+import org.apache.inlong.manager.common.event.task.StorageOperateListener;
+import org.apache.inlong.manager.common.plugin.ProcessPlugin;
+
+public class EmptyProcessPlugin implements ProcessPlugin {
+
+    @Override
+    public Map<DatasourceOperateListener, EventSelector> 
createDSOperateListeners() {

Review comment:
       ditto.

##########
File path: 
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/event/task/DatasourceOperateListener.java
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.event.task;
+
+import org.apache.inlong.manager.common.event.ListenerResult;
+import org.apache.inlong.manager.common.model.WorkflowContext;
+
+public interface DatasourceOperateListener extends TaskEventListener {

Review comment:
       change to `DataSourceXxx` pls.

##########
File path: inlong-manager/pom.xml
##########
@@ -264,6 +264,12 @@
                 <artifactId>jackson-datatype-jsr310</artifactId>
                 <version>${jackson.jsr310.version}</version>
             </dependency>
+            <dependency>
+                <groupId>com.fasterxml.jackson.dataformat</groupId>
+                <artifactId>jackson-dataformat-yaml</artifactId>
+                <version>${jackson.version}</version>
+            </dependency>
+

Review comment:
       Use at most 1 empty line.

##########
File path: 
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/core/plugin/PluginsService.java
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.core.plugin;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.inlong.manager.common.plugin.Plugin;
+import org.apache.inlong.manager.common.plugin.PluginBinder;
+import org.apache.inlong.manager.common.plugin.PluginDefinition;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class PluginsService {
+
+    public static final String DEFAULT_PLUGIN_LOC = "/plugins";
+
+    @Setter
+    @Getter
+    @Value("${plugin.location?:}")

Review comment:
       `@Value("${plugin.location?:''}")`, wouldn't it be better to use an 
empty string instead of null?

##########
File path: 
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/plugin/PluginClassLoaderTest.java
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.core.plugin;
+
+import com.google.common.collect.Lists;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.inlong.manager.common.plugin.Plugin;
+import org.apache.inlong.manager.common.plugin.PluginDefinition;
+import org.apache.inlong.manager.common.plugin.ProcessPlugin;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PluginClassLoaderTest {
+
+    @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.assertTrue(pluginDefinitionMap.size() == 1);
+        PluginDefinition pluginDefinition = 
Lists.newArrayList(pluginDefinitionMap.values()).get(0);
+        Assert.assertTrue(pluginDefinition != null);
+        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) {
+            System.out.println(e.getMessage());

Review comment:
       ditto.

##########
File path: 
inlong-manager/manager-service/src/test/java/org/apache/inlong/manager/service/core/plugin/JarHellTest.java
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.core.plugin;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class JarHellTest {
+
+    @Test
+    public void testJavaVersion() {
+        JarHell.checkJavaVersion("test_java", "1.8");
+        try {
+            JarHell.checkJavaVersion("test_java", "1.81");
+        } catch (Exception e) {
+            System.out.println(e.getMessage());

Review comment:
       Please use `Assert` instead of `System.out`.

##########
File path: 
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/thirdpart/hive/HiveStoreEventSelector.java
##########
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.service.thirdpart.hive;
+
+import java.util.List;
+import java.util.stream.Collectors;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.inlong.manager.common.enums.BizConstant;
+import org.apache.inlong.manager.common.event.EventSelector;
+import org.apache.inlong.manager.common.model.WorkflowContext;
+import org.apache.inlong.manager.dao.entity.DataStreamEntity;
+import org.apache.inlong.manager.dao.mapper.DataStreamEntityMapper;
+import org.apache.inlong.manager.service.core.StorageService;
+import 
org.apache.inlong.manager.service.workflow.business.BusinessResourceWorkflowForm;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+@Slf4j
+public class HiveStoreEventSelector implements EventSelector {
+
+    @Autowired
+    private StorageService storageService;
+    @Autowired
+    private DataStreamEntityMapper streamMapper;
+
+    @Override
+    public boolean accept(WorkflowContext context) {
+        BusinessResourceWorkflowForm form = (BusinessResourceWorkflowForm) 
context.getProcessForm();
+        String groupId = form.getInlongGroupId();
+        List<String> dsForHive = 
storageService.filterStreamIdByStorageType(groupId, BizConstant.STORAGE_HIVE,
+                streamMapper.selectByGroupId(groupId)
+                        .stream()

Review comment:
       There may be occurred NPE.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to