Refactor code, add class import, keep ‘logger’ variable names uniform. (#7164)
parent
db090685a8
commit
fa8ccd3855
|
|
@ -41,9 +41,10 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class DingTalkSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(DingTalkSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(DingTalkSender.class);
|
||||
private final String url;
|
||||
private final String keyword;
|
||||
private final Boolean enableProxy;
|
||||
|
|
@ -109,13 +110,13 @@ public final class DingTalkSender {
|
|||
|
||||
if (null == result) {
|
||||
alertResult.setMessage("send ding talk msg error");
|
||||
log.info("send ding talk msg error,ding talk server resp is null");
|
||||
logger.info("send ding talk msg error,ding talk server resp is null");
|
||||
return alertResult;
|
||||
}
|
||||
DingTalkSendMsgResponse sendMsgResponse = JSONUtils.parseObject(result, DingTalkSendMsgResponse.class);
|
||||
if (null == sendMsgResponse) {
|
||||
alertResult.setMessage("send ding talk msg fail");
|
||||
log.info("send ding talk msg error,resp error");
|
||||
logger.info("send ding talk msg error,resp error");
|
||||
return alertResult;
|
||||
}
|
||||
if (sendMsgResponse.errcode == 0) {
|
||||
|
|
@ -124,7 +125,7 @@ public final class DingTalkSender {
|
|||
return alertResult;
|
||||
}
|
||||
alertResult.setMessage(String.format("alert send ding talk msg error : %s", sendMsgResponse.getErrmsg()));
|
||||
log.info("alert send ding talk msg error : {}", sendMsgResponse.getErrmsg());
|
||||
logger.info("alert send ding talk msg error : {}", sendMsgResponse.getErrmsg());
|
||||
return alertResult;
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +135,7 @@ public final class DingTalkSender {
|
|||
String resp = sendMsg(title, content);
|
||||
return checkSendDingTalkSendMsgResult(resp);
|
||||
} catch (Exception e) {
|
||||
log.info("send ding talk alert msg exception : {}", e.getMessage());
|
||||
logger.info("send ding talk alert msg exception : {}", e.getMessage());
|
||||
alertResult = new AlertResult();
|
||||
alertResult.setStatus("false");
|
||||
alertResult.setMessage("send ding talk alert fail.");
|
||||
|
|
@ -166,7 +167,7 @@ public final class DingTalkSender {
|
|||
} finally {
|
||||
response.close();
|
||||
}
|
||||
log.info("Ding Talk send title :{},content : {}, resp: {}", title, content, resp);
|
||||
logger.info("Ding Talk send title :{},content : {}, resp: {}", title, content, resp);
|
||||
return resp;
|
||||
} finally {
|
||||
httpClient.close();
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
|||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class EmailAlertChannel implements AlertChannel {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(EmailAlertChannel.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmailAlertChannel.class);
|
||||
|
||||
@Override
|
||||
public AlertResult process(AlertInfo info) {
|
||||
|
|
@ -46,18 +47,18 @@ public final class EmailAlertChannel implements AlertChannel {
|
|||
alertResult = new AlertResult();
|
||||
alertResult.setStatus("false");
|
||||
alertResult.setMessage("alert send error.");
|
||||
log.info("alert send error : {}", alertResult.getMessage());
|
||||
logger.info("alert send error : {}", alertResult.getMessage());
|
||||
return alertResult;
|
||||
}
|
||||
|
||||
flag = Boolean.parseBoolean(String.valueOf(alertResult.getStatus()));
|
||||
|
||||
if (flag) {
|
||||
log.info("alert send success");
|
||||
logger.info("alert send success");
|
||||
alertResult.setMessage("email send success.");
|
||||
} else {
|
||||
alertResult.setMessage("alert send error.");
|
||||
log.info("alert send error : {}", alertResult.getMessage());
|
||||
logger.info("alert send error : {}", alertResult.getMessage());
|
||||
}
|
||||
|
||||
return alertResult;
|
||||
|
|
|
|||
|
|
@ -36,10 +36,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class ExcelUtils {
|
||||
private static final int XLSX_WINDOW_ROW = 10000;
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ExcelUtils.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExcelUtils.class);
|
||||
|
||||
private ExcelUtils() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
|
|
@ -55,14 +56,14 @@ public final class ExcelUtils {
|
|||
public static void genExcelFile(String content, String title, String xlsFilePath) {
|
||||
File file = new File(xlsFilePath);
|
||||
if (!file.exists() && !file.mkdirs()) {
|
||||
log.error("Create xlsx directory error, path:{}", xlsFilePath);
|
||||
logger.error("Create xlsx directory error, path:{}", xlsFilePath);
|
||||
throw new AlertEmailException("Create xlsx directory error");
|
||||
}
|
||||
|
||||
List<LinkedHashMap> itemsList = JSONUtils.toList(content, LinkedHashMap.class);
|
||||
|
||||
if (CollectionUtils.isEmpty(itemsList)) {
|
||||
log.error("itemsList is null");
|
||||
logger.error("itemsList is null");
|
||||
throw new AlertEmailException("itemsList is null");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -54,11 +54,12 @@ import javax.mail.internet.MimeMultipart;
|
|||
import javax.mail.internet.MimeUtility;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.sun.mail.smtp.SMTPProvider;
|
||||
|
||||
public final class MailSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(MailSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(MailSender.class);
|
||||
|
||||
private final List<String> receivers;
|
||||
private final List<String> receiverCcs;
|
||||
|
|
@ -380,12 +381,12 @@ public final class MailSender {
|
|||
public void deleteFile(File file) {
|
||||
if (file.exists()) {
|
||||
if (file.delete()) {
|
||||
log.info("delete success: {}", file.getAbsolutePath());
|
||||
logger.info("delete success: {}", file.getAbsolutePath());
|
||||
} else {
|
||||
log.info("delete fail: {}", file.getAbsolutePath());
|
||||
logger.info("delete fail: {}", file.getAbsolutePath());
|
||||
}
|
||||
} else {
|
||||
log.info("file not exists: {}", file.getAbsolutePath());
|
||||
logger.info("file not exists: {}", file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -393,7 +394,7 @@ public final class MailSender {
|
|||
* handle exception
|
||||
*/
|
||||
private void handleException(AlertResult alertResult, Exception e) {
|
||||
log.error("Send email to {} failed", receivers, e);
|
||||
logger.error("Send email to {} failed", receivers, e);
|
||||
alertResult.setMessage("Send email to {" + String.join(",", receivers) + "} failed," + e.toString());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,11 +36,12 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public final class FeiShuSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(FeiShuSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(FeiShuSender.class);
|
||||
private final String url;
|
||||
private final Boolean enableProxy;
|
||||
|
||||
|
|
@ -81,14 +82,14 @@ public final class FeiShuSender {
|
|||
|
||||
if (org.apache.dolphinscheduler.spi.utils.StringUtils.isBlank(result)) {
|
||||
alertResult.setMessage("send fei shu msg error");
|
||||
log.info("send fei shu msg error,fei shu server resp is null");
|
||||
logger.info("send fei shu msg error,fei shu server resp is null");
|
||||
return alertResult;
|
||||
}
|
||||
FeiShuSendMsgResponse sendMsgResponse = JSONUtils.parseObject(result, FeiShuSendMsgResponse.class);
|
||||
|
||||
if (null == sendMsgResponse) {
|
||||
alertResult.setMessage("send fei shu msg fail");
|
||||
log.info("send fei shu msg error,resp error");
|
||||
logger.info("send fei shu msg error,resp error");
|
||||
return alertResult;
|
||||
}
|
||||
if (sendMsgResponse.statusCode == 0) {
|
||||
|
|
@ -97,7 +98,7 @@ public final class FeiShuSender {
|
|||
return alertResult;
|
||||
}
|
||||
alertResult.setMessage(String.format("alert send fei shu msg error : %s", sendMsgResponse.getStatusMessage()));
|
||||
log.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(), sendMsgResponse.getExtra());
|
||||
logger.info("alert send fei shu msg error : {} ,Extra : {} ", sendMsgResponse.getStatusMessage(), sendMsgResponse.getExtra());
|
||||
return alertResult;
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +131,7 @@ public final class FeiShuSender {
|
|||
String resp = sendMsg(alertData);
|
||||
return checkSendFeiShuSendMsgResult(resp);
|
||||
} catch (Exception e) {
|
||||
log.info("send fei shu alert msg exception : {}", e.getMessage());
|
||||
logger.info("send fei shu alert msg exception : {}", e.getMessage());
|
||||
alertResult = new AlertResult();
|
||||
alertResult.setStatus("false");
|
||||
alertResult.setMessage("send fei shu alert fail.");
|
||||
|
|
@ -153,7 +154,7 @@ public final class FeiShuSender {
|
|||
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
if (statusCode != HttpStatus.SC_OK) {
|
||||
log.error("send feishu message error, return http status code: {} ", statusCode);
|
||||
logger.error("send feishu message error, return http status code: {} ", statusCode);
|
||||
}
|
||||
String resp;
|
||||
try {
|
||||
|
|
@ -163,7 +164,7 @@ public final class FeiShuSender {
|
|||
} finally {
|
||||
response.close();
|
||||
}
|
||||
log.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp);
|
||||
logger.info("Fei Shu send title :{} ,content :{}, resp: {}", alertData.getTitle(), alertData.getContent(), resp);
|
||||
return resp;
|
||||
} finally {
|
||||
httpClient.close();
|
||||
|
|
|
|||
|
|
@ -35,11 +35,12 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
public final class HttpSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(HttpSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(HttpSender.class);
|
||||
private static final String URL_SPLICE_CHAR = "?";
|
||||
/**
|
||||
* request type post
|
||||
|
|
@ -86,7 +87,7 @@ public final class HttpSender {
|
|||
alertResult.setStatus("true");
|
||||
alertResult.setMessage(resp);
|
||||
} catch (Exception e) {
|
||||
log.error("send http alert msg exception : {}", e.getMessage());
|
||||
logger.error("send http alert msg exception : {}", e.getMessage());
|
||||
alertResult.setStatus("false");
|
||||
alertResult.setMessage("send http request alert fail.");
|
||||
}
|
||||
|
|
@ -149,7 +150,7 @@ public final class HttpSender {
|
|||
StringEntity entity = new StringEntity(bodyParams, DEFAULT_CHARSET);
|
||||
((HttpPost) httpRequest).setEntity(entity);
|
||||
} catch (Exception e) {
|
||||
log.error("send http alert msg exception : {}", e.getMessage());
|
||||
logger.error("send http alert msg exception : {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,10 @@ package org.apache.dolphinscheduler.plugin.alert.script;
|
|||
import java.io.IOException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class ProcessUtils {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ProcessUtils.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProcessUtils.class);
|
||||
|
||||
private ProcessUtils() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
|
|
@ -48,7 +49,7 @@ public final class ProcessUtils {
|
|||
errorStreamGobbler.start();
|
||||
return process.waitFor();
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error("execute alert script error {}", e.getMessage());
|
||||
logger.error("execute alert script error {}", e.getMessage());
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,10 @@ import org.apache.dolphinscheduler.alert.api.AlertResult;
|
|||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class ScriptSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ScriptSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ScriptSender.class);
|
||||
private static final String ALERT_TITLE_OPTION = " -t ";
|
||||
private static final String ALERT_CONTENT_OPTION = " -c ";
|
||||
private static final String ALERT_USER_PARAMS_OPTION = " -p ";
|
||||
|
|
@ -62,7 +63,7 @@ public final class ScriptSender {
|
|||
return alertResult;
|
||||
}
|
||||
alertResult.setMessage("send script alert msg error,exitCode is " + exitCode);
|
||||
log.info("send script alert msg error,exitCode is {}", exitCode);
|
||||
logger.info("send script alert msg error,exitCode is {}", exitCode);
|
||||
return alertResult;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,10 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class StreamGobbler extends Thread {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(StreamGobbler.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(StreamGobbler.class);
|
||||
|
||||
private final InputStream inputStream;
|
||||
|
||||
|
|
@ -46,16 +47,16 @@ public final class StreamGobbler extends Thread {
|
|||
output.append(System.getProperty("line.separator"));
|
||||
}
|
||||
if (output.length() > 0) {
|
||||
log.info("out put msg is{}", output);
|
||||
logger.info("out put msg is{}", output);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("I/O error occurs {}", e.getMessage());
|
||||
logger.error("I/O error occurs {}", e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
inputBufferReader.close();
|
||||
inputStreamReader.close();
|
||||
} catch (IOException e) {
|
||||
log.error("I/O error occurs {}", e.getMessage());
|
||||
logger.error("I/O error occurs {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,11 +39,12 @@ import java.util.Objects;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
public final class SlackSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(SlackSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(SlackSender.class);
|
||||
|
||||
private final String webHookUrl;
|
||||
private final String botName;
|
||||
|
|
@ -83,7 +84,7 @@ public final class SlackSender {
|
|||
HttpEntity entity = response.getEntity();
|
||||
return EntityUtils.toString(entity, "UTF-8");
|
||||
} catch (Exception e) {
|
||||
log.error("Send message to slack error.", e);
|
||||
logger.error("Send message to slack error.", e);
|
||||
return "System Exception";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,9 +46,10 @@ import java.util.Map.Entry;
|
|||
import java.util.Set;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public final class WeChatSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(WeChatSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(WeChatSender.class);
|
||||
private static final String MUST_NOT_NULL = " must not null";
|
||||
private static final String ALERT_STATUS = "false";
|
||||
private static final String AGENT_ID_REG_EXP = "{agentId}";
|
||||
|
|
@ -92,7 +93,7 @@ public final class WeChatSender {
|
|||
} finally {
|
||||
response.close();
|
||||
}
|
||||
log.info("Enterprise WeChat send [{}], param:{}, resp:{}",
|
||||
logger.info("Enterprise WeChat send [{}], param:{}, resp:{}",
|
||||
url, data, resp);
|
||||
return resp;
|
||||
}
|
||||
|
|
@ -108,7 +109,7 @@ public final class WeChatSender {
|
|||
private static String markdownTable(String title, String content) {
|
||||
List<LinkedHashMap> mapItemsList = JSONUtils.toList(content, LinkedHashMap.class);
|
||||
if (null == mapItemsList || mapItemsList.isEmpty()) {
|
||||
log.error("itemsList is null");
|
||||
logger.error("itemsList is null");
|
||||
throw new RuntimeException("itemsList is null");
|
||||
}
|
||||
StringBuilder contents = new StringBuilder(200);
|
||||
|
|
@ -141,7 +142,7 @@ public final class WeChatSender {
|
|||
if (StringUtils.isNotEmpty(content)) {
|
||||
List<LinkedHashMap> mapItemsList = JSONUtils.toList(content, LinkedHashMap.class);
|
||||
if (null == mapItemsList || mapItemsList.isEmpty()) {
|
||||
log.error("itemsList is null");
|
||||
logger.error("itemsList is null");
|
||||
throw new RuntimeException("itemsList is null");
|
||||
}
|
||||
|
||||
|
|
@ -206,13 +207,13 @@ public final class WeChatSender {
|
|||
|
||||
if (null == result) {
|
||||
alertResult.setMessage("we chat send fail");
|
||||
log.info("send we chat msg error,resp is null");
|
||||
logger.info("send we chat msg error,resp is null");
|
||||
return alertResult;
|
||||
}
|
||||
WeChatSendMsgResponse sendMsgResponse = JSONUtils.parseObject(result, WeChatSendMsgResponse.class);
|
||||
if (null == sendMsgResponse) {
|
||||
alertResult.setMessage("we chat send fail");
|
||||
log.info("send we chat msg error,resp error");
|
||||
logger.info("send we chat msg error,resp error");
|
||||
return alertResult;
|
||||
}
|
||||
if (sendMsgResponse.errcode == 0) {
|
||||
|
|
@ -261,7 +262,7 @@ public final class WeChatSender {
|
|||
try {
|
||||
return checkWeChatSendMsgResult(post(enterpriseWeChatPushUrlReplace, msg));
|
||||
} catch (Exception e) {
|
||||
log.info("send we chat alert msg exception : {}", e.getMessage());
|
||||
logger.info("send we chat alert msg exception : {}", e.getMessage());
|
||||
alertResult = new AlertResult();
|
||||
alertResult.setMessage("send we chat alert fail");
|
||||
alertResult.setStatus(ALERT_STATUS);
|
||||
|
|
@ -289,7 +290,7 @@ public final class WeChatSender {
|
|||
try {
|
||||
return get(weChatTokenUrlReplace);
|
||||
} catch (IOException e) {
|
||||
log.info("we chat alert get token error{}", e.getMessage());
|
||||
logger.info("we chat alert get token error{}", e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,11 +38,12 @@ import java.util.Set;
|
|||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public final class AlertPluginManager {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(AlertPluginManager.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AlertPluginManager.class);
|
||||
|
||||
private final PluginDao pluginDao;
|
||||
|
||||
|
|
@ -59,7 +60,7 @@ public final class AlertPluginManager {
|
|||
ServiceLoader.load(AlertChannelFactory.class).forEach(factory -> {
|
||||
final String name = factory.name();
|
||||
|
||||
log.info("Registering alert plugin: {}", name);
|
||||
logger.info("Registering alert plugin: {}", name);
|
||||
|
||||
if (!names.add(name)) {
|
||||
throw new IllegalStateException(format("Duplicate alert plugins named '%s'", name));
|
||||
|
|
@ -67,7 +68,7 @@ public final class AlertPluginManager {
|
|||
|
||||
final AlertChannel alertChannel = factory.create();
|
||||
|
||||
log.info("Registered alert plugin: {}", name);
|
||||
logger.info("Registered alert plugin: {}", name);
|
||||
|
||||
final List<PluginParams> params = factory.params();
|
||||
final String paramsJson = PluginParamsTransfer.transferParamsToJson(params);
|
||||
|
|
|
|||
|
|
@ -27,13 +27,14 @@ import org.apache.dolphinscheduler.remote.processor.NettyRequestProcessor;
|
|||
import org.apache.dolphinscheduler.remote.utils.JsonSerializer;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
|
||||
@Component
|
||||
public final class AlertRequestProcessor implements NettyRequestProcessor {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(AlertRequestProcessor.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AlertRequestProcessor.class);
|
||||
|
||||
private final AlertSender alertSender;
|
||||
|
||||
|
|
@ -48,7 +49,7 @@ public final class AlertRequestProcessor implements NettyRequestProcessor {
|
|||
AlertSendRequestCommand alertSendRequestCommand = JsonSerializer.deserialize(
|
||||
command.getBody(), AlertSendRequestCommand.class);
|
||||
|
||||
log.info("Received command : {}", alertSendRequestCommand);
|
||||
logger.info("Received command : {}", alertSendRequestCommand);
|
||||
|
||||
AlertSendResponseCommand alertSendResponseCommand = alertSender.syncHandler(
|
||||
alertSendRequestCommand.getGroupId(),
|
||||
|
|
|
|||
|
|
@ -37,11 +37,12 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public final class AlertSender {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(AlertSender.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AlertSender.class);
|
||||
|
||||
private final AlertDao alertDao;
|
||||
private final AlertPluginManager alertPluginManager;
|
||||
|
|
@ -57,7 +58,7 @@ public final class AlertSender {
|
|||
int alertGroupId = alert.getAlertGroupId();
|
||||
List<AlertPluginInstance> alertInstanceList = alertDao.listInstanceByAlertGroupId(alertGroupId);
|
||||
if (CollectionUtils.isEmpty(alertInstanceList)) {
|
||||
log.error("send alert msg fail,no bind plugin instance.");
|
||||
logger.error("send alert msg fail,no bind plugin instance.");
|
||||
alertDao.updateAlert(AlertStatus.EXECUTION_FAILURE, "no bind plugin instance", alert.getId());
|
||||
continue;
|
||||
}
|
||||
|
|
@ -100,7 +101,7 @@ public final class AlertSender {
|
|||
alertSendResponseResult.setStatus(false);
|
||||
alertSendResponseResult.setMessage(message);
|
||||
sendResponseResults.add(alertSendResponseResult);
|
||||
log.error("Alert GroupId {} send error : not found alert instance", alertGroupId);
|
||||
logger.error("Alert GroupId {} send error : not found alert instance", alertGroupId);
|
||||
return new AlertSendResponseCommand(false, sendResponseResults);
|
||||
}
|
||||
|
||||
|
|
@ -130,7 +131,7 @@ public final class AlertSender {
|
|||
String message = String.format("Alert Plugin %s send error : return value is null", pluginInstanceName);
|
||||
alertResultExtend.setStatus(String.valueOf(false));
|
||||
alertResultExtend.setMessage(message);
|
||||
log.error("Alert Plugin {} send error : not found plugin {}", pluginInstanceName, instance.getPluginDefineId());
|
||||
logger.error("Alert Plugin {} send error : not found plugin {}", pluginInstanceName, instance.getPluginDefineId());
|
||||
return alertResultExtend;
|
||||
}
|
||||
|
||||
|
|
@ -143,23 +144,23 @@ public final class AlertSender {
|
|||
alertResult = alertChannel.get().process(alertInfo);
|
||||
} catch (Exception e) {
|
||||
alertResult = new AlertResult("false", e.getMessage());
|
||||
log.error("send alert error alert data id :{},", alertData.getId(), e);
|
||||
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);
|
||||
alertResultExtend.setStatus(String.valueOf(false));
|
||||
alertResultExtend.setMessage(message);
|
||||
log.info("Alert Plugin {} send error : return alertResult value is null", pluginInstanceName);
|
||||
logger.info("Alert Plugin {} send error : return alertResult value is null", pluginInstanceName);
|
||||
} else if (!Boolean.parseBoolean(String.valueOf(alertResult.getStatus()))) {
|
||||
alertResultExtend.setStatus(String.valueOf(false));
|
||||
alertResultExtend.setMessage(alertResult.getMessage());
|
||||
log.info("Alert Plugin {} send error : {}", pluginInstanceName, alertResult.getMessage());
|
||||
logger.info("Alert Plugin {} send error : {}", pluginInstanceName, alertResult.getMessage());
|
||||
} else {
|
||||
String message = String.format("Alert Plugin %s send success", pluginInstanceName);
|
||||
alertResultExtend.setStatus(String.valueOf(true));
|
||||
alertResultExtend.setMessage(message);
|
||||
log.info("Alert Plugin {} send success", pluginInstanceName);
|
||||
logger.info("Alert Plugin {} send success", pluginInstanceName);
|
||||
}
|
||||
return alertResultExtend;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ import org.springframework.context.annotation.ComponentScan;
|
|||
"org.apache.dolphinscheduler.dao"
|
||||
})
|
||||
public class AlertServer implements Closeable {
|
||||
private static final Logger log = LoggerFactory.getLogger(AlertServer.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(AlertServer.class);
|
||||
|
||||
private final PluginDao pluginDao;
|
||||
private final AlertDao alertDao;
|
||||
|
|
@ -72,13 +72,13 @@ public class AlertServer implements Closeable {
|
|||
|
||||
@PostConstruct
|
||||
public void start() {
|
||||
log.info("Starting Alert server");
|
||||
logger.info("Starting Alert server");
|
||||
|
||||
checkTable();
|
||||
startServer();
|
||||
|
||||
if (alertPluginManager.size() == 0) {
|
||||
log.warn("No alert plugin, alert sender will exit.");
|
||||
logger.warn("No alert plugin, alert sender will exit.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ public class AlertServer implements Closeable {
|
|||
|
||||
private void checkTable() {
|
||||
if (!pluginDao.checkPluginDefineTableExist()) {
|
||||
log.error("Plugin Define Table t_ds_plugin_define Not Exist . Please Create it First !");
|
||||
logger.error("Plugin Define Table t_ds_plugin_define Not Exist . Please Create it First !");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -119,7 +119,7 @@ public class AlertServer implements Closeable {
|
|||
final List<Alert> alerts = alertDao.listPendingAlerts();
|
||||
alertSender.send(alerts);
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to send alert", e);
|
||||
logger.error("Failed to send alert", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
public final class ZookeeperConnectionStateListener implements ConnectionStateListener {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ZookeeperConnectionStateListener.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(ZookeeperConnectionStateListener.class);
|
||||
|
||||
private final ConnectionListener listener;
|
||||
|
||||
|
|
@ -41,15 +41,15 @@ public final class ZookeeperConnectionStateListener implements ConnectionStateLi
|
|||
org.apache.curator.framework.state.ConnectionState newState) {
|
||||
switch (newState) {
|
||||
case LOST:
|
||||
log.warn("Registry disconnected");
|
||||
logger.warn("Registry disconnected");
|
||||
listener.onUpdate(ConnectionState.DISCONNECTED);
|
||||
break;
|
||||
case RECONNECTED:
|
||||
log.info("Registry reconnected");
|
||||
logger.info("Registry reconnected");
|
||||
listener.onUpdate(ConnectionState.RECONNECTED);
|
||||
break;
|
||||
case SUSPENDED:
|
||||
log.warn("Registry suspended");
|
||||
logger.warn("Registry suspended");
|
||||
listener.onUpdate(ConnectionState.SUSPENDED);
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue