Radeity commented on code in PR #15932:
URL: 
https://github.com/apache/dolphinscheduler/pull/15932#discussion_r1590279747


##########
dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/ha/AbstractServerStatusChangeListener.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.registry.api.ha;
+
+public abstract class AbstractServerStatusChangeListener implements 
ServerStatusChangeListener {
+
+    @Override
+    public void change(HAServer.ServerStatus originStatus, 
HAServer.ServerStatus currentStatus) {
+        if (originStatus == HAServer.ServerStatus.ACTIVE) {
+            if (currentStatus == HAServer.ServerStatus.STAND_BY) {
+                changeToStandBy();
+            } else {
+                throw new IllegalStateException("The status change from ACTIVE 
to ACTIVE is not allowed.");
+            }
+        } else if (originStatus == HAServer.ServerStatus.STAND_BY) {
+            if (currentStatus == HAServer.ServerStatus.ACTIVE) {
+                changeToActive();
+            } else {
+                throw new IllegalStateException("The status change from 
STAND_BY to STAND_BY is not allowed.");

Review Comment:
   If one alert server's original status is `Standby`, and it doesn't acquire 
lock successfully in new election, I don't think we should throw exception here.



##########
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java:
##########
@@ -271,10 +270,11 @@ public void sendTaskTimeoutAlert(ProcessInstance 
processInstance, TaskInstance t
     }
 
     /**
-     * List alerts that are pending for execution
+     * List pending alerts which id > minAlertId and status = {@link 
AlertStatus#WAIT_EXECUTION} order by id asc.
      */
-    public List<Alert> listPendingAlerts() {
-        return 
alertMapper.listingAlertByStatus(AlertStatus.WAIT_EXECUTION.getCode(), 
QUERY_ALERT_THRESHOLD);
+    public List<Alert> listPendingAlerts(int mixAlertId) {
+        return alertMapper.listingAlertByStatus(mixAlertId, 
AlertStatus.WAIT_EXECUTION.getCode(),
+                QUERY_ALERT_THRESHOLD);

Review Comment:
   Two typo errors here (`mixAlertId`).



##########
dolphinscheduler-alert/dolphinscheduler-alert-server/src/main/java/org/apache/dolphinscheduler/alert/service/AlertEventPendingQueue.java:
##########
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.alert.service;
+
+import org.apache.dolphinscheduler.alert.config.AlertConfig;
+import org.apache.dolphinscheduler.alert.metrics.AlertServerMetrics;
+import org.apache.dolphinscheduler.dao.entity.Alert;
+
+import org.springframework.stereotype.Component;
+
+@Component
+public class AlertEventPendingQueue extends AbstractEventPendingQueue<Alert> {
+
+    public AlertEventPendingQueue(AlertConfig alertConfig) {
+        super(alertConfig.getSenderParallelism() * 3 + 1);

Review Comment:
   May I ask why we set `n * 3 + 1` here?



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to