未验证 提交 c49626b8 编写于 作者: M muzhongjiang 提交者: GitHub

Word spelling modification,Comment modification,Log level modification (#3180)

* add state

* fixed bug "jackson enum conversion  : InvalidFormatException"

* Word spelling modification
Comment modification
Word spelling modification,Comment modification,Log level modification

* Update EmailManager.java

* Update FlinkParameters.java

* Update SqlTask.java
Co-authored-by: Nmzjnumber1@163.com <mzjnumber1@163.com>
Co-authored-by: Ndailidong <dailidong66@gmail.com>
上级 6fa37013
...@@ -27,28 +27,29 @@ import java.util.Map; ...@@ -27,28 +27,29 @@ import java.util.Map;
public class EmailManager { public class EmailManager {
/** /**
* email send * email send
* @param receviersList the receiver list * @param receiversList the receiver list
* @param receviersCcList the cc List * @param receiversCcList the cc List
* @param title the title * @param title the title
* @param content the content * @param content the content
* @param showType the showType * @param showType the showType
* @return the send result * @return the send result
*/ */
public Map<String,Object> send(List<String> receviersList,List<String> receviersCcList,String title,String content,String showType){ public Map<String,Object> send(List<String> receiversList,List<String> receiversCcList,String title,String content,String showType){
return MailUtils.sendMails(receviersList, receviersCcList, title, content, showType); return MailUtils.sendMails(receiversList, receiversCcList, title, content, showType);
} }
/** /**
* msg send * msg send
* @param receviersList the receiver list * @param receiversList the receiver list
* @param title the title * @param title the title
* @param content the content * @param content the content
* @param showType the showType * @param showType the showType
* @return the send result * @return the send result
*/ */
public Map<String,Object> send(List<String> receviersList,String title,String content,String showType){ public Map<String,Object> send(List<String> receiversList,String title,String content,String showType){
return MailUtils.sendMails(receviersList,title, content, showType); return MailUtils.sendMails(receiversList,title, content, showType);
} }
} }
...@@ -71,32 +71,32 @@ public class EmailAlertPlugin implements AlertPlugin { ...@@ -71,32 +71,32 @@ public class EmailAlertPlugin implements AlertPlugin {
AlertData alert = info.getAlertData(); AlertData alert = info.getAlertData();
List<String> receviersList = (List<String>) info.getProp(Constants.PLUGIN_DEFAULT_EMAIL_RECEIVERS); List<String> receiversList = (List<String>) info.getProp(Constants.PLUGIN_DEFAULT_EMAIL_RECEIVERS);
// receiving group list // receiving group list
// custom receiver // custom receiver
String receivers = alert.getReceivers(); String receivers = alert.getReceivers();
if (StringUtils.isNotEmpty(receivers)) { if (StringUtils.isNotEmpty(receivers)) {
String[] splits = receivers.split(","); String[] splits = receivers.split(",");
receviersList.addAll(Arrays.asList(splits)); receiversList.addAll(Arrays.asList(splits));
} }
List<String> receviersCcList = new ArrayList<>(); List<String> receiversCcList = new ArrayList<>();
// Custom Copier // Custom Copier
String receiversCc = alert.getReceiversCc(); String receiversCc = alert.getReceiversCc();
if (StringUtils.isNotEmpty(receiversCc)) { if (StringUtils.isNotEmpty(receiversCc)) {
String[] splits = receiversCc.split(","); String[] splits = receiversCc.split(",");
receviersCcList.addAll(Arrays.asList(splits)); receiversCcList.addAll(Arrays.asList(splits));
} }
if (CollectionUtils.isEmpty(receviersList) && CollectionUtils.isEmpty(receviersCcList)) { if (CollectionUtils.isEmpty(receiversList) && CollectionUtils.isEmpty(receiversCcList)) {
logger.warn("alert send error : At least one receiver address required"); logger.warn("alert send error : At least one receiver address required");
retMaps.put(Constants.STATUS, "false"); retMaps.put(Constants.STATUS, "false");
retMaps.put(Constants.MESSAGE, "execution failure,At least one receiver address required."); retMaps.put(Constants.MESSAGE, "execution failure,At least one receiver address required.");
return retMaps; return retMaps;
} }
retMaps = emailManager.send(receviersList, receviersCcList, alert.getTitle(), alert.getContent(), retMaps = emailManager.send(receiversList, receiversCcList, alert.getTitle(), alert.getContent(),
alert.getShowType()); alert.getShowType());
//send flag //send flag
...@@ -124,7 +124,7 @@ public class EmailAlertPlugin implements AlertPlugin { ...@@ -124,7 +124,7 @@ public class EmailAlertPlugin implements AlertPlugin {
logger.error(e.getMessage(), e); logger.error(e.getMessage(), e);
} }
} }
if (DingTalkUtils.isEnableDingTalk) { if (DingTalkUtils.isEnableDingTalk) {
logger.info("Ding Talk is enable."); logger.info("Ding Talk is enable.");
dingTalkManager.send(info); dingTalkManager.send(info);
......
...@@ -60,9 +60,9 @@ public class AlertSender { ...@@ -60,9 +60,9 @@ public class AlertSender {
users = alertDao.listUserByAlertgroupId(alert.getAlertGroupId()); users = alertDao.listUserByAlertgroupId(alert.getAlertGroupId());
// receiving group list // receiving group list
List<String> receviersList = new ArrayList<>(); List<String> receiversList = new ArrayList<>();
for (User user : users) { for (User user : users) {
receviersList.add(user.getEmail()); receiversList.add(user.getEmail());
} }
AlertData alertData = new AlertData(); AlertData alertData = new AlertData();
...@@ -78,17 +78,17 @@ public class AlertSender { ...@@ -78,17 +78,17 @@ public class AlertSender {
AlertInfo alertInfo = new AlertInfo(); AlertInfo alertInfo = new AlertInfo();
alertInfo.setAlertData(alertData); alertInfo.setAlertData(alertData);
alertInfo.addProp("receivers", receviersList); alertInfo.addProp("receivers", receiversList);
AlertPlugin emailPlugin = pluginManager.findOne(Constants.PLUGIN_DEFAULT_EMAIL_ID); AlertPlugin emailPlugin = pluginManager.findOne(Constants.PLUGIN_DEFAULT_EMAIL_ID);
retMaps = emailPlugin.process(alertInfo); retMaps = emailPlugin.process(alertInfo);
if (retMaps == null) { if (retMaps == null) {
alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, "alert send error", alert.getId()); alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, "alert send error", alert.getId());
logger.info("alert send error : return value is null"); logger.error("alert send error : return value is null");
} else if (!Boolean.parseBoolean(String.valueOf(retMaps.get(Constants.STATUS)))) { } else if (!Boolean.parseBoolean(String.valueOf(retMaps.get(Constants.STATUS)))) {
alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, String.valueOf(retMaps.get(Constants.MESSAGE)), alert.getId()); alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, String.valueOf(retMaps.get(Constants.MESSAGE)), alert.getId());
logger.info("alert send error : {}", retMaps.get(Constants.MESSAGE)); logger.error("alert send error : {}", retMaps.get(Constants.MESSAGE));
} else { } else {
alertDao.updateAlert(AlertStatus.EXECUTION_SUCCESS, (String) retMaps.get(Constants.MESSAGE), alert.getId()); alertDao.updateAlert(AlertStatus.EXECUTION_SUCCESS, (String) retMaps.get(Constants.MESSAGE), alert.getId());
logger.info("alert send success"); logger.info("alert send success");
......
...@@ -19,13 +19,12 @@ package org.apache.dolphinscheduler.common.task.flink; ...@@ -19,13 +19,12 @@ package org.apache.dolphinscheduler.common.task.flink;
import org.apache.dolphinscheduler.common.enums.ProgramType; import org.apache.dolphinscheduler.common.enums.ProgramType;
import org.apache.dolphinscheduler.common.process.ResourceInfo; import org.apache.dolphinscheduler.common.process.ResourceInfo;
import org.apache.dolphinscheduler.common.task.AbstractParameters; import org.apache.dolphinscheduler.common.task.AbstractParameters;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* spark parameters * flink parameters
*/ */
public class FlinkParameters extends AbstractParameters { public class FlinkParameters extends AbstractParameters {
...@@ -226,6 +225,4 @@ public class FlinkParameters extends AbstractParameters { ...@@ -226,6 +225,4 @@ public class FlinkParameters extends AbstractParameters {
} }
return resourceList; return resourceList;
} }
} }
...@@ -176,6 +176,7 @@ public class SqlTask extends AbstractTask { ...@@ -176,6 +176,7 @@ public class SqlTask extends AbstractTask {
logger.info("SQL title : {}",title); logger.info("SQL title : {}",title);
sqlParameters.setTitle(title); sqlParameters.setTitle(title);
} }
//new //new
//replace variable TIME with $[YYYYmmddd...] in sql when history run job and batch complement job //replace variable TIME with $[YYYYmmddd...] in sql when history run job and batch complement job
sql = ParameterUtils.replaceScheduleTime(sql, taskExecutionContext.getScheduleTime()); sql = ParameterUtils.replaceScheduleTime(sql, taskExecutionContext.getScheduleTime());
...@@ -324,6 +325,7 @@ public class SqlTask extends AbstractTask { ...@@ -324,6 +325,7 @@ public class SqlTask extends AbstractTask {
} }
} }
} }
/** /**
* create connection * create connection
* *
...@@ -423,34 +425,34 @@ public class SqlTask extends AbstractTask { ...@@ -423,34 +425,34 @@ public class SqlTask extends AbstractTask {
List<User> users = alertDao.queryUserByAlertGroupId(taskExecutionContext.getSqlTaskExecutionContext().getWarningGroupId()); List<User> users = alertDao.queryUserByAlertGroupId(taskExecutionContext.getSqlTaskExecutionContext().getWarningGroupId());
// receiving group list // receiving group list
List<String> receviersList = new ArrayList<>(); List<String> receiversList = new ArrayList<>();
for(User user:users){ for(User user:users){
receviersList.add(user.getEmail().trim()); receiversList.add(user.getEmail().trim());
} }
// custom receiver // custom receiver
String receivers = sqlParameters.getReceivers(); String receivers = sqlParameters.getReceivers();
if (StringUtils.isNotEmpty(receivers)){ if (StringUtils.isNotEmpty(receivers)){
String[] splits = receivers.split(COMMA); String[] splits = receivers.split(COMMA);
for (String receiver : splits){ for (String receiver : splits){
receviersList.add(receiver.trim()); receiversList.add(receiver.trim());
} }
} }
// copy list // copy list
List<String> receviersCcList = new ArrayList<>(); List<String> receiversCcList = new ArrayList<>();
// Custom Copier // Custom Copier
String receiversCc = sqlParameters.getReceiversCc(); String receiversCc = sqlParameters.getReceiversCc();
if (StringUtils.isNotEmpty(receiversCc)){ if (StringUtils.isNotEmpty(receiversCc)){
String[] splits = receiversCc.split(COMMA); String[] splits = receiversCc.split(COMMA);
for (String receiverCc : splits){ for (String receiverCc : splits){
receviersCcList.add(receiverCc.trim()); receiversCcList.add(receiverCc.trim());
} }
} }
String showTypeName = sqlParameters.getShowType().replace(COMMA,"").trim(); String showTypeName = sqlParameters.getShowType().replace(COMMA,"").trim();
if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){ if(EnumUtils.isValidEnum(ShowType.class,showTypeName)){
Map<String, Object> mailResult = MailUtils.sendMails(receviersList, Map<String, Object> mailResult = MailUtils.sendMails(receiversList,
receviersCcList, title, content, ShowType.valueOf(showTypeName).getDescp()); receiversCcList, title, content, ShowType.valueOf(showTypeName).getDescp());
if(!(boolean) mailResult.get(STATUS)){ if(!(boolean) mailResult.get(STATUS)){
throw new RuntimeException("send mail failed!"); throw new RuntimeException("send mail failed!");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册