adoroszlai commented on code in PR #1440:
URL: https://github.com/apache/ratis/pull/1440#discussion_r3154055472


##########
ratis-server/src/main/java/org/apache/ratis/server/raftlog/LogProtoUtils.java:
##########
@@ -87,9 +87,23 @@ public static String toLogEntriesString(List<LogEntryProto> 
entries) {
 
   public static String toLogEntriesShortString(List<LogEntryProto> entries,
       Function<StateMachineLogEntryProto, String> stateMachineToString) {
-    return entries == null ? null
-        : entries.isEmpty()? "<empty>"
-        : "size=" + entries.size() + ", first=" + 
toLogEntryString(entries.get(0), stateMachineToString);
+    if (entries == null) {
+      return null;
+    }
+    return toLogEntryTermIndexString(entries)
+        + (entries.isEmpty() ? "" : ", first=" + 
toLogEntryString(entries.get(0), stateMachineToString));
+  }
+
+  public static String toLogEntryTermIndexString(List<LogEntryProto> entries) {
+    final int n = entries.size();
+    return n == 0 ? toLogEntryTermIndexString(n, null, null)
+        : toLogEntryTermIndexString(n, TermIndex.valueOf(entries.get(0)), 
TermIndex.valueOf(entries.get(n - 1)));
+  }
+
+  public static String toLogEntryTermIndexString(int n, TermIndex first, 
TermIndex last) {
+    return n == 0 ? "HEARTBEAT"
+        : n == 1 ? "entry" + first
+        : n + " entries:" + first + "..." + last;

Review Comment:
   Missing `:`?
   
   ```suggestion
           : n == 1 ? "entry:" + first
           : n + " entries:" + first + "..." + last;
   ```
   
   Also, would `=` instead of `:` be better?  Since 
`AppendEntriesRequest#toString` uses `:` as separator.
   
   
https://github.com/apache/ratis/blob/3e927ccbf2c44cc62e77ee3e8e4bee74328ee83a/ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java#L894-L896



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java:
##########
@@ -1703,6 +1696,11 @@ leaderId, getMemberId(), currentTerm, followerCommit, 
inconsistencyReplyNextInde
     final long commitIndex = effectiveCommitIndex(proto.getLeaderCommit(), 
previous, entries.size());
     final long matchIndex = isHeartbeat? RaftLog.INVALID_LOG_INDEX: 
entries.get(entries.size() - 1).getIndex();
     return appendFuture.whenCompleteAsync((r, t) -> {
+      if  (t != null) {
+        LOG.warn("{}: appendEntries* failed: {}", getMemberId(), 
toLogEntryTermIndexString(entries), t);
+      } else if (LOG.isDebugEnabled()) {
+        LOG.debug("{}: appendEntries* succeeded {}", getMemberId(), 
toLogEntryTermIndexString(entries));

Review Comment:
   nit: `failed: {}` has `:` but `succeeded {}` does not.



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