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


##########
dolphinscheduler-registry/dolphinscheduler-registry-api/src/main/java/org/apache/dolphinscheduler/registry/api/ha/AbstractHAServer.java:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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;
+
+import org.apache.dolphinscheduler.common.thread.ThreadUtils;
+import org.apache.dolphinscheduler.registry.api.Event;
+import org.apache.dolphinscheduler.registry.api.Registry;
+
+import java.util.List;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import lombok.extern.slf4j.Slf4j;
+
+import com.google.common.collect.Lists;
+
+@Slf4j
+public abstract class AbstractHAServer implements HAServer {
+
+    private final Registry registry;
+
+    private final String serverPath;
+
+    private ServerStatus serverStatus;
+
+    private final List<ServerStatusChangeListener> serverStatusChangeListeners;
+
+    public AbstractHAServer(Registry registry, String serverPath) {
+        this.registry = registry;
+        this.serverPath = serverPath;
+        this.serverStatus = ServerStatus.STAND_BY;
+        this.serverStatusChangeListeners = Lists.newArrayList(new 
DefaultServerStatusChangeListener());
+    }
+
+    @Override
+    public void start() {
+        registry.subscribe(serverPath, event -> {
+            if (Event.Type.REMOVE.equals(event.type())) {
+                if (isActive() && !participateElection()) {
+                    statusChange(ServerStatus.STAND_BY);
+                    log.info("The current server has been removed from the 
registry, change the status to STAND_BY.");

Review Comment:
   Removed, the log will be printed at listener.



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