This is an automated email from the ASF dual-hosted git repository.

xingtanzjr pushed a commit to branch ml_add_peer
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/ml_add_peer by this push:
     new f27c3be348 change inactive log from exception to warnning log
f27c3be348 is described below

commit f27c3be348a695d34dd67d7ae0798f9b6c8b30b6
Author: Jinrui.Zhang <[email protected]>
AuthorDate: Tue Sep 6 15:16:21 2022 +0800

    change inactive log from exception to warnning log
---
 .../consensus/multileader/client/DispatchLogHandler.java    | 10 +++++++---
 .../multileader/service/MultiLeaderRPCServiceProcessor.java | 13 ++++++-------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git 
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/client/DispatchLogHandler.java
 
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/client/DispatchLogHandler.java
index b4cefed078..958ccd1fa0 100644
--- 
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/client/DispatchLogHandler.java
+++ 
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/client/DispatchLogHandler.java
@@ -45,9 +45,7 @@ public class DispatchLogHandler implements 
AsyncMethodCallback<TSyncLogRes> {
 
   @Override
   public void onComplete(TSyncLogRes response) {
-    if (response.getStatus().size() == 1
-        && response.getStatus().get(0).getCode()
-            == TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()) {
+    if (response.getStatus().size() == 1 && 
needRetry(response.getStatus().get(0).getCode())) {
       logger.warn(
           "Can not send {} to peer {} for {} times because {}",
           batch,
@@ -62,6 +60,12 @@ public class DispatchLogHandler implements 
AsyncMethodCallback<TSyncLogRes> {
     }
   }
 
+  private boolean needRetry(int statusCode) {
+    return statusCode == TSStatusCode.INTERNAL_SERVER_ERROR.getStatusCode()
+        || statusCode == TSStatusCode.READ_ONLY_SYSTEM_ERROR.getStatusCode()
+        || statusCode == TSStatusCode.WRITE_PROCESS_REJECT.getStatusCode();
+  }
+
   @Override
   public void onError(Exception exception) {
     logger.warn(
diff --git 
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/service/MultiLeaderRPCServiceProcessor.java
 
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/service/MultiLeaderRPCServiceProcessor.java
index 7655eb8a4e..a3030bf80a 100644
--- 
a/consensus/src/main/java/org/apache/iotdb/consensus/multileader/service/MultiLeaderRPCServiceProcessor.java
+++ 
b/consensus/src/main/java/org/apache/iotdb/consensus/multileader/service/MultiLeaderRPCServiceProcessor.java
@@ -21,7 +21,6 @@ package org.apache.iotdb.consensus.multileader.service;
 
 import org.apache.iotdb.common.rpc.thrift.TSStatus;
 import org.apache.iotdb.commons.consensus.ConsensusGroupId;
-import org.apache.iotdb.commons.exception.IoTDBException;
 import org.apache.iotdb.consensus.common.Peer;
 import org.apache.iotdb.consensus.common.request.BatchIndexedConsensusRequest;
 import org.apache.iotdb.consensus.common.request.ByteBufferConsensusRequest;
@@ -87,15 +86,15 @@ public class MultiLeaderRPCServiceProcessor implements 
MultiLeaderConsensusIServ
       if (impl.isReadOnly()) {
         String message = "fail to sync log because system is read-only.";
         logger.error(message);
-        resultHandler.onError(
-            new IoTDBException(message, 
TSStatusCode.READ_ONLY_SYSTEM_ERROR.getStatusCode()));
+        TSStatus status = new 
TSStatus(TSStatusCode.READ_ONLY_SYSTEM_ERROR.getStatusCode());
+        status.setMessage(message);
+        resultHandler.onComplete(new 
TSyncLogRes(Collections.singletonList(status)));
         return;
       }
       if (!impl.isActive()) {
-        resultHandler.onError(
-            new IoTDBException(
-                "peer is inactive and not ready to receive sync log request",
-                TSStatusCode.WRITE_PROCESS_REJECT.getStatusCode()));
+        TSStatus status = new 
TSStatus(TSStatusCode.WRITE_PROCESS_REJECT.getStatusCode());
+        status.setMessage("peer is inactive and not ready to receive sync log 
request");
+        resultHandler.onComplete(new 
TSyncLogRes(Collections.singletonList(status)));
         return;
       }
       BatchIndexedConsensusRequest requestsInThisBatch = new 
BatchIndexedConsensusRequest();

Reply via email to