This is an automated email from the ASF dual-hosted git repository.

shuming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new 163a5a05e [improve]:Improve plugin (#2744)
163a5a05e is described below

commit 163a5a05ed7f5eb13d9023d875de25925891fb39
Author: linDong <[email protected]>
AuthorDate: Tue Sep 24 09:38:14 2024 +0800

    [improve]:Improve plugin (#2744)
---
 .../manager/service/impl/PluginServiceImpl.java        | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git 
a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/PluginServiceImpl.java
 
b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/PluginServiceImpl.java
index 28da149cf..c1b52d270 100644
--- 
a/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/PluginServiceImpl.java
+++ 
b/manager/src/main/java/org/apache/hertzbeat/manager/service/impl/PluginServiceImpl.java
@@ -123,6 +123,7 @@ public class PluginServiceImpl implements PluginService {
             plugin.setEnableStatus(false);
             updateStatus(plugin);
         }
+        // reload classloader
         loadJarToClassLoader();
         for (PluginMetadata plugin : plugins) {
             try {
@@ -146,8 +147,7 @@ public class PluginServiceImpl implements PluginService {
         }
         pluginParamDao.deletePluginParamsByPluginMetadataIdIn(ids);
         syncPluginStatus();
-        // reload classloader
-        loadJarToClassLoader();
+
     }
 
     /**
@@ -167,7 +167,7 @@ public class PluginServiceImpl implements PluginService {
             PluginMetadata metadata = pluginMetadata.get();
             metadata.setEnableStatus(plugin.getEnableStatus());
             metadataDao.save(metadata);
-            syncPluginStatus();
+            syncSinglePluginStatus(metadata);
         } else {
             throw new IllegalArgumentException("The plugin is not existed");
         }
@@ -368,6 +368,18 @@ public class PluginServiceImpl implements PluginService {
         ITEM_TO_PLUGINMETADATAID_MAP.putAll(itemToPluginMetadataIdMap);
     }
 
+    private void syncSinglePluginStatus(PluginMetadata plugin) {
+        if (plugin == null || CollectionUtils.isEmpty(plugin.getItems())){
+            return;
+        }
+        for (PluginItem item : plugin.getItems()) {
+            PLUGIN_ENABLE_STATUS.put(item.getClassIdentifier(), 
plugin.getEnableStatus());
+            ITEM_TO_PLUGINMETADATAID_MAP.put(item.getClassIdentifier(), 
plugin.getId());
+        }
+
+
+    }
+
     @PostConstruct
     private void initParams() {
         try {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to