You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by GitBox <gi...@apache.org> on 2022/12/24 06:29:43 UTC

[GitHub] [ratis] codings-dan commented on a diff in pull request #799: RATIS-1761. If LeaderStateImpl is not running, it should not restart a LogAppender.

codings-dan commented on code in PR #799:
URL: https://github.com/apache/ratis/pull/799#discussion_r1056749328


##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -393,7 +394,9 @@ boolean isReady() {
   }
 
   void stop() {
-    this.running = false;
+    if (!isStopped.compareAndSet(false, true)) {
+      return;

Review Comment:
   add log `LOG.warn("Failed to stop: can't set isStopped state");`



##########
ratis-server/src/main/java/org/apache/ratis/server/leader/LogAppenderBase.java:
##########
@@ -125,6 +125,13 @@ public void stop() {
     daemon.tryToClose();
   }
 
+  void restart() {
+    if (!server.getInfo().isAlive()) {
+      return;

Review Comment:
   add log: `LOG.warn("Failed to restart: server is not alive");`



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/LeaderStateImpl.java:
##########
@@ -595,8 +599,20 @@ void stopAndRemoveSenders(Predicate<LogAppender> predicate) {
     senders.removeAll(toStop);
   }
 
+  boolean isRunning() {
+    if (isStopped.get()) {
+      return false;
+    }
+    final LeaderStateImpl current = server.getRole().getLeaderState().orElse(null);
+    return this == current;
+  }
+
   @Override
   public void restart(LogAppender sender) {
+    if (!isRunning()) {
+      return;

Review Comment:
   add log : `LOG.warn("Failed to restart: server is not running");`



-- 
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: issues-unsubscribe@ratis.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org