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 28da149cf59..c1b52d2703f 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 void deletePlugins(Set ids) { plugin.setEnableStatus(false); updateStatus(plugin); } + // reload classloader loadJarToClassLoader(); for (PluginMetadata plugin : plugins) { try { @@ -146,8 +147,7 @@ public void deletePlugins(Set ids) { } pluginParamDao.deletePluginParamsByPluginMetadataIdIn(ids); syncPluginStatus(); - // reload classloader - loadJarToClassLoader(); + } /** @@ -167,7 +167,7 @@ public void updateStatus(PluginMetadata plugin) { 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 @@ private void syncPluginStatus() { 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 {