You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/07/15 10:48:48 UTC

[GitHub] [dolphinscheduler] caishunfeng commented on a diff in pull request #10994: Don't write taskPlugin to db in master/worker

caishunfeng commented on code in PR #10994:
URL: https://github.com/apache/dolphinscheduler/pull/10994#discussion_r922052156


##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/ApiApplicationServer.java:
##########
@@ -32,16 +44,34 @@
 @ComponentScan("org.apache.dolphinscheduler")
 public class ApiApplicationServer {
 
+    private final Logger logger = LoggerFactory.getLogger(ApiApplicationServer.class);
+
     @Autowired
     private TaskPluginManager taskPluginManager;
 
+    @Autowired
+    private PluginDao pluginDao;
+
     public static void main(String[] args) {
         SpringApplication.run(ApiApplicationServer.class);
     }
 
     @EventListener
     public void run(ApplicationReadyEvent readyEvent) {
+        logger.info("Received spring application context ready event will load taskPlugin and write to DB");
         // install task plugin
-        taskPluginManager.installPlugin();
+        taskPluginManager.loadPlugin();
+        for (Map.Entry<String, TaskChannelFactory> entry : taskPluginManager.getTaskChannelFactoryMap().entrySet()) {
+            String taskPluginName = entry.getKey();
+            TaskChannelFactory taskChannelFactory = entry.getValue();
+            List<PluginParams> params = taskChannelFactory.getParams();
+            String paramsJson = PluginParamsTransfer.transferParamsToJson(params);
+
+            PluginDefine pluginDefine = new PluginDefine(taskPluginName, PluginType.TASK.getDesc(), paramsJson);
+            int count = pluginDao.addOrUpdatePluginDefine(pluginDefine);
+            if (count <= 0) {
+                throw new TaskPluginException("Failed to update task plugin: " + taskPluginName);
+            }
+        }

Review Comment:
   nip: it's better to split into a method



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org