felix-thinkingdata commented on a change in pull request #4645:
URL: 
https://github.com/apache/incubator-dolphinscheduler/pull/4645#discussion_r569992164



##########
File path: 
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
##########
@@ -129,9 +134,19 @@ private void runSender() {
             if (alertPluginManager == null || 
alertPluginManager.getAlertChannelMap().size() == 0) {
                 logger.warn("No Alert Plugin . Can not send alert info. ");
             } else {
-                List<Alert> alerts = alertDao.listWaitExecutionAlert();
-                alertSender = new AlertSender(alerts, alertDao, 
alertPluginManager);
-                alertSender.run();
+                InterProcessMutex mutex = null;
+                try {
+                    mutex = zookeeperClient.getAlertLockPath();
+                    mutex.acquire();

Review comment:
        adding ZK exceptions  processing logic
   
   ---
   增加了zk一样的处理逻辑

##########
File path: 
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
##########
@@ -129,9 +134,19 @@ private void runSender() {
             if (alertPluginManager == null || 
alertPluginManager.getAlertChannelMap().size() == 0) {
                 logger.warn("No Alert Plugin . Can not send alert info. ");
             } else {
-                List<Alert> alerts = alertDao.listWaitExecutionAlert();
-                alertSender = new AlertSender(alerts, alertDao, 
alertPluginManager);
-                alertSender.run();
+                InterProcessMutex mutex = null;
+                try {
+                    mutex = zookeeperClient.getAlertLockPath();
+                    mutex.acquire();

Review comment:
        adding ZK exceptions  processing logic
   
   ---
   增加了zk异常的处理逻辑

##########
File path: 
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
##########
@@ -129,9 +134,20 @@ private void runSender() {
             if (alertPluginManager == null || 
alertPluginManager.getAlertChannelMap().size() == 0) {
                 logger.warn("No Alert Plugin . Can not send alert info. ");
             } else {
-                List<Alert> alerts = alertDao.listWaitExecutionAlert();
-                alertSender = new AlertSender(alerts, alertDao, 
alertPluginManager);
-                alertSender.run();
+                InterProcessMutex mutex = null;
+                try {
+                    logger.error("创建分布式锁 : ");
+                    mutex = zookeeperClient.getAlertLockPath();
+                    mutex.acquire();
+                    List<Alert> alerts = alertDao.listWaitExecutionAlert();
+                    alertSender = new AlertSender(alerts, alertDao, 
alertPluginManager);
+                    alertSender.run();
+                } catch (Exception e) {
+                    logger.error("alert server with error : ", e);
+                } finally {
+                    zookeeperClient.release(mutex);
+
+                }

Review comment:
       
![image](https://user-images.githubusercontent.com/59079269/106859520-22698880-66fe-11eb-8d03-c365ba644602.png)
   通过尝试,选择一个alert告警,失败尝试另一个的方式。兼容sql task同步告警方式。

##########
File path: 
dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/AlertServer.java
##########
@@ -129,9 +134,20 @@ private void runSender() {
             if (alertPluginManager == null || 
alertPluginManager.getAlertChannelMap().size() == 0) {
                 logger.warn("No Alert Plugin . Can not send alert info. ");
             } else {
-                List<Alert> alerts = alertDao.listWaitExecutionAlert();
-                alertSender = new AlertSender(alerts, alertDao, 
alertPluginManager);
-                alertSender.run();
+                InterProcessMutex mutex = null;
+                try {
+                    logger.error("创建分布式锁 : ");
+                    mutex = zookeeperClient.getAlertLockPath();
+                    mutex.acquire();
+                    List<Alert> alerts = alertDao.listWaitExecutionAlert();
+                    alertSender = new AlertSender(alerts, alertDao, 
alertPluginManager);
+                    alertSender.run();
+                } catch (Exception e) {
+                    logger.error("alert server with error : ", e);
+                } finally {
+                    zookeeperClient.release(mutex);
+
+                }

Review comment:
       The code has been implemented




----------------------------------------------------------------
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]


Reply via email to