From 60e69be133aeb2409acd03baa0a85ccac1e5e784 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sat, 27 Jul 2024 22:39:44 +0800 Subject: [PATCH 1/7] [doc] : add committer introduction doc --- home/blog/2024-07-27-new-committer.md | 36 ++++++++++++++++++ .../2024-07-27-new-committer.md | 37 +++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 home/blog/2024-07-27-new-committer.md create mode 100644 home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md diff --git a/home/blog/2024-07-27-new-committer.md b/home/blog/2024-07-27-new-committer.md new file mode 100644 index 00000000000..26bfc69bba6 --- /dev/null +++ b/home/blog/2024-07-27-new-committer.md @@ -0,0 +1,36 @@ +--- +title: Welcome to HertzBeat Community Committer! +author: linDong +author_title: linDong +author_url: https://github.com/Yanshuming1 +author_image_url: https://avatars.githubusercontent.com/u/30208283?v=4 +tags: [opensource, practice] +keywords: [open source monitoring system, alerting system] +--- + +![hertzBeathertzBeat](/img/blog/new-committer.png) + +> It's an honor for me to become a Committer of Apache Hertzbeat +## Personal introduction + +I graduated in 2023 and am currently working as a Java developer in an Internet company. + +## First met Apache Hertzbeat + +After graduation and working for half a year, I had the idea of getting involved in open source. However, when searching for open source projects on GitHub, I found that many communities were not very active, and the official documentation was not complete, making it quite difficult to start with the projects. Therefore, I put the matter of open source on hold for the time being. + +One day, I saw a post by Senior Xiaobao on a certain platform and was immediately intrigued. I then privately messaged Xiaobao to consult about open source matters. Senior Xiaobao was extremely enthusiastic and meticulous in explaining many aspects of open source to me and recommended the Hertzbeat project. + +## My first PR + +I downloaded the source code of Hertzbeat and compiled and tested it according to the documentation. Then, when clicking on the functions on the page, I discovered a bug in the front-end pop-up window. So, I submitted my first issue and successfully claimed this issue, thus starting my first PR. + +## Keep active in community + +After submitting the first PR, I continuously followed the issues in the Hertzbeat community and attempted to solve the existing problems. I have successively completed tasks such as specifying @people on WeChat, integrating AI, adding a PrestoDB monitor, modifying bugs, and contributing to the official website documentation. + +## Reward +After several months of contributing to open source, I have reaped a lot. I have learned the business logic in the code, code norms, some technical frameworks that I have never used before, and some algorithms. It can be said that I have benefited greatly. + +## Conclusion +Becoming a Committer of Apache Hertzbeat is a very meaningful thing for me. In the future, I will continue to contribute to the Apache Hertzbeat community. I also hope that Apache Hertzbeat can successfully graduate from the incubator and that the community will become better and better. \ No newline at end of file diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md new file mode 100644 index 00000000000..463a89d1a35 --- /dev/null +++ b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md @@ -0,0 +1,37 @@ +--- +title: 热烈欢迎 HertzBeat 小伙伴新晋社区 Committer! +author: linDong +author_title: linDong +author_url: https://github.com/Yanshuming1 +author_image_url: https://avatars.githubusercontent.com/u/131688897?v=4 +tags: [opensource, practice] +keywords: [open source monitoring system, alerting system] +--- + +![hertzBeat](/img/blog/new-committer.png) + +> 非常荣幸能成为Apache Hertzbeat的Committer +## 个人介绍 + +本人是2023年毕业,目前在一家互联网公司担任java开发工程师。 + +## 初识 Apache Hertzbeat +毕业之后,工作了半年,萌生出接触开源的想法。然而,在 GitHub 上搜索开源项目时,发现诸多社区活跃度欠佳,官方文档也不完善,致使项目上手难度颇大,因此开源之事暂且搁置。 +某天,在某平台看到小宝大佬的一个帖子,我瞬间兴趣盎然,随即私聊小宝,咨询开源相关事宜。小宝大佬极其热情且细致地为我讲解了不少开源方面的情况,并向我推荐了 Hertzbeat 这个项目。 + +## 第一个PR + +我down了 Hertzbeat 的源码,并按照文档进行编译和测试,然后在页面点击功能的时候发现了一个前端弹窗的bug,所以我提交了自己的第一个issue,并且我成功认领了此issue +于是开启了我的第一个PR。 + +## 持续贡献 + +在提交第一个 PR 之后,我持续关注 Hertzbeat 社区的 issue ,且尝试去解决当中存在的问题。相继完成了微信指定艾特人、接入 AI 、添加 PrestoDB 监控器、Bug 修改以及官网文档贡献等工作。 + +## 收获 + +经过几个月对开源的贡献,我收获满满,学习到了代码中的业务逻辑、代码规范,一些此前未曾使用过的技术框架,还有一些算法,可谓是获益良多。 + +## 结语 + +成为Apache Hertzbeat的Committer于我而言是很有意义对事情,今后我也会持续对Apache Hertzbeat社区贡献下去,也希望Apache Hertzbeat能顺利从孵化器毕业,希望社区越来越好。 \ No newline at end of file From 9b626b9326514c4ce460b6229fd8a0eba59a48b3 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sun, 28 Jul 2024 14:20:09 +0800 Subject: [PATCH 2/7] [doc] : add committer introduction doc --- .../{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} | 0 .../{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename home/blog/{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} (100%) rename home/i18n/zh-cn/docusaurus-plugin-content-blog/{2024-07-27-new-committer.md => 2024-07-28-new-committer.md} (100%) diff --git a/home/blog/2024-07-27-new-committer.md b/home/blog/2024-07-28-new-committer.md similarity index 100% rename from home/blog/2024-07-27-new-committer.md rename to home/blog/2024-07-28-new-committer.md diff --git a/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md b/home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-28-new-committer.md similarity index 100% rename from home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-27-new-committer.md rename to home/i18n/zh-cn/docusaurus-plugin-content-blog/2024-07-28-new-committer.md From 9319d61a2d9f0e03ab74aa55c3608985cc6fcab8 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sun, 25 Aug 2024 19:53:49 +0800 Subject: [PATCH 3/7] [task]:Supports plug-in custom parameters --- .../component/alerter/DispatcherAlarm.java | 2 +- .../manager/controller/PluginController.java | 17 +++ .../hertzbeat/manager/dao/PluginParamDao.java | 49 ++++++++ .../manager/pojo/dto/PluginParam.java | 101 ++++++++++++++++ .../manager/service/PluginService.java | 20 +++- .../service/impl/PluginServiceImpl.java | 109 ++++++++++++++++-- .../manager/service/PluginServiceTest.java | 7 +- .../org/apache/hertzbeat/plugin/Plugin.java | 10 ++ 8 files changed, 305 insertions(+), 10 deletions(-) create mode 100644 manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java create mode 100644 manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java b/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java index 0e688e1c7ce..1534d473a27 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java @@ -131,7 +131,7 @@ public void run() { // Notice distribution sendNotify(alert); // Execute the plugin if enable - pluginService.pluginExecute(Plugin.class, plugin -> plugin.alert(alert)); + pluginService.pluginExecute(Plugin.class, plugin -> plugin.alert(alert),(plugin, configMapList) -> plugin.alert(alert, configMapList)); } } catch (IgnoreException ignored) { } catch (InterruptedException e) { diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java b/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java index 1fb73ada760..0bd5d83c6fd 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java @@ -26,7 +26,9 @@ import lombok.RequiredArgsConstructor; import org.apache.hertzbeat.common.entity.dto.Message; import org.apache.hertzbeat.common.entity.dto.PluginUpload; +import org.apache.hertzbeat.common.entity.manager.ParamDefine; import org.apache.hertzbeat.common.entity.manager.PluginMetadata; +import org.apache.hertzbeat.manager.pojo.dto.PluginParam; import org.apache.hertzbeat.manager.service.PluginService; import org.springframework.data.domain.Page; import org.springframework.http.ResponseEntity; @@ -85,4 +87,19 @@ public ResponseEntity> updatePluginStatus(@RequestBody PluginMetad pluginService.updateStatus(plugin); return ResponseEntity.ok(Message.success("Update success")); } + + @GetMapping("/getParamDefine") + @Operation(summary = "get param define", description = "get param define by jar path") + public ResponseEntity>> getParamDefine(@RequestParam Long pluginMetadataId) { + List plugins = pluginService.getParamDefine(pluginMetadataId); + return ResponseEntity.ok(Message.success(plugins)); + } + + @PostMapping("/saveParams") + @Operation(summary = "get param define", description = "get param define by jar path") + public ResponseEntity> saveParams(@RequestBody List pluginParams) { + pluginService.savePluginParam(pluginParams); + return ResponseEntity.ok(Message.success(true)); + } + } diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java b/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java new file mode 100644 index 00000000000..d1a3eb64248 --- /dev/null +++ b/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java @@ -0,0 +1,49 @@ +/* + * 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.hertzbeat.manager.dao; + +import java.util.List; +import java.util.Set; +import org.apache.hertzbeat.common.entity.manager.Param; +import org.apache.hertzbeat.manager.pojo.dto.PluginParam; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * PluginParamDao database operations + */ +public interface PluginParamDao extends JpaRepository { + + /** + * Query the list of parameters associated with the monitoring ID' + * @param pluginMetadataId Monitor ID + * @return list of parameter values + */ + List findParamsByPluginMetadataId(Long pluginMetadataId); + + /** + * Remove the parameter list associated with the pluginMetadata ID based on it + * @param pluginMetadataId Monitor Id + */ + void deleteParamsByPluginMetadataId(long pluginMetadataId); + + /** + * Remove the parameter list associated with the pluginMetadata ID list based on it + * @param pluginMetadataIds Monitoring ID List + */ + void deleteParamsByPluginMetadataIdIn(Set pluginMetadataIds); +} diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java new file mode 100644 index 00000000000..f946ea90fd8 --- /dev/null +++ b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java @@ -0,0 +1,101 @@ +/* + * 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.hertzbeat.manager.pojo.dto; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.*; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; +import java.time.LocalDateTime; +import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY; +import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_WRITE; + +/** + * PluginParam + */ +@Entity +@Table(name = "hzb_plugin_param", indexes = { @Index(columnList = "pluginMetadataId") }, + uniqueConstraints = @UniqueConstraint(columnNames = {"pluginMetadataId", "field"})) +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Schema(description = "Parameter Entity") +@EntityListeners(AuditingEntityListener.class) +public class PluginParam { + + /** + * Parameter primary key index ID + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Schema(title = "Parameter primary key index ID", example = "87584674384", accessMode = READ_ONLY) + private Long id; + /** + * Monitor ID + */ + @Schema(title = "Plugin task ID", example = "875846754543", accessMode = READ_WRITE) + @NotNull + private Long pluginMetadataId; + + /** + * Parameter Field Identifier + */ + @Schema(title = "Parameter identifier field", example = "port", accessMode = READ_WRITE) + @Size(max = 100) + @NotNull + private String field; + + /** + * Param Value + */ + @Schema(title = "parameter values", example = "8080", accessMode = READ_WRITE) + @Size(max = 8126) + @Column(length = 8126) + private String paramValue; + + /** + * Parameter type 0: number 1: string 2: encrypted string 3: json string mapped by map + */ + @Schema(title = "Parameter types 0: number 1: string 2: encrypted string 3:map mapped json string 4:arrays string", + accessMode = READ_WRITE) + @Min(0) + private byte type; + + /** + * Record create time + */ + @Schema(title = "Record create time", example = "1612198922000", accessMode = READ_ONLY) + @CreatedDate + private LocalDateTime gmtCreate; + + /** + * Record the latest modification time + */ + @Schema(title = "Record modify time", example = "1612198444000", accessMode = READ_ONLY) + @LastModifiedDate + private LocalDateTime gmtUpdate; + +} diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java index 23d01a30be2..634495631cd 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java @@ -17,10 +17,15 @@ package org.apache.hertzbeat.manager.service; +import java.util.List; import java.util.Set; +import java.util.function.BiConsumer; import java.util.function.Consumer; import org.apache.hertzbeat.common.entity.dto.PluginUpload; +import org.apache.hertzbeat.common.entity.job.Configmap; +import org.apache.hertzbeat.common.entity.manager.ParamDefine; import org.apache.hertzbeat.common.entity.manager.PluginMetadata; +import org.apache.hertzbeat.manager.pojo.dto.PluginParam; import org.springframework.data.domain.Page; /** @@ -58,7 +63,7 @@ public interface PluginService { * @param execute run plugin logic * @param plugin type */ - void pluginExecute(Class clazz, Consumer execute); + void pluginExecute(Class clazz, Consumer execute, BiConsumer> biConsumer); /** * delete plugin @@ -69,4 +74,17 @@ public interface PluginService { void updateStatus(PluginMetadata plugin); + /** + * get param define + * @param jarPath + * @return + */ + List getParamDefine(Long pluginMetadataId); + + /** + * save plugin param + * @param params + */ + void savePluginParam(List params); + } 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 162d4bc394a..9918b9b5624 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 @@ -17,6 +17,7 @@ package org.apache.hertzbeat.manager.service.impl; +import com.alibaba.fastjson.JSON; import jakarta.persistence.criteria.Predicate; import java.io.File; import java.io.FileOutputStream; @@ -39,9 +40,11 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; @@ -49,17 +52,23 @@ import org.apache.commons.io.FileUtils; import org.apache.hertzbeat.common.constants.PluginType; import org.apache.hertzbeat.common.entity.dto.PluginUpload; +import org.apache.hertzbeat.common.entity.job.Configmap; +import org.apache.hertzbeat.common.entity.manager.ParamDefine; import org.apache.hertzbeat.common.entity.manager.PluginItem; import org.apache.hertzbeat.common.entity.manager.PluginMetadata; import org.apache.hertzbeat.common.support.exception.CommonException; import org.apache.hertzbeat.manager.dao.PluginItemDao; import org.apache.hertzbeat.manager.dao.PluginMetadataDao; +import org.apache.hertzbeat.manager.dao.PluginParamDao; +import org.apache.hertzbeat.manager.pojo.dto.PluginParam; import org.apache.hertzbeat.manager.service.PluginService; import org.apache.hertzbeat.plugin.Plugin; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.yaml.snakeyaml.Yaml; /** * plugin service @@ -73,6 +82,8 @@ public class PluginServiceImpl implements PluginService { private final PluginItemDao itemDao; + private final PluginParamDao pluginParamDao; + public static Map, PluginType> PLUGIN_TYPE_MAPPING = new HashMap<>(); /** @@ -80,6 +91,20 @@ public class PluginServiceImpl implements PluginService { */ private static final Map PLUGIN_ENABLE_STATUS = new ConcurrentHashMap<>(); + /** + * plugin param define + */ + private static final Map> PARAMS_Define_MAP = new ConcurrentHashMap<>(); + + /** + * plugin params + */ + private static final Map> PARAMS_MAP = new ConcurrentHashMap<>(); + + /** + * pluginItem Mapping pluginId + */ + private static final Map ITEM_TO_PLUGINMETADATAID_MAP = new ConcurrentHashMap<>(); private final List pluginClassLoaders = new ArrayList<>(); @@ -106,6 +131,8 @@ public void deletePlugins(Set ids) { } // delete metadata metadataDao.deleteById(plugin.getId()); + syncPluginParamMap(plugin.getId(),null,true); + pluginParamDao.deleteParamsByPluginMetadataId(plugin.getId()); } catch (IOException e) { throw new RuntimeException(e); } @@ -139,6 +166,32 @@ public void updateStatus(PluginMetadata plugin) { } } + @Override + public List getParamDefine(Long pluginMetadataId) { + if (PARAMS_Define_MAP.containsKey(pluginMetadataId)) { + return PARAMS_Define_MAP.get(pluginMetadataId); + } + return List.of(); + } + + @Override + public void savePluginParam(List params) { + if (CollectionUtils.isEmpty(params)) { + return; + } + pluginParamDao.saveAll(params); + syncPluginParamMap(params.get(0).getPluginMetadataId(),params,false); + } + + private void syncPluginParamMap(Long pluginMetadataId, List params,boolean isDelete) { + if (isDelete) { + PARAMS_MAP.remove(pluginMetadataId); + return; + } + List configmapList = params.stream().map(item -> new Configmap(item.getField(), item.getParamValue(), item.getType())).toList(); + PARAMS_MAP.put(pluginMetadataId,configmapList); + } + static { PLUGIN_TYPE_MAPPING.put(Plugin.class, PluginType.POST_ALERT); } @@ -268,13 +321,33 @@ public Page getPlugins(String search, int pageIndex, int pageSiz private void syncPluginStatus() { List plugins = metadataDao.findAll(); Map statusMap = new HashMap<>(); + Map itemToPluginMetadataIdMap = new HashMap<>(); for (PluginMetadata plugin : plugins) { for (PluginItem item : plugin.getItems()) { statusMap.put(item.getClassIdentifier(), plugin.getEnableStatus()); + itemToPluginMetadataIdMap.put(item.getClassIdentifier(), plugin.getId()); } } PLUGIN_ENABLE_STATUS.clear(); PLUGIN_ENABLE_STATUS.putAll(statusMap); + ITEM_TO_PLUGINMETADATAID_MAP.clear(); + ITEM_TO_PLUGINMETADATAID_MAP.putAll(itemToPluginMetadataIdMap); + } + + @PostConstruct + private void initParams(){ + try { + List params = pluginParamDao.findAll(); + Map> content = params.stream() + .collect(Collectors.groupingBy(PluginParam::getPluginMetadataId)); + + for (Map.Entry> entry : content.entrySet()) { + syncPluginParamMap(entry.getKey(), entry.getValue(),false); + } + } catch (Exception e) { + log.error("Failed to init params:{}", e.getMessage()); + throw new CommonException("Failed to init params:" + e.getMessage()); + } } /** @@ -288,14 +361,19 @@ private void loadJarToClassLoader() { pluginClassLoader.close(); } } - pluginClassLoaders.clear(); - System.gc(); + + if (!pluginClassLoaders.isEmpty()) { + pluginClassLoaders.clear(); + System.gc(); + } + PARAMS_Define_MAP.clear(); List plugins = metadataDao.findPluginMetadataByEnableStatusTrue(); for (PluginMetadata metadata : plugins) { - List urls = loadLibInPlugin(metadata.getJarFilePath()); + List urls = loadLibInPlugin(metadata.getJarFilePath(),metadata.getId()); urls.add(new File(metadata.getJarFilePath()).toURI().toURL()); pluginClassLoaders.add(new URLClassLoader(urls.toArray(new URL[0]), Plugin.class.getClassLoader())); } + } catch (MalformedURLException e) { log.error("Failed to load plugin:{}", e.getMessage()); throw new CommonException("Failed to load plugin:" + e.getMessage()); @@ -308,19 +386,24 @@ private void loadJarToClassLoader() { * loading other JAR files that are dependencies for the plugin * * @param pluginJarPath jar file path + * @param pluginMetadataId * @return urls */ @SneakyThrows - private List loadLibInPlugin(String pluginJarPath) { + private List loadLibInPlugin(String pluginJarPath, Long pluginMetadataId) { File libDir = new File(getOtherLibDir(pluginJarPath)); FileUtils.forceMkdir(libDir); List libUrls = new ArrayList<>(); try (JarFile jarFile = new JarFile(pluginJarPath)) { Enumeration entries = jarFile.entries(); + Yaml yaml = new Yaml(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); File file = new File(libDir, entry.getName()); - if (!entry.isDirectory() && entry.getName().endsWith(".jar")) { + if (entry.isDirectory()) { + continue; + } + if (entry.getName().endsWith(".jar")) { if (!file.getParentFile().exists()) { FileUtils.createParentDirectories(file); } @@ -335,18 +418,30 @@ private List loadLibInPlugin(String pluginJarPath) { out.flush(); } } + if ((entry.getName().contains("define")) && (entry.getName().endsWith(".yml") || entry.getName().endsWith(".yaml"))) { + try (InputStream ymlInputStream = jarFile.getInputStream(entry)) { + List params = yaml.loadAs(ymlInputStream, List.class); + PARAMS_Define_MAP.putIfAbsent(pluginMetadataId, params); + } + } } } return libUrls; } @Override - public void pluginExecute(Class clazz, Consumer execute) { + public void pluginExecute(Class clazz, Consumer execute, BiConsumer> biConsumer) { for (URLClassLoader pluginClassLoader : pluginClassLoaders) { ServiceLoader load = ServiceLoader.load(clazz, pluginClassLoader); for (T t : load) { if (pluginIsEnable(t.getClass())) { - execute.accept(t); + Long pluginId = ITEM_TO_PLUGINMETADATAID_MAP.get(t.getClass().getName()); + List configmapList = PARAMS_MAP.get(pluginId); + if (CollectionUtils.isEmpty(configmapList)) { + execute.accept(t); + } else { + biConsumer.accept(t, configmapList); + } } } } diff --git a/manager/src/test/java/org/apache/hertzbeat/manager/service/PluginServiceTest.java b/manager/src/test/java/org/apache/hertzbeat/manager/service/PluginServiceTest.java index ed94f69c6c6..39cf4365a93 100644 --- a/manager/src/test/java/org/apache/hertzbeat/manager/service/PluginServiceTest.java +++ b/manager/src/test/java/org/apache/hertzbeat/manager/service/PluginServiceTest.java @@ -39,6 +39,7 @@ import org.apache.hertzbeat.common.entity.manager.PluginMetadata; import org.apache.hertzbeat.manager.dao.PluginItemDao; import org.apache.hertzbeat.manager.dao.PluginMetadataDao; +import org.apache.hertzbeat.manager.dao.PluginParamDao; import org.apache.hertzbeat.manager.service.impl.PluginServiceImpl; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -60,16 +61,20 @@ class PluginServiceTest { @InjectMocks private PluginServiceImpl pluginService; + @Mock private PluginMetadataDao metadataDao; + @Mock + private PluginParamDao pluginParamDao; + @Mock private PluginItemDao itemDao; @BeforeEach void setUp() { - pluginService = new PluginServiceImpl(metadataDao, itemDao); + pluginService = new PluginServiceImpl(metadataDao, itemDao,pluginParamDao); } @Test diff --git a/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java b/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java index d72632925b5..2bf1374d618 100644 --- a/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java +++ b/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java @@ -17,7 +17,9 @@ package org.apache.hertzbeat.plugin; +import java.util.List; import org.apache.hertzbeat.common.entity.alerter.Alert; +import org.apache.hertzbeat.common.entity.job.Configmap; /** * Plugin @@ -28,4 +30,12 @@ public interface Plugin { * execute when alert */ void alert(Alert alert); + + /** + * Supports user-defined parameters + * @param alert + * @param params + */ + void alert(Alert alert, List params); + } From 7ecdd5fc378146508f512f637e6df7f226faa4d0 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sun, 25 Aug 2024 20:09:13 +0800 Subject: [PATCH 4/7] [task]:Supports plug-in custom parameters --- .../component/alerter/DispatcherAlarm.java | 2 +- .../hertzbeat/manager/dao/PluginParamDao.java | 1 - .../hertzbeat/manager/pojo/dto/PluginParam.java | 17 +++++++++++++---- .../manager/service/PluginService.java | 5 ++--- .../manager/service/impl/PluginServiceImpl.java | 15 +++++++-------- .../org/apache/hertzbeat/plugin/Plugin.java | 2 -- 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java b/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java index 1534d473a27..c543c08a1ca 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/DispatcherAlarm.java @@ -131,7 +131,7 @@ public void run() { // Notice distribution sendNotify(alert); // Execute the plugin if enable - pluginService.pluginExecute(Plugin.class, plugin -> plugin.alert(alert),(plugin, configMapList) -> plugin.alert(alert, configMapList)); + pluginService.pluginExecute(Plugin.class, plugin -> plugin.alert(alert), (plugin, configMapList) -> plugin.alert(alert, configMapList)); } } catch (IgnoreException ignored) { } catch (InterruptedException e) { diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java b/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java index d1a3eb64248..d7fbeaa96af 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java @@ -19,7 +19,6 @@ import java.util.List; import java.util.Set; -import org.apache.hertzbeat.common.entity.manager.Param; import org.apache.hertzbeat.manager.pojo.dto.PluginParam; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java index f946ea90fd8..b92948f2b10 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParam.java @@ -16,11 +16,23 @@ */ package org.apache.hertzbeat.manager.pojo.dto; + +import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY; +import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_WRITE; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.persistence.*; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Index; +import jakarta.persistence.Table; +import jakarta.persistence.UniqueConstraint; import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import java.time.LocalDateTime; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -28,9 +40,6 @@ import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; -import java.time.LocalDateTime; -import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_ONLY; -import static io.swagger.v3.oas.annotations.media.Schema.AccessMode.READ_WRITE; /** * PluginParam diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java index 634495631cd..42254d7b532 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java @@ -76,14 +76,13 @@ public interface PluginService { /** * get param define - * @param jarPath - * @return + * @param pluginMetadataId plugin id */ List getParamDefine(Long pluginMetadataId); /** * save plugin param - * @param params + * @param params params */ void savePluginParam(List params); 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 9918b9b5624..6917af6be7f 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 @@ -17,7 +17,6 @@ package org.apache.hertzbeat.manager.service.impl; -import com.alibaba.fastjson.JSON; import jakarta.persistence.criteria.Predicate; import java.io.File; import java.io.FileOutputStream; @@ -131,7 +130,7 @@ public void deletePlugins(Set ids) { } // delete metadata metadataDao.deleteById(plugin.getId()); - syncPluginParamMap(plugin.getId(),null,true); + syncPluginParamMap(plugin.getId(), null, true); pluginParamDao.deleteParamsByPluginMetadataId(plugin.getId()); } catch (IOException e) { throw new RuntimeException(e); @@ -180,16 +179,16 @@ public void savePluginParam(List params) { return; } pluginParamDao.saveAll(params); - syncPluginParamMap(params.get(0).getPluginMetadataId(),params,false); + syncPluginParamMap(params.get(0).getPluginMetadataId(), params, false); } - private void syncPluginParamMap(Long pluginMetadataId, List params,boolean isDelete) { + private void syncPluginParamMap(Long pluginMetadataId, List params, boolean isDelete) { if (isDelete) { PARAMS_MAP.remove(pluginMetadataId); return; } List configmapList = params.stream().map(item -> new Configmap(item.getField(), item.getParamValue(), item.getType())).toList(); - PARAMS_MAP.put(pluginMetadataId,configmapList); + PARAMS_MAP.put(pluginMetadataId, configmapList); } static { @@ -342,7 +341,7 @@ private void initParams(){ .collect(Collectors.groupingBy(PluginParam::getPluginMetadataId)); for (Map.Entry> entry : content.entrySet()) { - syncPluginParamMap(entry.getKey(), entry.getValue(),false); + syncPluginParamMap(entry.getKey(), entry.getValue(), false); } } catch (Exception e) { log.error("Failed to init params:{}", e.getMessage()); @@ -369,7 +368,7 @@ private void loadJarToClassLoader() { PARAMS_Define_MAP.clear(); List plugins = metadataDao.findPluginMetadataByEnableStatusTrue(); for (PluginMetadata metadata : plugins) { - List urls = loadLibInPlugin(metadata.getJarFilePath(),metadata.getId()); + List urls = loadLibInPlugin(metadata.getJarFilePath(), metadata.getId()); urls.add(new File(metadata.getJarFilePath()).toURI().toURL()); pluginClassLoaders.add(new URLClassLoader(urls.toArray(new URL[0]), Plugin.class.getClassLoader())); } @@ -386,7 +385,7 @@ private void loadJarToClassLoader() { * loading other JAR files that are dependencies for the plugin * * @param pluginJarPath jar file path - * @param pluginMetadataId + * @param pluginMetadataId plugin id * @return urls */ @SneakyThrows diff --git a/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java b/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java index 2bf1374d618..efeed504603 100644 --- a/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java +++ b/plugin/src/main/java/org/apache/hertzbeat/plugin/Plugin.java @@ -33,8 +33,6 @@ public interface Plugin { /** * Supports user-defined parameters - * @param alert - * @param params */ void alert(Alert alert, List params); From 8b9d9c6ead4232c629e0be0968321b7905c66319 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Sun, 25 Aug 2024 20:48:18 +0800 Subject: [PATCH 5/7] [task]:Supports plug-in custom parameters --- .../apache/hertzbeat/manager/service/impl/PluginServiceImpl.java | 1 + 1 file changed, 1 insertion(+) 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 6917af6be7f..3ebd6d8a69b 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 @@ -178,6 +178,7 @@ public void savePluginParam(List params) { if (CollectionUtils.isEmpty(params)) { return; } + pluginParamDao.deleteParamsByPluginMetadataId(params.get(0).getPluginMetadataId()); pluginParamDao.saveAll(params); syncPluginParamMap(params.get(0).getPluginMetadataId(), params, false); } From 7f93bef9b9c1bcdf646d9d9c0221b028d341b9eb Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Mon, 26 Aug 2024 21:58:03 +0800 Subject: [PATCH 6/7] [task]:fix bug --- .../manager/controller/PluginController.java | 6 +-- .../hertzbeat/manager/dao/PluginParamDao.java | 4 +- .../manager/pojo/dto/PluginParametersVO.java | 43 +++++++++++++++++++ .../manager/service/PluginService.java | 4 +- .../service/impl/PluginServiceImpl.java | 19 +++++--- .../apache/hertzbeat/plugin/PluginImpl.java | 20 +++++++++ 6 files changed, 84 insertions(+), 12 deletions(-) create mode 100644 manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParametersVO.java create mode 100644 plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java b/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java index 0bd5d83c6fd..496ebfb5bad 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/controller/PluginController.java @@ -26,9 +26,9 @@ import lombok.RequiredArgsConstructor; import org.apache.hertzbeat.common.entity.dto.Message; import org.apache.hertzbeat.common.entity.dto.PluginUpload; -import org.apache.hertzbeat.common.entity.manager.ParamDefine; import org.apache.hertzbeat.common.entity.manager.PluginMetadata; import org.apache.hertzbeat.manager.pojo.dto.PluginParam; +import org.apache.hertzbeat.manager.pojo.dto.PluginParametersVO; import org.apache.hertzbeat.manager.service.PluginService; import org.springframework.data.domain.Page; import org.springframework.http.ResponseEntity; @@ -90,8 +90,8 @@ public ResponseEntity> updatePluginStatus(@RequestBody PluginMetad @GetMapping("/getParamDefine") @Operation(summary = "get param define", description = "get param define by jar path") - public ResponseEntity>> getParamDefine(@RequestParam Long pluginMetadataId) { - List plugins = pluginService.getParamDefine(pluginMetadataId); + public ResponseEntity> getParamDefine(@RequestParam Long pluginMetadataId) { + PluginParametersVO plugins = pluginService.getParamDefine(pluginMetadataId); return ResponseEntity.ok(Message.success(plugins)); } diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java b/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java index d7fbeaa96af..4eeec26b192 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/dao/PluginParamDao.java @@ -38,11 +38,11 @@ public interface PluginParamDao extends JpaRepository { * Remove the parameter list associated with the pluginMetadata ID based on it * @param pluginMetadataId Monitor Id */ - void deleteParamsByPluginMetadataId(long pluginMetadataId); + void deletePluginParamsByPluginMetadataId(long pluginMetadataId); /** * Remove the parameter list associated with the pluginMetadata ID list based on it * @param pluginMetadataIds Monitoring ID List */ - void deleteParamsByPluginMetadataIdIn(Set pluginMetadataIds); + void deletePluginParamsByPluginMetadataIdIn(Set pluginMetadataIds); } diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParametersVO.java b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParametersVO.java new file mode 100644 index 00000000000..ba3f2f9ffa1 --- /dev/null +++ b/manager/src/main/java/org/apache/hertzbeat/manager/pojo/dto/PluginParametersVO.java @@ -0,0 +1,43 @@ +/* + * 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.hertzbeat.manager.pojo.dto; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.hertzbeat.common.entity.manager.ParamDefine; +import java.util.List; + +/** + * Popup rendering and parameter values + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PluginParametersVO { + + /** + * Stencil rendering + */ + private List paramDefines; + + /** + * specific parameter + */ + private List pluginParams; +} diff --git a/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java b/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java index 42254d7b532..a7f0c706e4f 100644 --- a/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java +++ b/manager/src/main/java/org/apache/hertzbeat/manager/service/PluginService.java @@ -23,9 +23,9 @@ import java.util.function.Consumer; import org.apache.hertzbeat.common.entity.dto.PluginUpload; import org.apache.hertzbeat.common.entity.job.Configmap; -import org.apache.hertzbeat.common.entity.manager.ParamDefine; import org.apache.hertzbeat.common.entity.manager.PluginMetadata; import org.apache.hertzbeat.manager.pojo.dto.PluginParam; +import org.apache.hertzbeat.manager.pojo.dto.PluginParametersVO; import org.springframework.data.domain.Page; /** @@ -78,7 +78,7 @@ public interface PluginService { * get param define * @param pluginMetadataId plugin id */ - List getParamDefine(Long pluginMetadataId); + PluginParametersVO getParamDefine(Long pluginMetadataId); /** * save plugin param 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 3ebd6d8a69b..5838bb260d9 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 @@ -60,12 +60,14 @@ import org.apache.hertzbeat.manager.dao.PluginMetadataDao; import org.apache.hertzbeat.manager.dao.PluginParamDao; import org.apache.hertzbeat.manager.pojo.dto.PluginParam; +import org.apache.hertzbeat.manager.pojo.dto.PluginParametersVO; import org.apache.hertzbeat.manager.service.PluginService; import org.apache.hertzbeat.plugin.Plugin; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.jpa.domain.Specification; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import org.yaml.snakeyaml.Yaml; @@ -131,12 +133,12 @@ public void deletePlugins(Set ids) { // delete metadata metadataDao.deleteById(plugin.getId()); syncPluginParamMap(plugin.getId(), null, true); - pluginParamDao.deleteParamsByPluginMetadataId(plugin.getId()); } catch (IOException e) { throw new RuntimeException(e); } } + pluginParamDao.deletePluginParamsByPluginMetadataIdIn(ids); syncPluginStatus(); // reload classloader loadJarToClassLoader(); @@ -166,19 +168,26 @@ public void updateStatus(PluginMetadata plugin) { } @Override - public List getParamDefine(Long pluginMetadataId) { + public PluginParametersVO getParamDefine(Long pluginMetadataId) { + + PluginParametersVO pluginParametersVO = new PluginParametersVO(); if (PARAMS_Define_MAP.containsKey(pluginMetadataId)) { - return PARAMS_Define_MAP.get(pluginMetadataId); + List paramDefines = PARAMS_Define_MAP.get(pluginMetadataId); + List paramsByPluginMetadataId = pluginParamDao.findParamsByPluginMetadataId(pluginMetadataId); + pluginParametersVO.setParamDefines(paramDefines); + pluginParametersVO.setPluginParams(paramsByPluginMetadataId); + return pluginParametersVO; } - return List.of(); + return pluginParametersVO; } @Override + @Transactional public void savePluginParam(List params) { if (CollectionUtils.isEmpty(params)) { return; } - pluginParamDao.deleteParamsByPluginMetadataId(params.get(0).getPluginMetadataId()); + pluginParamDao.deletePluginParamsByPluginMetadataId(params.get(0).getPluginMetadataId()); pluginParamDao.saveAll(params); syncPluginParamMap(params.get(0).getPluginMetadataId(), params, false); } diff --git a/plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java b/plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java new file mode 100644 index 00000000000..4f3b6a6d759 --- /dev/null +++ b/plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java @@ -0,0 +1,20 @@ +package org.apache.hertzbeat.plugin; + +import org.apache.hertzbeat.common.entity.alerter.Alert; +import org.apache.hertzbeat.common.entity.job.Configmap; +import org.apache.hertzbeat.common.util.JsonUtil; + +import java.util.List; + +public class PluginImpl implements Plugin{ + @Override + public void alert(Alert alert) { + System.out.println("alert"); + } + + @Override + public void alert(Alert alert, List params) { + System.out.println("alert" + JsonUtil.toJson(params)); + + } +} From ee40419859bd004e1545c34fc33eadfd486c5087 Mon Sep 17 00:00:00 2001 From: linDong <56677297@qq.com> Date: Mon, 26 Aug 2024 22:54:51 +0800 Subject: [PATCH 7/7] [task]:fix bug --- .../apache/hertzbeat/plugin/PluginImpl.java | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java diff --git a/plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java b/plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java deleted file mode 100644 index 4f3b6a6d759..00000000000 --- a/plugin/src/main/java/org/apache/hertzbeat/plugin/PluginImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.apache.hertzbeat.plugin; - -import org.apache.hertzbeat.common.entity.alerter.Alert; -import org.apache.hertzbeat.common.entity.job.Configmap; -import org.apache.hertzbeat.common.util.JsonUtil; - -import java.util.List; - -public class PluginImpl implements Plugin{ - @Override - public void alert(Alert alert) { - System.out.println("alert"); - } - - @Override - public void alert(Alert alert, List params) { - System.out.println("alert" + JsonUtil.toJson(params)); - - } -}