diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannel.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannel.java index 7adfacce39..6b13f24d86 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannel.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannel.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertResult; -import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import java.util.Map; @@ -34,8 +33,10 @@ public class DingTalkAlertChannel implements AlertChannel { public AlertResult process(AlertInfo alertInfo) { AlertData alertData = alertInfo.getAlertData(); - String alertParams = alertInfo.getAlertParams(); - Map paramsMap = PluginParamsTransfer.getPluginParamsMap(alertParams); + Map paramsMap = alertInfo.getAlertParams(); + if (null == paramsMap) { + return new AlertResult("false", "ding talk params is null"); + } return new DingTalkSender(paramsMap).sendDingTalkMsg(alertData.getTitle(), alertData.getContent()); } } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java index c793af5710..3dbf0b8fb9 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertResult; -import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import java.util.Map; @@ -38,8 +37,10 @@ public class EmailAlertChannel implements AlertChannel { public AlertResult process(AlertInfo info) { AlertData alert = info.getAlertData(); - String alertParams = info.getAlertParams(); - Map paramsMap = PluginParamsTransfer.getPluginParamsMap(alertParams); + Map paramsMap = info.getAlertParams(); + if (null == paramsMap) { + return new AlertResult("false", "mail params is null"); + } MailSender mailSender = new MailSender(paramsMap); AlertResult alertResult = mailSender.sendMails(alert.getTitle(), alert.getContent()); diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactoryTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactoryTest.java index 977cd8fefc..37a11e47fb 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactoryTest.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactoryTest.java @@ -19,13 +19,10 @@ package org.apache.dolphinscheduler.plugin.alert.email; import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.List; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; /** @@ -36,29 +33,13 @@ import org.junit.Test; */ public class EmailAlertChannelFactoryTest { - @Before - public void before() throws Exception { - } - - @After - public void after() throws Exception { - } - - /** - * Method: getName() - */ - @Test - public void testGetName() throws Exception { - } - /** * Method: getParams() */ @Test - public void testGetParams() throws Exception { + public void testGetParams() { EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory(); List params = emailAlertChannelFactory.getParams(); - System.out.println(JSONUtils.toJsonString(params)); Assert.assertEquals(12, params.size()); } @@ -66,7 +47,7 @@ public class EmailAlertChannelFactoryTest { * Method: create() */ @Test - public void testCreate() throws Exception { + public void testCreate() { EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory(); AlertChannel alertChannel = emailAlertChannelFactory.create(); Assert.assertNotNull(alertChannel); diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java index 97a1013399..fc28df272c 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java @@ -24,6 +24,7 @@ import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.alert.ShowType; import org.apache.dolphinscheduler.spi.params.InputParam; import org.apache.dolphinscheduler.spi.params.PasswordParam; +import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import org.apache.dolphinscheduler.spi.params.RadioParam; import org.apache.dolphinscheduler.spi.params.base.DataType; import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; @@ -34,6 +35,7 @@ import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import org.junit.Assert; import org.junit.Test; @@ -66,7 +68,9 @@ public class EmailAlertChannelTest { .setTitle("test"); AlertInfo alertInfo = new AlertInfo(); alertInfo.setAlertData(alertData); - alertInfo.setAlertParams(getEmailAlertParams()); + Map paramsMap = PluginParamsTransfer.getPluginParamsMap(getEmailAlertParams()); + + alertInfo.setAlertParams(paramsMap); AlertResult alertResult = emailAlertChannel.process(alertInfo); Assert.assertNotNull(alertResult); Assert.assertEquals("false", alertResult.getStatus()); diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannel.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannel.java index 8a195e08f8..3bbdaa9997 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannel.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-feishu/src/main/java/org/apache/dolphinscheduler/plugin/alert/feishu/FeiShuAlertChannel.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertResult; -import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import java.util.Map; @@ -30,8 +29,10 @@ public class FeiShuAlertChannel implements AlertChannel { public AlertResult process(AlertInfo alertInfo) { AlertData alertData = alertInfo.getAlertData(); - String alertParams = alertInfo.getAlertParams(); - Map paramsMap = PluginParamsTransfer.getPluginParamsMap(alertParams); + Map paramsMap = alertInfo.getAlertParams(); + if (null == paramsMap) { + return new AlertResult("false", "fei shu params is null"); + } return new FeiShuSender(paramsMap).sendFeiShuMsg(alertData); } } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java index 27bc1903d8..cb550b7541 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertResult; -import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import java.util.Map; @@ -33,8 +32,10 @@ public class HttpAlertChannel implements AlertChannel { public AlertResult process(AlertInfo alertInfo) { AlertData alertData = alertInfo.getAlertData(); - String alertParams = alertInfo.getAlertParams(); - Map paramsMap = PluginParamsTransfer.getPluginParamsMap(alertParams); + Map paramsMap = alertInfo.getAlertParams(); + if (null == paramsMap) { + return new AlertResult("false", "http params is null"); + } return new HttpSender(paramsMap).send(alertData.getContent()); } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java index 31a438b4fc..4d385e8a54 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java @@ -21,12 +21,14 @@ import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.params.InputParam; +import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.junit.Assert; import org.junit.Test; @@ -45,7 +47,7 @@ public class HttpAlertChannelTest { alertData.setContent("Fault tolerance warning"); alertInfo.setAlertData(alertData); AlertResult alertResult = alertChannel.process(alertInfo); - Assert.assertEquals("Request types are not supported", alertResult.getMessage()); + Assert.assertEquals("http params is null", alertResult.getMessage()); } @Test @@ -56,7 +58,8 @@ public class HttpAlertChannelTest { AlertData alertData = new AlertData(); alertData.setContent("Fault tolerance warning"); alertInfo.setAlertData(alertData); - alertInfo.setAlertParams(getParams()); + Map paramsMap = PluginParamsTransfer.getPluginParamsMap(getParams()); + alertInfo.setAlertParams(paramsMap); AlertResult alertResult = alertChannel.process(alertInfo); Assert.assertEquals("true", alertResult.getStatus()); } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java index 2a0021277d..dc6aa27e25 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertResult; -import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import java.util.Map; @@ -33,8 +32,10 @@ public class ScriptAlertChannel implements AlertChannel { @Override public AlertResult process(AlertInfo alertinfo) { AlertData alertData = alertinfo.getAlertData(); - String alertParams = alertinfo.getAlertParams(); - Map paramsMap = PluginParamsTransfer.getPluginParamsMap(alertParams); + Map paramsMap = alertinfo.getAlertParams(); + if (null == paramsMap) { + return new AlertResult("false", "ding talk params is null"); + } return new ScriptSender(paramsMap).sendScriptAlert(alertData.getTitle()); } } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactoryTest.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactoryTest.java index 72f2197315..8cedc2c38e 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactoryTest.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactoryTest.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.plugin.alert.script; import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.params.base.PluginParams; -import org.apache.dolphinscheduler.spi.utils.JSONUtils; import java.util.List; @@ -35,7 +34,6 @@ public class ScriptAlertChannelFactoryTest { public void testGetParams() { ScriptAlertChannelFactory scriptAlertChannelFactory = new ScriptAlertChannelFactory(); List params = scriptAlertChannelFactory.getParams(); - JSONUtils.toJsonString(params); Assert.assertEquals(3, params.size()); } diff --git a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java index 4cdd4d375c..36cce09ff3 100644 --- a/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java +++ b/dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertResult; -import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import java.util.Map; @@ -33,8 +32,10 @@ public class WeChatAlertChannel implements AlertChannel { @Override public AlertResult process(AlertInfo info) { AlertData alertData = info.getAlertData(); - String alertParams = info.getAlertParams(); - Map paramsMap = PluginParamsTransfer.getPluginParamsMap(alertParams); + Map paramsMap = info.getAlertParams(); + if (null == paramsMap) { + return new AlertResult("false", "we chat params is null"); + } return new WeChatSender(paramsMap).sendEnterpriseWeChat(alertData.getTitle(), alertData.getContent()); } diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java index 54afc93442..b25cd57f4c 100644 --- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java +++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java @@ -29,7 +29,6 @@ import org.apache.dolphinscheduler.alert.utils.PropertyUtils; import org.apache.dolphinscheduler.common.thread.Stopper; import org.apache.dolphinscheduler.dao.AlertDao; import org.apache.dolphinscheduler.dao.DaoFactory; -import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.remote.NettyRemotingServer; import org.apache.dolphinscheduler.remote.command.CommandType; @@ -53,8 +52,6 @@ public class AlertServer { */ private AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class); - private PluginDao pluginDao = DaoFactory.getDaoInstance(PluginDao.class); - private AlertSender alertSender; private static AlertServer instance; @@ -114,7 +111,7 @@ public class AlertServer { NettyServerConfig serverConfig = new NettyServerConfig(); serverConfig.setListenPort(ALERT_RPC_PORT); this.server = new NettyRemotingServer(serverConfig); - this.server.registerProcessor(CommandType.ALERT_SEND_REQUEST, new AlertRequestProcessor(alertDao, alertPluginManager, pluginDao)); + this.server.registerProcessor(CommandType.ALERT_SEND_REQUEST, new AlertRequestProcessor(alertDao, alertPluginManager)); this.server.start(); } @@ -133,7 +130,7 @@ public class AlertServer { logger.warn("No Alert Plugin . Can not send alert info. "); } else { List alerts = alertDao.listWaitExecutionAlert(); - alertSender = new AlertSender(alerts, alertDao, alertPluginManager, pluginDao); + alertSender = new AlertSender(alerts, alertDao, alertPluginManager); alertSender.run(); } } diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/EmailManager.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/EmailManager.java deleted file mode 100644 index 874b866759..0000000000 --- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/EmailManager.java +++ /dev/null @@ -1,55 +0,0 @@ -///* -// * 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.dolphinscheduler.alert.manager; -// -//import org.apache.dolphinscheduler.alert.utils.MailUtils; -// -//import java.util.List; -//import java.util.Map; -// -///** -// * email send manager -// */ -//public class EmailManager { -// /** -// * email send -// * @param receiversList the receiver list -// * @param receiversCcList the cc List -// * @param title the title -// * @param content the content -// * @param showType the showType -// * @return the send result -// */ -// public Map send(List receiversList,List receiversCcList,String title,String content,String showType){ -// -// return MailUtils.sendMails(receiversList, receiversCcList, title, content, showType); -// } -// -// /** -// * msg send -// * @param receiversList the receiver list -// * @param title the title -// * @param content the content -// * @param showType the showType -// * @return the send result -// */ -// public Map send(List receiversList,String title,String content,String showType){ -// -// return MailUtils.sendMails(receiversList,title, content, showType); -// } -// -//} diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/MsgManager.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/MsgManager.java deleted file mode 100644 index e7fb161162..0000000000 --- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/manager/MsgManager.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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.dolphinscheduler.alert.manager; - -import org.apache.dolphinscheduler.dao.entity.Alert; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * SMS send manager - */ -public class MsgManager { - - private static final Logger logger = LoggerFactory.getLogger(MsgManager.class); - - /** - * SMS send - * - * @param alert the alert - */ - public void send(Alert alert) { - logger.info("send message {}", alert); - } -} diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java index a660087c89..d795e71d52 100644 --- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java +++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java @@ -31,6 +31,7 @@ import org.apache.dolphinscheduler.spi.classloader.ThreadContextClassLoader; import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import org.apache.dolphinscheduler.spi.params.base.PluginParams; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -47,6 +48,11 @@ public class AlertPluginManager extends AbstractDolphinPluginManager { private final Map alertChannelFactoryMap = new ConcurrentHashMap<>(); private final Map alertChannelMap = new ConcurrentHashMap<>(); + /** + * k->pluginDefineId v->pluginDefineName + */ + private final Map pluginDefineMap = new HashMap<>(); + public void addAlertChannelFactory(AlertChannelFactory alertChannelFactory) { requireNonNull(alertChannelFactory, "alertChannelFactory is null"); @@ -83,6 +89,10 @@ public class AlertPluginManager extends AbstractDolphinPluginManager { return alertChannelMap; } + public String getPluginNameById(int id) { + return pluginDefineMap.get(id); + } + @Override public void installPlugin(DolphinSchedulerPlugin dolphinSchedulerPlugin) { for (AlertChannelFactory alertChannelFactory : dolphinSchedulerPlugin.getAlertChannelFactorys()) { @@ -93,7 +103,8 @@ public class AlertPluginManager extends AbstractDolphinPluginManager { String paramsJson = PluginParamsTransfer.transferParamsToJson(params); PluginDefine pluginDefine = new PluginDefine(nameEn, PluginType.ALERT.getDesc(), paramsJson); - pluginDao.addOrUpdatePluginDefine(pluginDefine); + int id = pluginDao.addOrUpdatePluginDefine(pluginDefine); + pluginDefineMap.put(id, pluginDefine.getPluginName()); } } } diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessor.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessor.java index 5e8a8f89d6..ec716d9878 100644 --- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessor.java +++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessor.java @@ -21,7 +21,6 @@ import org.apache.dolphinscheduler.alert.plugin.AlertPluginManager; import org.apache.dolphinscheduler.alert.runner.AlertSender; import org.apache.dolphinscheduler.common.utils.Preconditions; import org.apache.dolphinscheduler.dao.AlertDao; -import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequestCommand; @@ -35,18 +34,16 @@ import org.slf4j.LoggerFactory; import io.netty.channel.Channel; /** - * alert request processor + * alert request processor */ public class AlertRequestProcessor implements NettyRequestProcessor { private final Logger logger = LoggerFactory.getLogger(AlertRequestProcessor.class); private AlertDao alertDao; - private PluginDao pluginDao; private AlertPluginManager alertPluginManager; - public AlertRequestProcessor(AlertDao alertDao, AlertPluginManager alertPluginManager, PluginDao pluginDao) { + public AlertRequestProcessor(AlertDao alertDao, AlertPluginManager alertPluginManager) { this.alertDao = alertDao; - this.pluginDao = pluginDao; this.alertPluginManager = alertPluginManager; } @@ -59,7 +56,7 @@ public class AlertRequestProcessor implements NettyRequestProcessor { command.getBody(), AlertSendRequestCommand.class); logger.info("received command : {}", alertSendRequestCommand); - AlertSender alertSender = new AlertSender(alertDao, alertPluginManager, pluginDao); + AlertSender alertSender = new AlertSender(alertDao, alertPluginManager); AlertSendResponseCommand alertSendResponseCommand = alertSender.syncHandler(alertSendRequestCommand.getGroupId(), alertSendRequestCommand.getTitle(), alertSendRequestCommand.getContent()); channel.writeAndFlush(alertSendResponseCommand.convert2Command(command.getOpaque())); diff --git a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java index 429c744bea..114d01a845 100644 --- a/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java +++ b/dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java @@ -20,8 +20,8 @@ package org.apache.dolphinscheduler.alert.runner; import org.apache.dolphinscheduler.alert.plugin.AlertPluginManager; import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.utils.CollectionUtils; +import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.AlertDao; -import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.remote.command.alert.AlertSendResponseCommand; @@ -33,6 +33,7 @@ import org.apache.dolphinscheduler.spi.alert.AlertResult; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,25 +47,22 @@ public class AlertSender { private List alertList; private AlertDao alertDao; - private PluginDao pluginDao; private AlertPluginManager alertPluginManager; public AlertSender(AlertPluginManager alertPluginManager) { this.alertPluginManager = alertPluginManager; } - public AlertSender(AlertDao alertDao, AlertPluginManager alertPluginManager, PluginDao pluginDao) { + public AlertSender(AlertDao alertDao, AlertPluginManager alertPluginManager) { super(); this.alertDao = alertDao; - this.pluginDao = pluginDao; this.alertPluginManager = alertPluginManager; } - public AlertSender(List alertList, AlertDao alertDao, AlertPluginManager alertPluginManager, PluginDao pluginDao) { + public AlertSender(List alertList, AlertDao alertDao, AlertPluginManager alertPluginManager) { super(); this.alertList = alertList; this.alertDao = alertDao; - this.pluginDao = pluginDao; this.alertPluginManager = alertPluginManager; } @@ -108,7 +106,7 @@ public class AlertSender { List alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); AlertData alertData = new AlertData(); alertData.setContent(content) - .setTitle(title); + .setTitle(title); boolean sendResponseStatus = true; List sendResponseResults = new ArrayList<>(); @@ -143,7 +141,7 @@ public class AlertSender { * @return AlertResult */ private AlertResult alertResultHandler(AlertPluginInstance instance, AlertData alertData) { - String pluginName = pluginDao.getPluginDefineById(instance.getPluginDefineId()).getPluginName(); + String pluginName = alertPluginManager.getPluginNameById(instance.getPluginDefineId()); AlertChannel alertChannel = alertPluginManager.getAlertChannelMap().get(pluginName); AlertResult alertResultExtend = new AlertResult(); String pluginInstanceName = instance.getInstanceName(); @@ -157,8 +155,16 @@ public class AlertSender { AlertInfo alertInfo = new AlertInfo(); alertInfo.setAlertData(alertData); - alertInfo.setAlertParams(instance.getPluginInstanceParams()); - AlertResult alertResult = alertChannel.process(alertInfo); + Map paramsMap = JSONUtils.toMap(instance.getPluginInstanceParams()); + alertInfo.setAlertParams(paramsMap); + AlertResult alertResult; + try { + alertResult = alertChannel.process(alertInfo); + } catch (Exception e) { + alertResult = new AlertResult("false", e.getMessage()); + logger.error("send alert error alert data id :{},", alertData.getId(), e); + } + if (alertResult == null) { String message = String.format("Alert Plugin %s send error : return alertResult value is null", pluginInstanceName); diff --git a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java index a8ead79be9..cdc779e35e 100644 --- a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java +++ b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/AlertServerTest.java @@ -34,12 +34,13 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PrepareForTest({AlertServer.class,DaoFactory.class}) +@PrepareForTest({AlertServer.class, DaoFactory.class}) public class AlertServerTest { @Before @@ -61,7 +62,8 @@ public class AlertServerTest { AlertPluginManager alertPluginManager = PowerMockito.mock(AlertPluginManager.class); PowerMockito.whenNew(AlertPluginManager.class).withNoArguments().thenReturn(alertPluginManager); ConcurrentHashMap alertChannelMap = new ConcurrentHashMap<>(); - alertChannelMap.put("pluginName",alertChannelMock); + alertChannelMap.put("pluginName", alertChannelMock); + PowerMockito.when(alertPluginManager.getPluginNameById(Mockito.anyInt())).thenReturn("pluginName"); PowerMockito.when(alertPluginManager.getAlertChannelMap()).thenReturn(alertChannelMap); DolphinPluginManagerConfig alertPluginManagerConfig = PowerMockito.mock(DolphinPluginManagerConfig.class); @@ -79,7 +81,8 @@ public class AlertServerTest { Assert.assertNotNull(alertServer); new Thread(() -> { - alertServer.start(); }) + alertServer.start(); + }) .start(); Thread.sleep(5 * Constants.ALERT_SCAN_INTERVAL); diff --git a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java index 3983545140..4f428d4667 100644 --- a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java +++ b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java @@ -136,7 +136,7 @@ public class EmailAlertPluginTest { alertPluginInstance.setPluginInstanceParams(getEmailAlertParams()); alertDao.getAlertPluginInstanceMapper().insert(alertPluginInstance); - AlertSender alertSender = new AlertSender(alertList, alertDao, alertPluginManager, pluginDao); + AlertSender alertSender = new AlertSender(alertList, alertDao, alertPluginManager); alertSender.run(); Alert alertResult = alertDao.getAlertMapper().selectById(alert1.getId()); diff --git a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java index 0126eb3dae..052d2f3d55 100644 --- a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java +++ b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/processor/AlertRequestProcessorTest.java @@ -19,7 +19,6 @@ package org.apache.dolphinscheduler.alert.processor; import org.apache.dolphinscheduler.alert.plugin.AlertPluginManager; import org.apache.dolphinscheduler.dao.AlertDao; -import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.remote.command.Command; import org.apache.dolphinscheduler.remote.command.CommandType; import org.apache.dolphinscheduler.remote.command.alert.AlertSendRequestCommand; @@ -37,7 +36,6 @@ import io.netty.channel.Channel; public class AlertRequestProcessorTest { private AlertDao alertDao; - private PluginDao pluginDao; private AlertPluginManager alertPluginManager; private AlertRequestProcessor alertRequestProcessor; @@ -45,17 +43,16 @@ public class AlertRequestProcessorTest { @Before public void before() { alertDao = PowerMockito.mock(AlertDao.class); - pluginDao = PowerMockito.mock(PluginDao.class); alertPluginManager = PowerMockito.mock(AlertPluginManager.class); - alertRequestProcessor = new AlertRequestProcessor(alertDao,alertPluginManager,pluginDao); + alertRequestProcessor = new AlertRequestProcessor(alertDao, alertPluginManager); } @Test public void testProcess() { Channel channel = PowerMockito.mock(Channel.class); - AlertSendRequestCommand alertSendRequestCommand = new AlertSendRequestCommand(1,"title","content"); + AlertSendRequestCommand alertSendRequestCommand = new AlertSendRequestCommand(1, "title", "content"); Command reqCommand = alertSendRequestCommand.convert2Command(); - Assert.assertEquals(CommandType.ALERT_SEND_REQUEST,reqCommand.getType()); - alertRequestProcessor.process(channel,reqCommand); + Assert.assertEquals(CommandType.ALERT_SEND_REQUEST, reqCommand.getType()); + alertRequestProcessor.process(channel, reqCommand); } } diff --git a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderTest.java b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderTest.java index 2664bdcd29..3b84bdbe67 100644 --- a/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderTest.java +++ b/dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/runner/AlertSenderTest.java @@ -67,7 +67,7 @@ public class AlertSenderTest { int alertGroupId = 1; String title = "alert mail test title"; String content = "alert mail test content"; - alertSender = new AlertSender(alertDao,alertPluginManager,pluginDao); + alertSender = new AlertSender(alertDao, alertPluginManager); //1.alert instance does not exist PowerMockito.when(alertDao.listInstanceByAlertGroupId(alertGroupId)).thenReturn(null); @@ -75,7 +75,7 @@ public class AlertSenderTest { AlertSendResponseCommand alertSendResponseCommand = alertSender.syncHandler(alertGroupId, title, content); Assert.assertFalse(alertSendResponseCommand.getResStatus()); alertSendResponseCommand.getResResults().forEach(result -> - logger.info("alert send response result, status:{}, message:{}",result.getStatus(),result.getMessage())); + logger.info("alert send response result, status:{}, message:{}", result.getStatus(), result.getMessage())); //2.alert plugin does not exist int pluginDefineId = 1; @@ -83,30 +83,31 @@ public class AlertSenderTest { String pluginInstanceName = "alert-instance-mail"; List alertInstanceList = new ArrayList<>(); AlertPluginInstance alertPluginInstance = new AlertPluginInstance( - pluginDefineId,pluginInstanceParams,pluginInstanceName); + pluginDefineId, pluginInstanceParams, pluginInstanceName); alertInstanceList.add(alertPluginInstance); PowerMockito.when(alertDao.listInstanceByAlertGroupId(1)).thenReturn(alertInstanceList); String pluginName = "alert-plugin-mail"; - PluginDefine pluginDefine = new PluginDefine(pluginName,"1",null); + PluginDefine pluginDefine = new PluginDefine(pluginName, "1", null); PowerMockito.when(pluginDao.getPluginDefineById(pluginDefineId)).thenReturn(pluginDefine); alertSendResponseCommand = alertSender.syncHandler(alertGroupId, title, content); Assert.assertFalse(alertSendResponseCommand.getResStatus()); alertSendResponseCommand.getResResults().forEach(result -> - logger.info("alert send response result, status:{}, message:{}",result.getStatus(),result.getMessage())); + logger.info("alert send response result, status:{}, message:{}", result.getStatus(), result.getMessage())); //3.alert result value is null AlertChannel alertChannelMock = PowerMockito.mock(AlertChannel.class); PowerMockito.when(alertChannelMock.process(Mockito.any())).thenReturn(null); Map alertChannelMap = new ConcurrentHashMap<>(); - alertChannelMap.put(pluginName,alertChannelMock); + alertChannelMap.put(pluginName, alertChannelMock); PowerMockito.when(alertPluginManager.getAlertChannelMap()).thenReturn(alertChannelMap); + PowerMockito.when(alertPluginManager.getPluginNameById(Mockito.anyInt())).thenReturn("alert-plugin-mail"); alertSendResponseCommand = alertSender.syncHandler(alertGroupId, title, content); Assert.assertFalse(alertSendResponseCommand.getResStatus()); alertSendResponseCommand.getResResults().forEach(result -> - logger.info("alert send response result, status:{}, message:{}",result.getStatus(),result.getMessage())); + logger.info("alert send response result, status:{}, message:{}", result.getStatus(), result.getMessage())); //4.abnormal information inside the alert plug-in code AlertResult alertResult = new AlertResult(); @@ -114,27 +115,27 @@ public class AlertSenderTest { alertResult.setMessage("Abnormal information inside the alert plug-in code"); PowerMockito.when(alertChannelMock.process(Mockito.any())).thenReturn(alertResult); alertChannelMap = new ConcurrentHashMap<>(); - alertChannelMap.put(pluginName,alertChannelMock); + alertChannelMap.put(pluginName, alertChannelMock); PowerMockito.when(alertPluginManager.getAlertChannelMap()).thenReturn(alertChannelMap); alertSendResponseCommand = alertSender.syncHandler(alertGroupId, title, content); Assert.assertFalse(alertSendResponseCommand.getResStatus()); alertSendResponseCommand.getResResults().forEach(result -> - logger.info("alert send response result, status:{}, message:{}",result.getStatus(),result.getMessage())); + logger.info("alert send response result, status:{}, message:{}", result.getStatus(), result.getMessage())); //5.alert plugin send success alertResult = new AlertResult(); alertResult.setStatus(String.valueOf(true)); - alertResult.setMessage(String.format("Alert Plugin %s send success",pluginInstanceName)); + alertResult.setMessage(String.format("Alert Plugin %s send success", pluginInstanceName)); PowerMockito.when(alertChannelMock.process(Mockito.any())).thenReturn(alertResult); alertChannelMap = new ConcurrentHashMap<>(); - alertChannelMap.put(pluginName,alertChannelMock); + alertChannelMap.put(pluginName, alertChannelMock); PowerMockito.when(alertPluginManager.getAlertChannelMap()).thenReturn(alertChannelMap); alertSendResponseCommand = alertSender.syncHandler(alertGroupId, title, content); Assert.assertTrue(alertSendResponseCommand.getResStatus()); alertSendResponseCommand.getResResults().forEach(result -> - logger.info("alert send response result, status:{}, message:{}",result.getStatus(),result.getMessage())); + logger.info("alert send response result, status:{}, message:{}", result.getStatus(), result.getMessage())); } @@ -150,28 +151,29 @@ public class AlertSenderTest { alert.setContent(content); alertList.add(alert); - alertSender = new AlertSender(alertList,alertDao,alertPluginManager,pluginDao); + alertSender = new AlertSender(alertList, alertDao, alertPluginManager); int pluginDefineId = 1; String pluginInstanceParams = "alert-instance-mail-params"; String pluginInstanceName = "alert-instance-mail"; List alertInstanceList = new ArrayList<>(); AlertPluginInstance alertPluginInstance = new AlertPluginInstance( - pluginDefineId,pluginInstanceParams,pluginInstanceName); + pluginDefineId, pluginInstanceParams, pluginInstanceName); alertInstanceList.add(alertPluginInstance); PowerMockito.when(alertDao.listInstanceByAlertGroupId(alertGroupId)).thenReturn(alertInstanceList); String pluginName = "alert-plugin-mail"; - PluginDefine pluginDefine = new PluginDefine(pluginName,"1",null); + PluginDefine pluginDefine = new PluginDefine(pluginName, "1", null); PowerMockito.when(pluginDao.getPluginDefineById(pluginDefineId)).thenReturn(pluginDefine); + PowerMockito.when(alertPluginManager.getPluginNameById(1)).thenReturn("alert-instance-mail"); AlertResult alertResult = new AlertResult(); alertResult.setStatus(String.valueOf(true)); - alertResult.setMessage(String.format("Alert Plugin %s send success",pluginInstanceName)); + alertResult.setMessage(String.format("Alert Plugin %s send success", pluginInstanceName)); AlertChannel alertChannelMock = PowerMockito.mock(AlertChannel.class); PowerMockito.when(alertChannelMock.process(Mockito.any())).thenReturn(alertResult); ConcurrentHashMap alertChannelMap = new ConcurrentHashMap<>(); - alertChannelMap.put(pluginName,alertChannelMock); + alertChannelMap.put(pluginName, alertChannelMock); PowerMockito.when(alertPluginManager.getAlertChannelMap()).thenReturn(alertChannelMap); Assert.assertTrue(Boolean.parseBoolean(alertResult.getStatus())); alertSender.run(); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java index dede2c173a..4d3d35a76e 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java @@ -24,12 +24,17 @@ import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.vo.AlertPluginInstanceVO; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.utils.CollectionUtils; +import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.PluginDefine; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper; +import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; +import org.apache.dolphinscheduler.spi.params.base.PluginParams; + +import org.apache.commons.collections4.MapUtils; import java.util.ArrayList; import java.util.Arrays; @@ -37,6 +42,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.function.Function; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; @@ -73,7 +79,8 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert @Override public Map create(User loginUser, int pluginDefineId, String instanceName, String pluginInstanceParams) { AlertPluginInstance alertPluginInstance = new AlertPluginInstance(); - alertPluginInstance.setPluginInstanceParams(pluginInstanceParams); + String paramsMapJson = parsePluginParamsMap(pluginInstanceParams); + alertPluginInstance.setPluginInstanceParams(paramsMapJson); alertPluginInstance.setInstanceName(instanceName); alertPluginInstance.setPluginDefineId(pluginDefineId); @@ -88,7 +95,9 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert if (i > 0) { putMsg(result, Status.SUCCESS); + return result; } + putMsg(result, Status.SAVE_ERROR); return result; } @@ -104,7 +113,8 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert public Map update(User loginUser, int pluginInstanceId, String instanceName, String pluginInstanceParams) { AlertPluginInstance alertPluginInstance = new AlertPluginInstance(); - alertPluginInstance.setPluginInstanceParams(pluginInstanceParams); + String paramsMapJson = parsePluginParamsMap(pluginInstanceParams); + alertPluginInstance.setPluginInstanceParams(paramsMapJson); alertPluginInstance.setInstanceName(instanceName); alertPluginInstance.setId(pluginInstanceId); Map result = new HashMap<>(); @@ -112,8 +122,9 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert if (i > 0) { putMsg(result, Status.SUCCESS); + return result; } - + putMsg(result, Status.SAVE_ERROR); return result; } @@ -201,24 +212,66 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert if (CollectionUtils.isEmpty(pluginDefineList)) { return null; } - Map pluginDefineMap = pluginDefineList.stream().collect(Collectors.toMap(PluginDefine::getId, PluginDefine::getPluginName)); + Map pluginDefineMap = pluginDefineList.stream().collect(Collectors.toMap(PluginDefine::getId, Function.identity())); List alertPluginInstanceVOS = new ArrayList<>(); alertPluginInstances.forEach(alertPluginInstance -> { AlertPluginInstanceVO alertPluginInstanceVO = new AlertPluginInstanceVO(); - alertPluginInstanceVO.setAlertPluginName(pluginDefineMap.get(alertPluginInstance.getPluginDefineId())); + alertPluginInstanceVO.setCreateTime(alertPluginInstance.getCreateTime()); alertPluginInstanceVO.setUpdateTime(alertPluginInstance.getUpdateTime()); alertPluginInstanceVO.setPluginDefineId(alertPluginInstance.getPluginDefineId()); alertPluginInstanceVO.setInstanceName(alertPluginInstance.getInstanceName()); alertPluginInstanceVO.setId(alertPluginInstance.getId()); + PluginDefine pluginDefine = pluginDefineMap.get(alertPluginInstance.getPluginDefineId()); + //FIXME When the user removes the plug-in, this will happen. At this time, maybe we should add a new field to indicate that the plug-in has expired? + if (null == pluginDefine) { + return; + } + alertPluginInstanceVO.setAlertPluginName(pluginDefine.getPluginName()); //todo List pages do not recommend returning this parameter - alertPluginInstanceVO.setPluginInstanceParams(alertPluginInstance.getPluginInstanceParams()); + String pluginParamsMapString = alertPluginInstance.getPluginInstanceParams(); + String uiPluginParams = parseToPluginUiParams(pluginParamsMapString, pluginDefine.getPluginParams()); + alertPluginInstanceVO.setPluginInstanceParams(uiPluginParams); alertPluginInstanceVOS.add(alertPluginInstanceVO); }); return alertPluginInstanceVOS; } + /** + * Get the parameters actually needed by the plugin + * + * @param pluginParams Complete parameters(include ui) + * @return k, v(json string) + */ + private String parsePluginParamsMap(String pluginParams) { + Map paramsMap = PluginParamsTransfer.getPluginParamsMap(pluginParams); + return JSONUtils.toJsonString(paramsMap); + } + + /** + * parseToPluginUiParams + * + * @param pluginParamsMapString k-v data + * @param pluginUiParams Complete parameters(include ui) + * @return Complete parameters list(include ui) + */ + private String parseToPluginUiParams(String pluginParamsMapString, String pluginUiParams) { + Map paramsMap = JSONUtils.toMap(pluginParamsMapString); + if (MapUtils.isEmpty(paramsMap)) { + return null; + } + List pluginParamsList = JSONUtils.toList(pluginUiParams, PluginParams.class); + List newPluginParamsList = new ArrayList<>(pluginParamsList.size()); + pluginParamsList.forEach(pluginParams -> { + pluginParams.setValue(paramsMap.get(pluginParams.getName())); + newPluginParamsList.add(pluginParams); + + }); + + return JSONUtils.toJsonString(newPluginParamsList); + } + private boolean checkHasAssociatedAlertGroup(String id) { List idsList = alertGroupMapper.queryInstanceIdsList(); if (CollectionUtils.isEmpty(idsList)) { diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java index 7d25fb5e6a..fb58070304 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertPluginInstanceServiceTest.java @@ -22,6 +22,7 @@ import org.apache.dolphinscheduler.api.service.impl.AlertPluginInstanceServiceIm import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; +import org.apache.dolphinscheduler.dao.entity.PluginDefine; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper; @@ -29,6 +30,7 @@ import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.Map; @@ -60,6 +62,82 @@ public class AlertPluginInstanceServiceTest { private User user; + private String uiParams = "[\n" + + " {\n" + + " \"field\":\"userParams\",\n" + + " \"name\":\"user.params\",\n" + + " \"props\":{\n" + + " \"placeholder\":\"please enter your custom parameters, which will be passed to you when calling your script\",\n" + + " \"size\":\"small\"\n" + + " },\n" + + " \"type\":\"input\",\n" + + " \"title\":\"user.params\",\n" + + " \"value\":\"userParams\",\n" + + " \"validate\":[\n" + + " {\n" + + " \"required\":false,\n" + + " \"message\":null,\n" + + " \"type\":\"string\",\n" + + " \"trigger\":\"blur\",\n" + + " \"min\":null,\n" + + " \"max\":null\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"field\":\"path\",\n" + + " \"name\":\"path\",\n" + + " \"props\":{\n" + + " \"placeholder\":\"please upload the file to the disk directory of the alert server, and ensure that the path is absolute and has the corresponding access rights\",\n" + + " \"size\":\"small\"\n" + + " },\n" + + " \"type\":\"input\",\n" + + " \"title\":\"path\",\n" + + " \"value\":\"/kris/script/path\",\n" + + " \"validate\":[\n" + + " {\n" + + " \"required\":true,\n" + + " \"message\":null,\n" + + " \"type\":\"string\",\n" + + " \"trigger\":\"blur\",\n" + + " \"min\":null,\n" + + " \"max\":null\n" + + " }\n" + + " ]\n" + + " },\n" + + " {\n" + + " \"field\":\"type\",\n" + + " \"name\":\"type\",\n" + + " \"props\":{\n" + + " \"placeholder\":null,\n" + + " \"size\":\"small\"\n" + + " },\n" + + " \"type\":\"radio\",\n" + + " \"title\":\"type\",\n" + + " \"value\":0,\n" + + " \"validate\":[\n" + + " {\n" + + " \"required\":true,\n" + + " \"message\":null,\n" + + " \"type\":\"string\",\n" + + " \"trigger\":\"blur\",\n" + + " \"min\":null,\n" + + " \"max\":null\n" + + " }\n" + + " ],\n" + + " \"options\":[\n" + + " {\n" + + " \"label\":\"SHELL\",\n" + + " \"value\":0,\n" + + " \"disabled\":false\n" + + " }\n" + + " ]\n" + + " }\n" + + "]\n" + + "\n"; + + private String paramsMap = "{\"path\":\"/kris/script/path\",\"userParams\":\"userParams\",\"type\":\"0\"}"; + @Before public void before() { user = new User(); @@ -77,10 +155,10 @@ public class AlertPluginInstanceServiceTest { @Test public void testCreate() { Mockito.when(alertPluginInstanceMapper.queryByInstanceName("test")).thenReturn(alertPluginInstances); - Map result = alertPluginInstanceService.create(user, 1, "test", "test params"); + Map result = alertPluginInstanceService.create(user, 1, "test", uiParams); Assert.assertEquals(Status.PLUGIN_INSTANCE_ALREADY_EXIT, result.get(Constants.STATUS)); Mockito.when(alertPluginInstanceMapper.insert(Mockito.any())).thenReturn(1); - result = alertPluginInstanceService.create(user, 1, "test1", "test params"); + result = alertPluginInstanceService.create(user, 1, "test1", uiParams); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); } @@ -96,4 +174,31 @@ public class AlertPluginInstanceServiceTest { } + @Test + public void testUpdate() { + Mockito.when(alertPluginInstanceMapper.updateById(Mockito.any())).thenReturn(0); + Map result = alertPluginInstanceService.update(user, 1, "testUpdate", uiParams); + Assert.assertEquals(Status.SAVE_ERROR, result.get(Constants.STATUS)); + Mockito.when(alertPluginInstanceMapper.updateById(Mockito.any())).thenReturn(1); + result = alertPluginInstanceService.update(user, 1, "testUpdate", uiParams); + Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); + } + + @Test + public void testQueryAll() { + AlertPluginInstance alertPluginInstance = new AlertPluginInstance(); + alertPluginInstance.setId(1); + alertPluginInstance.setPluginDefineId(1); + alertPluginInstance.setPluginInstanceParams(paramsMap); + alertPluginInstance.setInstanceName("test"); + PluginDefine pluginDefine = new PluginDefine("script", "script", uiParams); + pluginDefine.setId(1); + List pluginDefines = Collections.singletonList(pluginDefine); + List pluginInstanceList = Collections.singletonList(alertPluginInstance); + Mockito.when(alertPluginInstanceMapper.queryAllAlertPluginInstanceList()).thenReturn(pluginInstanceList); + Mockito.when(pluginDefineMapper.queryAllPluginDefineList()).thenReturn(pluginDefines); + Map result = alertPluginInstanceService.queryAll(); + Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); + } + } diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/PluginDao.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/PluginDao.java index ab82997bc2..93df36aadc 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/PluginDao.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/PluginDao.java @@ -58,22 +58,22 @@ public class PluginDao extends AbstractBaseDao { * * @param pluginDefine new pluginDefine */ - public void addOrUpdatePluginDefine(PluginDefine pluginDefine) { + public int addOrUpdatePluginDefine(PluginDefine pluginDefine) { requireNonNull(pluginDefine, "pluginDefine is null"); requireNonNull(pluginDefine.getPluginName(), "pluginName is null"); requireNonNull(pluginDefine.getPluginType(), "pluginType is null"); List pluginDefineList = pluginDefineMapper.queryByNameAndType(pluginDefine.getPluginName(), pluginDefine.getPluginType()); if (pluginDefineList == null || pluginDefineList.size() == 0) { - pluginDefineMapper.insert(pluginDefine); - } else { - PluginDefine currPluginDefine = pluginDefineList.get(0); - if (!currPluginDefine.getPluginParams().equals(pluginDefine.getPluginParams())) { - currPluginDefine.setUpdateTime(pluginDefine.getUpdateTime()); - currPluginDefine.setPluginParams(pluginDefine.getPluginParams()); - pluginDefineMapper.updateById(currPluginDefine); - } + return pluginDefineMapper.insert(pluginDefine); } + PluginDefine currPluginDefine = pluginDefineList.get(0); + if (!currPluginDefine.getPluginParams().equals(pluginDefine.getPluginParams())) { + currPluginDefine.setUpdateTime(pluginDefine.getUpdateTime()); + currPluginDefine.setPluginParams(pluginDefine.getPluginParams()); + pluginDefineMapper.updateById(currPluginDefine); + } + return currPluginDefine.getId(); } /** diff --git a/dolphinscheduler-server/src/main/resources/logback-master.xml b/dolphinscheduler-server/src/main/resources/logback-master.xml index 2b986ddad2..a61d891b10 100644 --- a/dolphinscheduler-server/src/main/resources/logback-master.xml +++ b/dolphinscheduler-server/src/main/resources/logback-master.xml @@ -32,9 +32,9 @@ - + taskAppId diff --git a/dolphinscheduler-server/src/main/resources/logback-worker.xml b/dolphinscheduler-server/src/main/resources/logback-worker.xml index a09202fb7e..31719d5b53 100644 --- a/dolphinscheduler-server/src/main/resources/logback-worker.xml +++ b/dolphinscheduler-server/src/main/resources/logback-worker.xml @@ -33,9 +33,9 @@ - + taskAppId @@ -56,10 +56,9 @@ ${log.base}/dolphinscheduler-worker.log - + ${log.base}/dolphinscheduler-worker.%d{yyyy-MM-dd_HH}.%i.log 168 diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertInfo.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertInfo.java index c91428ce12..d6e54561e7 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertInfo.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertInfo.java @@ -17,6 +17,8 @@ package org.apache.dolphinscheduler.spi.alert; +import java.util.Map; + /** * AlertInfo */ @@ -25,18 +27,18 @@ public class AlertInfo { /** * all params this plugin need is in alertProps */ - private String alertParams; + private Map alertParams; /** * the alert content */ private AlertData alertData; - public String getAlertParams() { + public Map getAlertParams() { return alertParams; } - public void setAlertParams(String alertParams) { + public void setAlertParams(Map alertParams) { this.alertParams = alertParams; } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertResult.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertResult.java index a327d09403..6ce5425f7f 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertResult.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertResult.java @@ -38,4 +38,12 @@ public class AlertResult { public void setMessage(String message) { this.message = message; } + + public AlertResult(String status, String message) { + this.status = status; + this.message = message; + } + + public AlertResult() { + } } diff --git a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/PluginParams.java b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/PluginParams.java index 1fdf0e0792..34d60a26c4 100644 --- a/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/PluginParams.java +++ b/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/params/base/PluginParams.java @@ -165,6 +165,10 @@ public class PluginParams { public List getValidateList() { return validateList; } + + public void setValue(Object value) { + this.value = value; + } } diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue index abadc2c36b..fd8a2b8955 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/formModel/tasks/_source/dependItemList.vue @@ -16,26 +16,21 @@ */
{{$t('SQL Parameter')}}
@@ -142,6 +140,7 @@ import mDatasource from './_source/datasource' import mLocalParams from './_source/localParams' import mStatementList from './_source/statementList' + import mWarningGroups from './_source/warningGroups' import disabledState from '@/module/mixin/disabledState' import codemirror from '@/conf/home/pages/resource/pages/file/pages/_source/codemirror' @@ -167,8 +166,6 @@ sqlType: '0', // Email title title: '', - // Form/attachment - showType: ['TABLE'], // Sql parameter connParams: '', // Pre statements @@ -176,7 +173,8 @@ // Post statements postStatements: [], item: '', - scriptBoxDialog: false + scriptBoxDialog: false, + groupId: null } }, mixins: [disabledState], @@ -197,9 +195,6 @@ */ _onSqlType (a) { this.sqlType = a - if (a === 0) { - this.showType = ['TABLE'] - } }, /** * return udfs @@ -245,16 +240,12 @@ if (!this.$refs.refDs._verifDatasource()) { return false } - if (this.sqlType === 0 && !this.showType.length) { - this.$message.warning(`${i18n.$t('One form or attachment must be selected')}`) - return false - } - if (this.sqlType === 0 && !this.title) { + if (this.sqlType === '0' && !this.title) { this.$message.warning(`${i18n.$t('Mail subject required')}`) return false } - if (this.sqlType === 0 && !this.receivers.length) { - this.$message.warning(`${i18n.$t('Recipient required')}`) + if (this.sqlType === '0' && (this.groupId === '' || this.groupId === null)) { + this.$message.warning(`${i18n.$t('Alarm group required')}`) return false } // udfs Subcomponent verification Verification only if the data type is HIVE @@ -287,18 +278,7 @@ udfs: this.udfs, sqlType: this.sqlType, title: this.title, - showType: (() => { - /** - * Special processing return order TABLE,ATTACHMENT - * Handling checkout sequence - */ - let showType = this.showType - if (showType.length === 2 && showType[0] === 'ATTACHMENT') { - return [showType[1], showType[0]].join(',') - } else { - return showType.join(',') - } - })(), + groupId: this.groupId, localParams: this.localParams, connParams: this.connParams, preStatements: this.preStatements, @@ -347,14 +327,7 @@ udfs: this.udfs, sqlType: this.sqlType, title: this.title, - showType: (() => { - let showType = this.showType - if (showType.length === 2 && showType[0] === 'ATTACHMENT') { - return [showType[1], showType[0]].join(',') - } else { - return showType.join(',') - } - })(), + groupId: this.groupId, localParams: this.localParams, connParams: this.connParams, preStatements: this.preStatements, @@ -372,11 +345,9 @@ watch: { // Listening to sqlType sqlType (val) { - if (val === 0) { - this.showType = [] - } if (val !== 0) { this.title = '' + this.groupId = null } }, // Listening data source @@ -403,14 +374,10 @@ this.sqlType = o.params.sqlType this.connParams = o.params.connParams || '' this.localParams = o.params.localParams || [] - if (o.params.showType === '') { - this.showType = [] - } else { - this.showType = o.params.showType.split(',') || [] - } this.preStatements = o.params.preStatements || [] this.postStatements = o.params.postStatements || [] this.title = o.params.title || '' + this.groupId = o.params.groupId } }, mounted () { @@ -436,14 +403,7 @@ udfs: this.udfs, sqlType: this.sqlType, title: this.title, - showType: (() => { - let showType = this.showType - if (showType.length === 2 && showType[0] === 'ATTACHMENT') { - return [showType[1], showType[0]].join(',') - } else { - return showType.join(',') - } - })(), + groupId: this.groupId, localParams: this.localParams, connParams: this.connParams, preStatements: this.preStatements, @@ -451,6 +411,6 @@ } } }, - components: { mListBox, mDatasource, mLocalParams, mUdfs, mSqlType, mStatementList, mScriptBox } + components: { mListBox, mDatasource, mLocalParams, mUdfs, mSqlType, mStatementList, mScriptBox, mWarningGroups } } diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/startingParam/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/startingParam/index.vue index bcc91524ff..de42199a1a 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/startingParam/index.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/_source/startingParam/index.vue @@ -26,7 +26,7 @@
  • {{$t('Process priority')}}:{{startupParam.processInstancePriority}}
  • {{$t('Worker group')}}:{{startupParam.workerGroup}}
  • {{$t('Notification strategy')}}:{{_rtWarningType(startupParam.warningType)}}
  • -
  • {{$t('Notification group')}}:{{_rtNotifyGroupName(startupParam.warningGroupId)}}
  • +
  • {{$t('Alarm group')}}:{{_rtNotifyGroupName(startupParam.warningGroupId)}}
  • diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/definitionDetails.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/definitionDetails.vue index d9acb38453..65510bf69b 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/definitionDetails.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/definitionDetails.vue @@ -42,7 +42,7 @@ methods: { ...mapMutations('dag', ['resetParams', 'setIsDetails']), ...mapActions('dag', ['getProcessList', 'getProjectList', 'getResourcesList', 'getProcessDetails', 'getResourcesListJar']), - ...mapActions('security', ['getTenantList', 'getWorkerGroupsAll']), + ...mapActions('security', ['getTenantList', 'getWorkerGroupsAll', 'getAlarmGroupsAll']), /** * init */ @@ -64,6 +64,8 @@ this.getResourcesListJar(), // get worker group list this.getWorkerGroupsAll(), + // get alarm group list + this.getAlarmGroupsAll(), this.getTenantList() ]).then((data) => { let item = data[0] diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/index.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/index.vue index d232e2dd86..81d129a47e 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/index.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/index.vue @@ -41,7 +41,7 @@ methods: { ...mapMutations('dag', ['resetParams']), ...mapActions('dag', ['getProcessList', 'getProjectList', 'getResourcesList', 'getResourcesListJar', 'getResourcesListJar']), - ...mapActions('security', ['getTenantList', 'getWorkerGroupsAll']), + ...mapActions('security', ['getTenantList', 'getWorkerGroupsAll', 'getAlarmGroupsAll']), /** * init */ @@ -63,6 +63,8 @@ this.getResourcesListJar(), // get worker group list this.getWorkerGroupsAll(), + // get alarm group list + this.getAlarmGroupsAll(), this.getTenantList() ]).then((data) => { this.isLoading = false diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/dag/instanceDetails.vue b/dolphinscheduler-ui/src/js/conf/home/pages/dag/instanceDetails.vue index 0727d12eed..f9561bd52c 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/dag/instanceDetails.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/dag/instanceDetails.vue @@ -44,7 +44,7 @@ methods: { ...mapMutations('dag', ['setIsDetails', 'resetParams']), ...mapActions('dag', ['getProcessList', 'getProjectList', 'getResourcesList', 'getInstancedetail', 'getResourcesListJar']), - ...mapActions('security', ['getTenantList', 'getWorkerGroupsAll']), + ...mapActions('security', ['getTenantList', 'getWorkerGroupsAll', 'getAlarmGroupsAll']), /** * init */ @@ -66,6 +66,8 @@ this.getResourcesListJar(), // get worker group list this.getWorkerGroupsAll(), + // get alarm group list + this.getAlarmGroupsAll(), this.getTenantList() ]).then((data) => { let item = data[0] diff --git a/dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/_source/zookeeperDirectories.vue b/dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/_source/zookeeperDirectories.vue index ca4f6ad728..088063b01e 100644 --- a/dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/_source/zookeeperDirectories.vue +++ b/dolphinscheduler-ui/src/js/conf/home/pages/monitor/pages/servers/_source/zookeeperDirectories.vue @@ -15,13 +15,9 @@ * limitations under the License. */