felix-thinkingdata commented on a change in pull request #4645:
URL:
https://github.com/apache/incubator-dolphinscheduler/pull/4645#discussion_r571803299
##########
File path:
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/AlertClientService.java
##########
@@ -78,40 +72,46 @@ public void close() {
/**
* alert sync send data
- * @param groupId
- * @param title
- * @param content
- * @return
*/
- public AlertSendResponseCommand sendAlert(int groupId, String title,
String content) {
- return this.sendAlert(this.host,this.port,groupId,title,content);
+ public AlertSendResponseCommand sendAlert(int groupId, String title,
String content) {
+ return this.sendAlert(this.host, this.port, groupId, title, content);
}
/**
* alert sync send data
+ *
* @param host host
* @param port port
* @param groupId groupId
* @param title title
* @param content content
* @return AlertSendResponseCommand
*/
- public AlertSendResponseCommand sendAlert(String host, int port, int
groupId, String title, String content) {
+ public AlertSendResponseCommand sendAlert(String host, int port, int
groupId, String title, String content) {
logger.info("sync alert send, host : {}, port : {}, groupId : {},
title : {} ", host, port, groupId, title);
AlertSendRequestCommand request = new AlertSendRequestCommand(groupId,
title, content);
- final Host address = new Host(host, port);
- try {
- Command command = request.convert2Command();
- Command response = this.client.sendSync(address, command,
ALERT_REQUEST_TIMEOUT);
- if (response != null) {
- return JsonSerializer.deserialize(response.getBody(),
AlertSendResponseCommand.class);
+ AlertSendResponseCommand alertSendResponseCommand = null;
+ String[] hosts = host.split(",");
+ for (String hostName : hosts) {
+ final Host address = new Host(hostName, port);
+ try {
+ Command command = request.convert2Command();
+ Command response = this.client.sendSync(address, command,
ALERT_REQUEST_TIMEOUT);
+ if (response != null) {
+ alertSendResponseCommand =
JsonSerializer.deserialize(response.getBody(), AlertSendResponseCommand.class);
+ if (alertSendResponseCommand.getResStatus()) {
+ return alertSendResponseCommand;
+ }
Review comment:
如果都失败,会返回最后一个失败告警的。
---
If both fail, the last failure alert will be returned.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]