Browse Source

[Improvement][alert-spi]plugin instance only saves the main information

plugin instance only saves the main information

when users need to display all the complete information (usually UI display), then do the conversion.
data_quality_design
CalvinKirs 3 years ago
parent
commit
5f23ca5dee
  1. 3
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannel.java
  2. 9
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java
  3. 23
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelFactoryTest.java
  4. 6
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/test/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannelTest.java
  5. 9
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java
  6. 7
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/test/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannelTest.java
  7. 8
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/main/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannel.java
  8. 12
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactoryTest.java
  9. 9
      dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java
  10. 15
      dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java
  11. 11
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java
  12. 8
      dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertInfo.java

3
dolphinscheduler-alert-plugin/dolphinscheduler-alert-dingtalk/src/main/java/org/apache/dolphinscheduler/plugin/alert/dingtalk/DingTalkAlertChannel.java

@ -34,8 +34,7 @@ public class DingTalkAlertChannel implements AlertChannel {
public AlertResult process(AlertInfo alertInfo) { public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData(); AlertData alertData = alertInfo.getAlertData();
String alertParams = alertInfo.getAlertParams(); Map<String, String> paramsMap = alertInfo.getAlertParams();
Map paramsMap = JSONUtils.parseObject(alertParams,Map.class);
if(null==paramsMap){ if(null==paramsMap){
return new AlertResult("false","ding talk params is null"); return new AlertResult("false","ding talk params is null");
} }

9
dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/src/main/java/org/apache/dolphinscheduler/plugin/alert/email/EmailAlertChannel.java

@ -21,8 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertData;
import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertInfo;
import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.alert.AlertResult;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.Map; import java.util.Map;
@ -39,10 +37,9 @@ public class EmailAlertChannel implements AlertChannel {
public AlertResult process(AlertInfo info) { public AlertResult process(AlertInfo info) {
AlertData alert = info.getAlertData(); AlertData alert = info.getAlertData();
String alertParams = info.getAlertParams(); Map<String, String> paramsMap = info.getAlertParams();
Map paramsMap = JSONUtils.parseObject(alertParams,Map.class); if (null == paramsMap) {
if(null==paramsMap){ return new AlertResult("false", "mail params is null");
return new AlertResult("false","mail params is null");
} }
MailSender mailSender = new MailSender(paramsMap); MailSender mailSender = new MailSender(paramsMap);
AlertResult alertResult = mailSender.sendMails(alert.getTitle(), alert.getContent()); AlertResult alertResult = mailSender.sendMails(alert.getTitle(), alert.getContent());

23
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.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.List; import java.util.List;
import org.junit.After;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
/** /**
@ -36,29 +33,13 @@ import org.junit.Test;
*/ */
public class EmailAlertChannelFactoryTest { 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() * Method: getParams()
*/ */
@Test @Test
public void testGetParams() throws Exception { public void testGetParams() {
EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory(); EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory();
List<PluginParams> params = emailAlertChannelFactory.getParams(); List<PluginParams> params = emailAlertChannelFactory.getParams();
System.out.println(JSONUtils.toJsonString(params));
Assert.assertEquals(12, params.size()); Assert.assertEquals(12, params.size());
} }
@ -66,7 +47,7 @@ public class EmailAlertChannelFactoryTest {
* Method: create() * Method: create()
*/ */
@Test @Test
public void testCreate() throws Exception { public void testCreate() {
EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory(); EmailAlertChannelFactory emailAlertChannelFactory = new EmailAlertChannelFactory();
AlertChannel alertChannel = emailAlertChannelFactory.create(); AlertChannel alertChannel = emailAlertChannelFactory.create();
Assert.assertNotNull(alertChannel); Assert.assertNotNull(alertChannel);

6
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.alert.ShowType;
import org.apache.dolphinscheduler.spi.params.InputParam; import org.apache.dolphinscheduler.spi.params.InputParam;
import org.apache.dolphinscheduler.spi.params.PasswordParam; 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.RadioParam;
import org.apache.dolphinscheduler.spi.params.base.DataType; import org.apache.dolphinscheduler.spi.params.base.DataType;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions; 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.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -66,7 +68,9 @@ public class EmailAlertChannelTest {
.setTitle("test"); .setTitle("test");
AlertInfo alertInfo = new AlertInfo(); AlertInfo alertInfo = new AlertInfo();
alertInfo.setAlertData(alertData); alertInfo.setAlertData(alertData);
alertInfo.setAlertParams(getEmailAlertParams()); Map<String, String> paramsMap = PluginParamsTransfer.getPluginParamsMap(getEmailAlertParams());
alertInfo.setAlertParams(paramsMap);
AlertResult alertResult = emailAlertChannel.process(alertInfo); AlertResult alertResult = emailAlertChannel.process(alertInfo);
Assert.assertNotNull(alertResult); Assert.assertNotNull(alertResult);
Assert.assertEquals("false", alertResult.getStatus()); Assert.assertEquals("false", alertResult.getStatus());

9
dolphinscheduler-alert-plugin/dolphinscheduler-alert-http/src/main/java/org/apache/dolphinscheduler/plugin/alert/http/HttpAlertChannel.java

@ -21,8 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertData;
import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertInfo;
import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.alert.AlertResult;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.Map; import java.util.Map;
@ -34,10 +32,9 @@ public class HttpAlertChannel implements AlertChannel {
public AlertResult process(AlertInfo alertInfo) { public AlertResult process(AlertInfo alertInfo) {
AlertData alertData = alertInfo.getAlertData(); AlertData alertData = alertInfo.getAlertData();
String alertParams = alertInfo.getAlertParams(); Map<String, String> paramsMap = alertInfo.getAlertParams();
Map paramsMap = JSONUtils.parseObject(alertParams,Map.class); if (null == paramsMap) {
if(null==paramsMap){ return new AlertResult("false", "http params is null");
return new AlertResult("false","http params is null");
} }
return new HttpSender(paramsMap).send(alertData.getContent()); return new HttpSender(paramsMap).send(alertData.getContent());

7
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.AlertInfo;
import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.alert.AlertResult;
import org.apache.dolphinscheduler.spi.params.InputParam; 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.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate; import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.utils.JSONUtils; import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -45,7 +47,7 @@ public class HttpAlertChannelTest {
alertData.setContent("Fault tolerance warning"); alertData.setContent("Fault tolerance warning");
alertInfo.setAlertData(alertData); alertInfo.setAlertData(alertData);
AlertResult alertResult = alertChannel.process(alertInfo); AlertResult alertResult = alertChannel.process(alertInfo);
Assert.assertEquals("Request types are not supported", alertResult.getMessage()); Assert.assertEquals("http params is null", alertResult.getMessage());
} }
@Test @Test
@ -56,7 +58,8 @@ public class HttpAlertChannelTest {
AlertData alertData = new AlertData(); AlertData alertData = new AlertData();
alertData.setContent("Fault tolerance warning"); alertData.setContent("Fault tolerance warning");
alertInfo.setAlertData(alertData); alertInfo.setAlertData(alertData);
alertInfo.setAlertParams(getParams()); Map<String, String> paramsMap = PluginParamsTransfer.getPluginParamsMap(getParams());
alertInfo.setAlertParams(paramsMap);
AlertResult alertResult = alertChannel.process(alertInfo); AlertResult alertResult = alertChannel.process(alertInfo);
Assert.assertEquals("true", alertResult.getStatus()); Assert.assertEquals("true", alertResult.getStatus());
} }

8
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.AlertData;
import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertInfo;
import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.alert.AlertResult;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.Map; import java.util.Map;
@ -33,10 +32,9 @@ public class ScriptAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo alertinfo) { public AlertResult process(AlertInfo alertinfo) {
AlertData alertData = alertinfo.getAlertData(); AlertData alertData = alertinfo.getAlertData();
String alertParams = alertinfo.getAlertParams(); Map<String, String> paramsMap = alertinfo.getAlertParams();
Map paramsMap = JSONUtils.parseObject(alertParams,Map.class); if (null == paramsMap) {
if(null==paramsMap){ return new AlertResult("false", "ding talk params is null");
return new AlertResult("false","ding talk params is null");
} }
return new ScriptSender(paramsMap).sendScriptAlert(alertData.getTitle()); return new ScriptSender(paramsMap).sendScriptAlert(alertData.getTitle());
} }

12
dolphinscheduler-alert-plugin/dolphinscheduler-alert-script/src/test/java/org/apache/dolphinscheduler/plugin/alert/script/ScriptAlertChannelFactoryTest.java

@ -18,11 +18,8 @@
package org.apache.dolphinscheduler.plugin.alert.script; package org.apache.dolphinscheduler.plugin.alert.script;
import org.apache.dolphinscheduler.spi.alert.AlertChannel; import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.junit.Assert; import org.junit.Assert;
@ -37,16 +34,7 @@ public class ScriptAlertChannelFactoryTest {
public void testGetParams() { public void testGetParams() {
ScriptAlertChannelFactory scriptAlertChannelFactory = new ScriptAlertChannelFactory(); ScriptAlertChannelFactory scriptAlertChannelFactory = new ScriptAlertChannelFactory();
List<PluginParams> params = scriptAlertChannelFactory.getParams(); List<PluginParams> params = scriptAlertChannelFactory.getParams();
String pluginParamsMapString= JSONUtils.toJsonString(PluginParamsTransfer.getPluginParamsMap(JSONUtils.toJsonString(params)));
HashMap paramsMap= JSONUtils.parseObject(pluginParamsMapString,HashMap.class);
System.out.println(paramsMap.get("path"));
Assert.assertEquals(3, params.size()); Assert.assertEquals(3, params.size());
List<PluginParams> paramss= JSONUtils.toList(JSONUtils.toJsonString(params),PluginParams.class);
System.out.println(PluginParamsTransfer.getPluginParamsMap(JSONUtils.toJsonString(params)));
System.out.println(paramss.get(0).getName());
System.out.println(paramss.get(0).getName());
} }
@Test @Test

9
dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannel.java

@ -21,8 +21,6 @@ import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.alert.AlertData; import org.apache.dolphinscheduler.spi.alert.AlertData;
import org.apache.dolphinscheduler.spi.alert.AlertInfo; import org.apache.dolphinscheduler.spi.alert.AlertInfo;
import org.apache.dolphinscheduler.spi.alert.AlertResult; import org.apache.dolphinscheduler.spi.alert.AlertResult;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.utils.JSONUtils;
import java.util.Map; import java.util.Map;
@ -34,10 +32,9 @@ public class WeChatAlertChannel implements AlertChannel {
@Override @Override
public AlertResult process(AlertInfo info) { public AlertResult process(AlertInfo info) {
AlertData alertData = info.getAlertData(); AlertData alertData = info.getAlertData();
String alertParams = info.getAlertParams(); Map<String, String> paramsMap = info.getAlertParams();
Map paramsMap = JSONUtils.parseObject(alertParams,Map.class); if (null == paramsMap) {
if(null==paramsMap){ return new AlertResult("false", "we chat params is null");
return new AlertResult("false","we chat params is null");
} }
return new WeChatSender(paramsMap).sendEnterpriseWeChat(alertData.getTitle(), alertData.getContent()); return new WeChatSender(paramsMap).sendEnterpriseWeChat(alertData.getTitle(), alertData.getContent());

15
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/runner/AlertSender.java

@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.alert.runner;
import org.apache.dolphinscheduler.alert.plugin.AlertPluginManager; import org.apache.dolphinscheduler.alert.plugin.AlertPluginManager;
import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.utils.CollectionUtils; 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.AlertDao;
import org.apache.dolphinscheduler.dao.PluginDao; import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.Alert;
@ -33,6 +34,7 @@ import org.apache.dolphinscheduler.spi.alert.AlertResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -79,9 +81,9 @@ public class AlertSender {
} }
AlertData alertData = new AlertData(); AlertData alertData = new AlertData();
alertData.setId(alert.getId()) alertData.setId(alert.getId())
.setContent(alert.getContent()) .setContent(alert.getContent())
.setLog(alert.getLog()) .setLog(alert.getLog())
.setTitle(alert.getTitle()); .setTitle(alert.getTitle());
for (AlertPluginInstance instance : alertInstanceList) { for (AlertPluginInstance instance : alertInstanceList) {
@ -107,7 +109,7 @@ public class AlertSender {
List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId); List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId);
AlertData alertData = new AlertData(); AlertData alertData = new AlertData();
alertData.setContent(content) alertData.setContent(content)
.setTitle(title); .setTitle(title);
boolean sendResponseStatus = true; boolean sendResponseStatus = true;
List<AlertSendResponseResult> sendResponseResults = new ArrayList<>(); List<AlertSendResponseResult> sendResponseResults = new ArrayList<>();
@ -126,7 +128,7 @@ public class AlertSender {
for (AlertPluginInstance instance : alertInstanceList) { for (AlertPluginInstance instance : alertInstanceList) {
AlertResult alertResult = this.alertResultHandler(instance, alertData); AlertResult alertResult = this.alertResultHandler(instance, alertData);
AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult( AlertSendResponseResult alertSendResponseResult = new AlertSendResponseResult(
Boolean.parseBoolean(String.valueOf(alertResult.getStatus())), alertResult.getMessage()); Boolean.parseBoolean(String.valueOf(alertResult.getStatus())), alertResult.getMessage());
sendResponseStatus = sendResponseStatus && alertSendResponseResult.getStatus(); sendResponseStatus = sendResponseStatus && alertSendResponseResult.getStatus();
sendResponseResults.add(alertSendResponseResult); sendResponseResults.add(alertSendResponseResult);
} }
@ -156,7 +158,8 @@ public class AlertSender {
AlertInfo alertInfo = new AlertInfo(); AlertInfo alertInfo = new AlertInfo();
alertInfo.setAlertData(alertData); alertInfo.setAlertData(alertData);
alertInfo.setAlertParams(instance.getPluginInstanceParams()); Map<String, String> paramsMap = JSONUtils.toMap(instance.getPluginInstanceParams());
alertInfo.setAlertParams(paramsMap);
AlertResult alertResult = alertChannel.process(alertInfo); AlertResult alertResult = alertChannel.process(alertInfo);
if (alertResult == null) { if (alertResult == null) {

11
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java

@ -33,6 +33,8 @@ import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer; import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.params.base.PluginParams; import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.commons.collections4.MapUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -215,7 +217,7 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert
alertPluginInstanceVO.setAlertPluginName(pluginDefine.getPluginName()); alertPluginInstanceVO.setAlertPluginName(pluginDefine.getPluginName());
//todo List pages do not recommend returning this parameter //todo List pages do not recommend returning this parameter
String pluginParamsMapString = alertPluginInstance.getPluginInstanceParams(); String pluginParamsMapString = alertPluginInstance.getPluginInstanceParams();
String uiPluginParams=parseToPluginUiParams(pluginParamsMapString,pluginDefine.getPluginParams()); String uiPluginParams = parseToPluginUiParams(pluginParamsMapString, pluginDefine.getPluginParams());
alertPluginInstanceVO.setPluginInstanceParams(uiPluginParams); alertPluginInstanceVO.setPluginInstanceParams(uiPluginParams);
alertPluginInstanceVOS.add(alertPluginInstanceVO); alertPluginInstanceVOS.add(alertPluginInstanceVO);
}); });
@ -242,9 +244,10 @@ public class AlertPluginInstanceServiceImpl extends BaseService implements Alert
* @return Complete parameters list(include ui) * @return Complete parameters list(include ui)
*/ */
private String parseToPluginUiParams(String pluginParamsMapString, String pluginUiParams) { private String parseToPluginUiParams(String pluginParamsMapString, String pluginUiParams) {
//todo npe Map<String, String> paramsMap = JSONUtils.toMap(pluginParamsMapString);
HashMap paramsMap = JSONUtils.parseObject(pluginParamsMapString, HashMap.class); if (MapUtils.isEmpty(paramsMap)) {
assert paramsMap != null; return null;
}
List<PluginParams> pluginParamsList = JSONUtils.toList(pluginUiParams, PluginParams.class); List<PluginParams> pluginParamsList = JSONUtils.toList(pluginUiParams, PluginParams.class);
List<PluginParams> newPluginParamsList = new ArrayList<>(pluginParamsList.size()); List<PluginParams> newPluginParamsList = new ArrayList<>(pluginParamsList.size());
pluginParamsList.forEach(pluginParams -> { pluginParamsList.forEach(pluginParams -> {

8
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/alert/AlertInfo.java

@ -17,6 +17,8 @@
package org.apache.dolphinscheduler.spi.alert; package org.apache.dolphinscheduler.spi.alert;
import java.util.Map;
/** /**
* AlertInfo * AlertInfo
*/ */
@ -25,18 +27,18 @@ public class AlertInfo {
/** /**
* all params this plugin need is in alertProps * all params this plugin need is in alertProps
*/ */
private String alertParams; private Map<String,String> alertParams;
/** /**
* the alert content * the alert content
*/ */
private AlertData alertData; private AlertData alertData;
public String getAlertParams() { public Map<String, String> getAlertParams() {
return alertParams; return alertParams;
} }
public void setAlertParams(String alertParams) { public void setAlertParams(Map<String, String> alertParams) {
this.alertParams = alertParams; this.alertParams = alertParams;
} }

Loading…
Cancel
Save