This is an automated email from the ASF dual-hosted git repository.
zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 4977d1bf00 [Improvement-18056][Alert] Remove the unused code in alert
module (#18062)
4977d1bf00 is described below
commit 4977d1bf000f8db79afcff150913e83cbb5e4992
Author: Wenjun Ruan <[email protected]>
AuthorDate: Fri Mar 13 14:25:16 2026 +0800
[Improvement-18056][Alert] Remove the unused code in alert module (#18062)
---
.../plugin/alert/voice/VoiceSender.java | 11 +---
.../dolphinscheduler/alert/api/AlertInputTips.java | 12 +---
.../plugin/alert/dingtalk/DingTalkSender.java | 50 +--------------
.../plugin/alert/email/ExcelUtils.java | 2 +-
.../plugin/alert/email/MailSender.java | 8 +--
.../plugin/alert/feishu/FeiShuSender.java | 6 +-
.../plugin/alert/feishu/HttpRequestUtil.java | 6 +-
.../plugin/alert/feishu/FeiShuSenderTest.java | 48 --------------
.../plugin/alert/http/HttpSender.java | 4 +-
.../plugin/alert/pagerduty/PagerDutySender.java | 6 +-
.../alert/prometheus/PrometheusAlertSender.java | 8 +--
.../prometheus/PrometheusAlertSenderTest.java | 10 ---
.../plugin/alert/script/ScriptType.java | 18 ++----
.../plugin/alert/slack/SlackSender.java | 4 +-
.../plugin/alert/telegram/TelegramSender.java | 40 +-----------
.../alert/webexteams/WebexTeamsDestination.java | 18 ++----
.../plugin/alert/webexteams/WebexTeamsSender.java | 8 +--
.../plugin/alert/wechat/WeChatSender.java | 47 +-------------
.../plugin/alert/wechat/WeChatType.java | 18 ++----
.../plugin/alert/wechat/WechatAppChatMessage.java | 50 ++-------------
.../plugin/alert/wechat/WechatAppMessage.java | 74 ++--------------------
.../alert/metrics/AlertServerMetrics.java | 6 --
.../alert/plugin/AlertPluginManager.java | 4 --
23 files changed, 68 insertions(+), 390 deletions(-)
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-aliyunVoice/src/main/java/org/apache/dolphinscheduler/plugin/alert/voice/VoiceSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-aliyunVoice/src/main/java/org/apache/dolphinscheduler/plugin/alert/voice/VoiceSender.java
index fe0fc65986..e901d57402 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-aliyunVoice/src/main/java/org/apache/dolphinscheduler/plugin/alert/voice/VoiceSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-aliyunVoice/src/main/java/org/apache/dolphinscheduler/plugin/alert/voice/VoiceSender.java
@@ -40,11 +40,11 @@ public final class VoiceSender {
* @return Client
* @throws Exception
*/
- public VoiceSender(VoiceParam voiceParam) {
+ VoiceSender(VoiceParam voiceParam) {
this.voiceParam = voiceParam;
}
- public AlertResult send() {
+ AlertResult send() {
AlertResult alertResult = new AlertResult();
alertResult.setSuccess(false);
try {
@@ -91,11 +91,4 @@ public final class VoiceSender {
return new com.aliyun.dyvmsapi20170525.Client(config);
}
- public VoiceParam getVoidcePara() {
- return voiceParam;
- }
-
- public void setVoidcePara(VoiceParam voidcePara) {
- this.voiceParam = voidcePara;
- }
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertInputTips.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertInputTips.java
index a0b783e814..655f59f4a3 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertInputTips.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-api/src/main/java/org/apache/dolphinscheduler/alert/api/AlertInputTips.java
@@ -18,11 +18,11 @@
package org.apache.dolphinscheduler.alert.api;
import java.util.HashMap;
-import java.util.Locale;
import java.util.Map;
-import org.springframework.context.i18n.LocaleContextHolder;
+import lombok.Getter;
+@Getter
public enum AlertInputTips {
PASSWORD("if enable use authentication, you need input password",
"如果开启鉴权校验,则需要输入密码"),
@@ -68,14 +68,6 @@ public enum AlertInputTips {
this.zhMsg = zhMsg;
}
- public String getMsg() {
- if
(Locale.SIMPLIFIED_CHINESE.getLanguage().equals(LocaleContextHolder.getLocale().getLanguage()))
{
- return this.zhMsg;
- } else {
- return this.enMsg;
- }
- }
-
public static Map<String, String> getAllMsg(AlertInputTips alertInputTips)
{
Map<String, String> allMsgMap = new HashMap<>();
allMsgMap.put("zhMsg", alertInputTips.zhMsg);
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java
index 467b74f0e8..88f80b31e0 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkSender.java
@@ -48,8 +48,7 @@ import java.util.Objects;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
-import lombok.Getter;
-import lombok.Setter;
+import lombok.Data;
import lombok.extern.slf4j.Slf4j;
/**
@@ -156,7 +155,7 @@ public final class DingTalkSender {
* @param content content
* @return
*/
- public AlertResult sendDingTalkMsg(String title, String content) {
+ AlertResult sendDingTalkMsg(String title, String content) {
AlertResult alertResult;
try {
String resp = sendMsg(title, content);
@@ -328,53 +327,10 @@ public final class DingTalkSender {
return url + "×tamp=" + timestamp + "&sign=" + sign;
}
- @Getter
- @Setter
+ @Data
static final class DingTalkSendMsgResponse {
private Integer errcode;
private String errmsg;
-
- public DingTalkSendMsgResponse() {
- }
-
- @Override
- public boolean equals(final Object o) {
- if (o == this) {
- return true;
- }
- if (!(o instanceof DingTalkSendMsgResponse)) {
- return false;
- }
- final DingTalkSendMsgResponse other = (DingTalkSendMsgResponse) o;
- final Object this$errcode = this.getErrcode();
- final Object other$errcode = other.getErrcode();
- if (this$errcode == null ? other$errcode != null :
!this$errcode.equals(other$errcode)) {
- return false;
- }
- final Object this$errmsg = this.getErrmsg();
- final Object other$errmsg = other.getErrmsg();
- if (this$errmsg == null ? other$errmsg != null :
!this$errmsg.equals(other$errmsg)) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- final int PRIME = 59;
- int result = 1;
- final Object $errcode = this.getErrcode();
- result = result * PRIME + ($errcode == null ? 43 :
$errcode.hashCode());
- final Object $errmsg = this.getErrmsg();
- result = result * PRIME + ($errmsg == null ? 43 :
$errmsg.hashCode());
- return result;
- }
-
- @Override
- public String toString() {
- return "DingTalkSender.DingTalkSendMsgResponse(errcode=" +
this.getErrcode() + ", errmsg="
- + this.getErrmsg() + ")";
- }
}
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java
index 811c3c6181..3f8e91be0e 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/ExcelUtils.java
@@ -53,7 +53,7 @@ public final class ExcelUtils {
* @param title the title
* @param xlsFilePath the xls path
*/
- public static void genExcelFile(String content, String title, String
xlsFilePath) {
+ static void genExcelFile(String content, String title, String xlsFilePath)
{
File file = new File(xlsFilePath);
if (!file.exists() && !file.mkdirs()) {
log.error("Create xlsx directory error, path:{}", xlsFilePath);
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
index 58e1eb10b3..ed6366bc00 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/MailSender.java
@@ -80,7 +80,7 @@ public final class MailSender {
private final String mustNotNull = " must not be null";
private String xlsFilePath;
- public MailSender(Map<String, String> config) {
+ MailSender(Map<String, String> config) {
String receiversConfig =
config.get(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS);
if (receiversConfig == null || "".equals(receiversConfig)) {
throw new
AlertEmailException(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS +
mustNotNull);
@@ -140,7 +140,7 @@ public final class MailSender {
* @param title title
* @param content content
*/
- public AlertResult sendMails(String title, String content) {
+ AlertResult sendMails(String title, String content) {
return sendMails(this.receivers, this.receiverCcs, title, content);
}
@@ -152,7 +152,7 @@ public final class MailSender {
* @param title title
* @param content content
*/
- public AlertResult sendMails(List<String> receivers, List<String>
receiverCcs, String title, String content) {
+ private AlertResult sendMails(List<String> receivers, List<String>
receiverCcs, String title, String content) {
AlertResult alertResult = new AlertResult();
alertResult.setSuccess(false);
@@ -390,7 +390,7 @@ public final class MailSender {
*
* @param file the file to delete
*/
- public void deleteFile(File file) {
+ private void deleteFile(File file) {
if (file.exists()) {
if (file.delete()) {
log.info("delete success: {}", file.getAbsolutePath());
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java
index 07ba19ef39..7336e835e4 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSender.java
@@ -82,7 +82,7 @@ public final class FeiShuSender {
return JSONUtils.toJsonString(items);
}
- public static AlertResult checkSendFeiShuSendMsgResult(String result) {
+ private static AlertResult checkSendFeiShuSendMsgResult(String result) {
AlertResult alertResult = new AlertResult();
alertResult.setSuccess(false);
@@ -108,7 +108,7 @@ public final class FeiShuSender {
return alertResult;
}
- public static String formatContent(AlertData alertData) {
+ private static String formatContent(AlertData alertData) {
if (alertData.getContent() != null) {
List<Map> list = JSONUtils.toList(alertData.getContent(),
Map.class);
@@ -131,7 +131,7 @@ public final class FeiShuSender {
return null;
}
- public AlertResult sendFeiShuMsg(AlertData alertData) {
+ AlertResult sendFeiShuMsg(AlertData alertData) {
AlertResult alertResult;
try {
String resp = sendMsg(alertData);
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/HttpRequestUtil.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/HttpRequestUtil.java
index c981175610..3c736ad4e4 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/HttpRequestUtil.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/HttpRequestUtil.java
@@ -36,8 +36,8 @@ public final class HttpRequestUtil {
throw new UnsupportedOperationException("This is a utility class and
cannot be instantiated");
}
- public static CloseableHttpClient getHttpClient(boolean enableProxy,
String proxy, Integer port, String user,
- String password) {
+ static CloseableHttpClient getHttpClient(boolean enableProxy, String
proxy, Integer port, String user,
+ String password) {
if (enableProxy) {
HttpHost httpProxy = new HttpHost(proxy, port);
CredentialsProvider provider = new BasicCredentialsProvider();
@@ -49,7 +49,7 @@ public final class HttpRequestUtil {
}
}
- public static HttpPost constructHttpPost(String url, String msg) {
+ static HttpPost constructHttpPost(String url, String msg) {
HttpPost post = new HttpPost(url);
StringEntity entity = new StringEntity(msg,
ContentType.APPLICATION_JSON);
post.setEntity(entity);
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/test/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSenderTest.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/test/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSenderTest.java
index 8e582260ff..5305faa0dc 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/test/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSenderTest.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-feishu/src/test/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuSenderTest.java
@@ -46,52 +46,4 @@ public class FeiShuSenderTest {
Assertions.assertFalse(alertResult.isSuccess());
}
- @Test
- public void testFormatContent() {
- String alertMsg = "[\n"
- + " {\n"
- + " \"owner\": \"dolphinscheduler\",\n"
- + " \"processEndTime\": \"2021-01-29 19:01:11\",\n"
- + " \"processHost\": \"10.81.129.4:5678\",\n"
- + " \"processId\": 2926,\n"
- + " \"processName\": \"3-20210129190038108\",\n"
- + " \"processStartTime\": \"2021-01-29 19:00:38\",\n"
- + " \"processState\": \"SUCCESS\",\n"
- + " \"processType\": \"START_PROCESS\",\n"
- + " \"projectId\": 2,\n"
- + " \"projectName\": \"testdelproject\",\n"
- + " \"recovery\": \"NO\",\n"
- + " \"retryTimes\": 0,\n"
- + " \"runTimes\": 1,\n"
- + " \"taskId\": 0\n"
- + " }\n"
- + "]";
- AlertData alertData = new AlertData();
- alertData.setTitle("");
- alertData.setContent(alertMsg);
- Assertions.assertNotNull(FeiShuSender.formatContent(alertData));
- }
-
- @Test
- public void testSendWithFormatException() {
- AlertData alertData = new AlertData();
- alertData.setTitle("feishu test title");
- alertData.setContent("[{\"content\":\"feishu test content\"}]");
- String alertResult = FeiShuSender.formatContent(alertData);
- Assertions.assertEquals(alertResult, "`feishu test
title`\ncontent:feishu test content\n");
- }
-
- @Test
- public void testCheckSendFeiShuSendMsgResult() {
-
- AlertResult alertResult =
FeiShuSender.checkSendFeiShuSendMsgResult("");
- Assertions.assertFalse(alertResult.isSuccess());
- AlertResult alertResult2 =
FeiShuSender.checkSendFeiShuSendMsgResult("{\"code\":123}");
- Assertions.assertEquals("alert send feishu msg error: null",
- alertResult2.getMessage());
-
- String response = "{\"code\":\"0\",\"data\":{},\"msg\":\"success\"}";
- AlertResult alertResult3 =
FeiShuSender.checkSendFeiShuSendMsgResult(response);
- Assertions.assertTrue(alertResult3.isSuccess());
- }
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
index 9c407e7536..68d16c2659 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpSender.java
@@ -49,7 +49,7 @@ public final class HttpSender {
private int timeout;
private String url;
- public HttpSender(Map<String, String> paramsMap) {
+ HttpSender(Map<String, String> paramsMap) {
paramsValidator(paramsMap);
}
@@ -96,7 +96,7 @@ public final class HttpSender {
: HttpAlertConstants.DEFAULT_TIMEOUT) * 1000;
}
- public AlertResult send(String msg) {
+ AlertResult send(String msg) {
AlertResult alertResult = new AlertResult();
OkHttpResponse okHttpResponse;
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutySender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutySender.java
index 11dd01048a..699665ef38 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutySender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-pagerduty/src/main/java/org/apache/dolphinscheduler/plugin/alert/pagerduty/PagerDutySender.java
@@ -46,12 +46,12 @@ public final class PagerDutySender {
private final String integrationKey;
- public PagerDutySender(Map<String, String> config) {
+ PagerDutySender(Map<String, String> config) {
integrationKey =
config.get(PagerDutyParamsConstants.NAME_PAGER_DUTY_INTEGRATION_KEY_NAME);
Preconditions.checkArgument(!Objects.isNull(integrationKey),
"PagerDuty integration key can not be null");
}
- public AlertResult sendPagerDutyAlter(String title, String content) {
+ AlertResult sendPagerDutyAlter(String title, String content) {
AlertResult alertResult = new AlertResult();
alertResult.setSuccess(false);
alertResult.setMessage("send pager duty alert fail.");
@@ -124,7 +124,7 @@ public final class PagerDutySender {
return post;
}
- public static String formatContent(String content) {
+ private static String formatContent(String content) {
List<Map> list = JSONUtils.toList(content, Map.class);
if (list.isEmpty()) {
return content;
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSender.java
index 48fda566b1..c1d4648828 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/main/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSender.java
@@ -53,13 +53,13 @@ public class PrometheusAlertSender {
private String generatorURL;
private String annotations;
- public PrometheusAlertSender(Map<String, String> config) {
+ PrometheusAlertSender(Map<String, String> config) {
url = config.get(PrometheusAlertConstants.NAME_ALERT_MANAGER_URL);
generatorURL = config.get(PrometheusAlertConstants.NAME_GENERATOR_URL);
annotations =
config.get(PrometheusAlertConstants.NAME_ALERT_MANAGER_ANNOTATIONS);
}
- public AlertResult sendMessage(AlertData alertData) {
+ AlertResult sendMessage(AlertData alertData) {
AlertResult alertResult;
try {
String resp = sendMsg(alertData);
@@ -104,7 +104,7 @@ public class PrometheusAlertSender {
}
}
- public AlertResult checkSendAlertManageMsgResult(String resp) {
+ private AlertResult checkSendAlertManageMsgResult(String resp) {
AlertResult alertResult = new AlertResult();
alertResult.setSuccess(false);
@@ -119,7 +119,7 @@ public class PrometheusAlertSender {
return alertResult;
}
- public String generateContentJson(AlertData alertData) {
+ private String generateContentJson(AlertData alertData) {
List<HashMap> list = JSONUtils.toList(alertData.getContent(),
HashMap.class);
HashMap<String, String> labels = new HashMap<>();
if (CollectionUtils.isEmpty(list)) {
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/test/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSenderTest.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/test/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSenderTest.java
index c0d18396e4..ea37211e68 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/test/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSenderTest.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-prometheus/src/test/java/org/apache/dolphinscheduler/plugin/alert/prometheus/PrometheusAlertSenderTest.java
@@ -58,14 +58,4 @@ public class PrometheusAlertSenderTest {
Assertions.assertFalse(result.isSuccess());
}
- @Test
- public void testCheckSendAlertManageMsgResult() {
- PrometheusAlertSender prometheusAlertSender = new
PrometheusAlertSender(config);
- AlertResult alertResult1 =
prometheusAlertSender.checkSendAlertManageMsgResult("");
- Assertions.assertFalse(alertResult1.isSuccess());
- Assertions.assertEquals("prometheus alert manager send fail, resp is
", alertResult1.getMessage());
- AlertResult alertResult2 =
prometheusAlertSender.checkSendAlertManageMsgResult("alert success");
- Assertions.assertTrue(alertResult2.isSuccess());
- Assertions.assertEquals("prometheus alert manager send success",
alertResult2.getMessage());
- }
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java
index b31e10f575..eb592771b0 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptType.java
@@ -17,6 +17,11 @@
package org.apache.dolphinscheduler.plugin.alert.script;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
public enum ScriptType {
SHELL(0, "SHELL"),
@@ -24,17 +29,4 @@ public enum ScriptType {
private final int code;
private final String descp;
- ScriptType(int code, String descp) {
- this.code = code;
- this.descp = descp;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getDescp() {
- return descp;
- }
-
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackSender.java
index 4096ccc998..213445ebcc 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-slack/src/main/java/org/apache/dolphinscheduler/plugin/alert/slack/SlackSender.java
@@ -50,7 +50,7 @@ public final class SlackSender {
private final String webHookUrl;
private final String botName;
- public SlackSender(Map<String, String> slackAlertParam) {
+ SlackSender(Map<String, String> slackAlertParam) {
webHookUrl =
slackAlertParam.get(SlackParamsConstants.SLACK_WEB_HOOK_URL_NAME);
botName = slackAlertParam.get(SlackParamsConstants.SLACK_BOT_NAME);
Preconditions.checkArgument(!Objects.isNull(webHookUrl),
"SlackWebHookURL can not be null");
@@ -66,7 +66,7 @@ public final class SlackSender {
* @param content content
* @return slack response
*/
- public String sendMessage(String title, String content) {
+ String sendMessage(String title, String content) {
try (
CloseableHttpClient httpClient =
HttpClients.custom().setRetryHandler(HttpServiceRetryStrategy.retryStrategy).build())
{
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramSender.java
index 417e97d4cd..c4d07694aa 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-telegram/src/main/java/org/apache/dolphinscheduler/plugin/alert/telegram/TelegramSender.java
@@ -44,6 +44,7 @@ import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
+import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -97,7 +98,7 @@ public final class TelegramSender {
* @return alert result
* @see <a href="https://core.telegram.org/bots/api#sendmessage">telegram
bot api</a>
*/
- public AlertResult sendMessage(AlertData alertData) {
+ AlertResult sendMessage(AlertData alertData) {
AlertResult result;
try {
String resp = sendInvoke(alertData.getTitle(),
alertData.getContent());
@@ -179,6 +180,7 @@ public final class TelegramSender {
return null == parseMode ||
TelegramAlertConstants.PARSE_MODE_TXT.equals(parseMode);
}
+ @Data
static class TelegramSendMsgResponse {
@JsonProperty("ok")
@@ -193,42 +195,6 @@ public final class TelegramSender {
public boolean isOk() {
return null != ok && ok;
}
-
- public Boolean getOk() {
- return ok;
- }
-
- @JsonProperty("ok")
- public void setOk(Boolean ok) {
- this.ok = ok;
- }
-
- @JsonProperty("error_code")
- public void setErrorCode(Integer errorCode) {
- this.errorCode = errorCode;
- }
-
- public Integer getErrorCode() {
- return errorCode;
- }
-
- public String getDescription() {
- return description;
- }
-
- @JsonProperty("description")
- public void setDescription(String description) {
- this.description = description;
- }
-
- public Object getResult() {
- return result;
- }
-
- @JsonProperty("result")
- public void setResult(Object result) {
- this.result = result;
- }
}
private static HttpPost buildHttpPost(String url, String msg) {
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsDestination.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsDestination.java
index 694fd3fdea..5fe395966c 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsDestination.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsDestination.java
@@ -22,8 +22,13 @@ import static java.util.stream.Collectors.toMap;
import java.util.Arrays;
import java.util.Map;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
import com.google.common.base.Functions;
+@AllArgsConstructor
+@Getter
public enum WebexTeamsDestination {
/**
@@ -38,19 +43,6 @@ public enum WebexTeamsDestination {
private final int code;
private final String descp;
- WebexTeamsDestination(int code, String descp) {
- this.code = code;
- this.descp = descp;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getDescp() {
- return descp;
- }
-
private static final Map<String, WebexTeamsDestination>
WEBEX_TEAMS_DESTINATION_MAP =
Arrays.stream(WebexTeamsDestination.values())
.collect(toMap(WebexTeamsDestination::getDescp,
Functions.identity()));
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsSender.java
index 3b8b3d21c8..e370f10ded 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-webexteams/src/main/java/org/apache/dolphinscheduler/plugin/alert/webexteams/WebexTeamsSender.java
@@ -51,7 +51,7 @@ public final class WebexTeamsSender {
private final String atSomeoneInRoom;
private final WebexTeamsDestination destination;
- public WebexTeamsSender(Map<String, String> config) {
+ WebexTeamsSender(Map<String, String> config) {
botAccessToken =
config.get(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN);
roomId =
config.get(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID);
toPersonId =
config.get(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID);
@@ -65,7 +65,7 @@ public final class WebexTeamsSender {
"WebexTeams message destination could not be determined.
Provide only one destination in the roomId, toPersonEmail, or toPersonId
field");
}
- public AlertResult sendWebexTeamsAlter(AlertData alertData) {
+ AlertResult sendWebexTeamsAlter(AlertData alertData) {
AlertResult alertResult = new AlertResult();
alertResult.setSuccess(false);
alertResult.setMessage("send webex teams alert fail.");
@@ -146,7 +146,7 @@ public final class WebexTeamsSender {
return post;
}
- public static String addAtPersonEmailInRoom(String formatContent, String
atPersonEmailInRoom) {
+ private static String addAtPersonEmailInRoom(String formatContent, String
atPersonEmailInRoom) {
String[] emailArr = atPersonEmailInRoom.split(",");
StringBuilder formatContentBuilder = new StringBuilder(formatContent);
for (String email : emailArr) {
@@ -156,7 +156,7 @@ public final class WebexTeamsSender {
return formatContentBuilder.toString();
}
- public static String formatContent(AlertData alertData) {
+ private static String formatContent(AlertData alertData) {
if (alertData.getContent() != null) {
List<Map> list = JSONUtils.toList(alertData.getContent(),
Map.class);
if (list.isEmpty()) {
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java
index d3fba217dc..219c507346 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatSender.java
@@ -46,8 +46,7 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import lombok.Getter;
-import lombok.Setter;
+import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@@ -205,7 +204,7 @@ public final class WeChatSender {
*
* @return Enterprise WeChat resp, demo:
{"errcode":0,"errmsg":"ok","invaliduser":""}
*/
- public AlertResult sendEnterpriseWeChat(String title, String content) {
+ AlertResult sendEnterpriseWeChat(String title, String content) {
AlertResult alertResult;
String data = markdownByAlert(title, content);
if (null == weChatToken) {
@@ -261,50 +260,10 @@ public final class WeChatSender {
return null;
}
- @Getter
- @Setter
+ @Data
static final class WeChatSendMsgResponse {
private Integer errcode;
private String errmsg;
-
- public WeChatSendMsgResponse() {
- }
-
- public boolean equals(final Object o) {
- if (o == this) {
- return true;
- }
- if (!(o instanceof WeChatSendMsgResponse)) {
- return false;
- }
- final WeChatSendMsgResponse other = (WeChatSendMsgResponse) o;
- final Object this$errcode = this.getErrcode();
- final Object other$errcode = other.getErrcode();
- if (this$errcode == null ? other$errcode != null :
!this$errcode.equals(other$errcode)) {
- return false;
- }
- final Object this$errmsg = this.getErrmsg();
- final Object other$errmsg = other.getErrmsg();
- if (this$errmsg == null ? other$errmsg != null :
!this$errmsg.equals(other$errmsg)) {
- return false;
- }
- return true;
- }
-
- public int hashCode() {
- final int PRIME = 59;
- int result = 1;
- final Object $errcode = this.getErrcode();
- result = result * PRIME + ($errcode == null ? 43 :
$errcode.hashCode());
- final Object $errmsg = this.getErrmsg();
- result = result * PRIME + ($errmsg == null ? 43 :
$errmsg.hashCode());
- return result;
- }
-
- public String toString() {
- return "WeChatSender.WeChatSendMsgResponse(errcode=" +
this.getErrcode() + ", errmsg=" + this.getErrmsg()
- + ")";
- }
}
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatType.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatType.java
index 109da59944..959d94ca4b 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatType.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatType.java
@@ -17,6 +17,11 @@
package org.apache.dolphinscheduler.plugin.alert.wechat;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@AllArgsConstructor
+@Getter
public enum WeChatType {
APP(1, "APP/应用"),
@@ -25,17 +30,4 @@ public enum WeChatType {
private final int code;
private final String descp;
-
- WeChatType(int code, String descp) {
- this.code = code;
- this.descp = descp;
- }
-
- public int getCode() {
- return code;
- }
-
- public String getDescp() {
- return descp;
- }
}
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppChatMessage.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppChatMessage.java
index 9c16f759fa..349069ca4a 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppChatMessage.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppChatMessage.java
@@ -21,6 +21,13 @@ import org.apache.dolphinscheduler.alert.api.ShowType;
import java.util.Map;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter
+@Setter
+@NoArgsConstructor
public class WechatAppChatMessage {
private String chatid;
@@ -29,49 +36,6 @@ public class WechatAppChatMessage {
private Map<String, String> markdown;
private Integer safe;
- public String getChatid() {
- return chatid;
- }
-
- public void setChatid(String chatid) {
- this.chatid = chatid;
- }
-
- public String getMsgtype() {
- return msgtype;
- }
-
- public void setMsgtype(String msgtype) {
- this.msgtype = msgtype;
- }
-
- public Map<String, String> getText() {
- return text;
- }
-
- public void setText(Map<String, String> text) {
- this.text = text;
- }
-
- public Integer getSafe() {
- return safe;
- }
-
- public void setSafe(Integer safe) {
- this.safe = safe;
- }
-
- public Map<String, String> getMarkdown() {
- return markdown;
- }
-
- public void setMarkdown(Map<String, String> markdown) {
- this.markdown = markdown;
- }
-
- public WechatAppChatMessage() {
- }
-
public WechatAppChatMessage(String chatid, String msgtype, Map<String,
String> contentMap, Integer safe) {
this.chatid = chatid;
this.msgtype = msgtype;
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppMessage.java
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppMessage.java
index f5ec7183ba..5295167007 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppMessage.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WechatAppMessage.java
@@ -21,6 +21,13 @@ import org.apache.dolphinscheduler.alert.api.ShowType;
import java.util.Map;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+@Getter
+@Setter
+@NoArgsConstructor
public class WechatAppMessage {
private String touser;
@@ -32,73 +39,6 @@ public class WechatAppMessage {
private Integer enable_id_trans;
private Integer enable_duplicate_check;
- public String getTouser() {
- return touser;
- }
-
- public void setTouser(String touser) {
- this.touser = touser;
- }
-
- public String getMsgtype() {
- return msgtype;
- }
-
- public void setMsgtype(String msgtype) {
- this.msgtype = msgtype;
- }
-
- public Integer getAgentid() {
- return agentid;
- }
-
- public void setAgentid(Integer agentid) {
- this.agentid = agentid;
- }
-
- public Map<String, String> getText() {
- return text;
- }
-
- public void setText(Map<String, String> text) {
- this.text = text;
- }
-
- public Integer getSafe() {
- return safe;
- }
-
- public void setSafe(Integer safe) {
- this.safe = safe;
- }
-
- public Integer getEnable_id_trans() {
- return enable_id_trans;
- }
-
- public void setEnable_id_trans(Integer enable_id_trans) {
- this.enable_id_trans = enable_id_trans;
- }
-
- public Integer getEnable_duplicate_check() {
- return enable_duplicate_check;
- }
-
- public void setEnable_duplicate_check(Integer enable_duplicate_check) {
- this.enable_duplicate_check = enable_duplicate_check;
- }
-
- public Map<String, String> getMarkdown() {
- return markdown;
- }
-
- public void setMarkdown(Map<String, String> markdown) {
- this.markdown = markdown;
- }
-
- public WechatAppMessage() {
- }
-
public WechatAppMessage(String touser, String msgtype, Integer agentid,
Map<String, String> contentMap,
Integer safe, Integer enableIdTrans, Integer
enableDuplicateCheck) {
this.touser = touser;
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/metrics/AlertServerMetrics.java
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/metrics/AlertServerMetrics.java
index dfe819fbfa..d298c20709 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/metrics/AlertServerMetrics.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/metrics/AlertServerMetrics.java
@@ -50,12 +50,6 @@ public class AlertServerMetrics {
.register(Metrics.globalRegistry);
}
- public void registerSendingAlertGauge(final Supplier<Number> supplier) {
- Gauge.builder("ds.alert.sending", supplier)
- .description("Number of sending alert")
- .register(Metrics.globalRegistry);
- }
-
public static void registerUncachedException(final Supplier<Number>
supplier) {
Gauge.builder("ds.alert.uncached.exception", supplier)
.description("number of uncached exception")
diff --git
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java
index 5192561cf1..124f654ee9 100644
---
a/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java
+++
b/dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java
@@ -64,10 +64,6 @@ public final class AlertPluginManager {
return Optional.ofNullable(alertPluginMap.get(id));
}
- public int size() {
- return alertPluginMap.size();
- }
-
private void checkAlertPluginExist() {
if (!pluginDao.checkPluginDefineTableExist()) {
log.error("Plugin Define Table t_ds_plugin_define Not Exist.
Please Create it First!");