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/08/06 08:04:07 UTC

[GitHub] [ratis] szetszwo opened a new pull request, #706: RATIS-1663. Record call id for board casting a heartbeat.

szetszwo opened a new pull request, #706:
URL: https://github.com/apache/ratis/pull/706

   See https://issues.apache.org/jira/browse/RATIS-1663


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


[GitHub] [ratis] szetszwo commented on a diff in pull request #706: RATIS-1663. Record call id for board casting a heartbeat.

Posted by GitBox <gi...@apache.org>.
szetszwo commented on code in PR #706:
URL: https://github.com/apache/ratis/pull/706#discussion_r941585168


##########
ratis-common/src/main/java/org/apache/ratis/rpc/CallId.java:
##########
@@ -27,6 +28,17 @@
 public final class CallId {
   private static final AtomicLong CALL_ID_COUNTER = new AtomicLong();
 
+  private static final Comparator<Long> COMPARATOR = (left, right) -> {
+    final long diff = left - right;
+    // check diff < Long.MAX_VALUE/2 for the possibility of numerical overflow.
+    return diff == 0? 0: diff > 0 && diff < Long.MAX_VALUE/2? 1: -1;

Review Comment:
   It generates call IDs in a different way -- this only allows >=0 values but GrpcLogAppender allows +/- values.



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


[GitHub] [ratis] codings-dan commented on a diff in pull request #706: RATIS-1663. Record call id for board casting a heartbeat.

Posted by GitBox <gi...@apache.org>.
codings-dan commented on code in PR #706:
URL: https://github.com/apache/ratis/pull/706#discussion_r941369473


##########
ratis-common/src/main/java/org/apache/ratis/rpc/CallId.java:
##########
@@ -27,6 +28,17 @@
 public final class CallId {
   private static final AtomicLong CALL_ID_COUNTER = new AtomicLong();
 
+  private static final Comparator<Long> COMPARATOR = (left, right) -> {
+    final long diff = left - right;
+    // check diff < Long.MAX_VALUE/2 for the possibility of numerical overflow.
+    return diff == 0? 0: diff > 0 && diff < Long.MAX_VALUE/2? 1: -1;

Review Comment:
   Why this `COMPARATOR` is different from `GrpcLogAppender#CALL_ID_COMPARATOR`?



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


[GitHub] [ratis] szetszwo merged pull request #706: RATIS-1663. Record call id for board casting a heartbeat.

Posted by GitBox <gi...@apache.org>.
szetszwo merged PR #706:
URL: https://github.com/apache/ratis/pull/706


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


[GitHub] [ratis] codings-dan commented on a diff in pull request #706: RATIS-1663. Record call id for board casting a heartbeat.

Posted by GitBox <gi...@apache.org>.
codings-dan commented on code in PR #706:
URL: https://github.com/apache/ratis/pull/706#discussion_r942079537


##########
ratis-common/src/main/java/org/apache/ratis/rpc/CallId.java:
##########
@@ -27,6 +28,17 @@
 public final class CallId {
   private static final AtomicLong CALL_ID_COUNTER = new AtomicLong();
 
+  private static final Comparator<Long> COMPARATOR = (left, right) -> {
+    final long diff = left - right;
+    // check diff < Long.MAX_VALUE/2 for the possibility of numerical overflow.
+    return diff == 0? 0: diff > 0 && diff < Long.MAX_VALUE/2? 1: -1;

Review Comment:
   Got it, thanks!



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


[GitHub] [ratis] szetszwo commented on pull request #706: RATIS-1663. Record call id for board casting a heartbeat.

Posted by GitBox <gi...@apache.org>.
szetszwo commented on PR #706:
URL: https://github.com/apache/ratis/pull/706#issuecomment-1210355749

   @codings-dan , thanks a lot for reviewing this!


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


[GitHub] [ratis] szetszwo commented on a diff in pull request #706: RATIS-1663. Record call id for board casting a heartbeat.

Posted by GitBox <gi...@apache.org>.
szetszwo commented on code in PR #706:
URL: https://github.com/apache/ratis/pull/706#discussion_r941585818


##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java:
##########
@@ -56,9 +57,16 @@
 public class GrpcLogAppender extends LogAppenderBase {
   public static final Logger LOG = LoggerFactory.getLogger(GrpcLogAppender.class);
 
+  private static final Comparator<Long> CALL_ID_COMPARATOR = (left, right) -> {
+    // calculate diff in order to take care the possibility of numerical overflow,

Review Comment:
   Let me simply remove it.  Thanks.



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


[GitHub] [ratis] codings-dan commented on a diff in pull request #706: RATIS-1663. Record call id for board casting a heartbeat.

Posted by GitBox <gi...@apache.org>.
codings-dan commented on code in PR #706:
URL: https://github.com/apache/ratis/pull/706#discussion_r941369473


##########
ratis-common/src/main/java/org/apache/ratis/rpc/CallId.java:
##########
@@ -27,6 +28,17 @@
 public final class CallId {
   private static final AtomicLong CALL_ID_COUNTER = new AtomicLong();
 
+  private static final Comparator<Long> COMPARATOR = (left, right) -> {
+    final long diff = left - right;
+    // check diff < Long.MAX_VALUE/2 for the possibility of numerical overflow.
+    return diff == 0? 0: diff > 0 && diff < Long.MAX_VALUE/2? 1: -1;

Review Comment:
   Why this `COMPARATOR` is different from GrpcLogAppender#CALL_ID_COMPARATOR?



##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/server/GrpcLogAppender.java:
##########
@@ -56,9 +57,16 @@
 public class GrpcLogAppender extends LogAppenderBase {
   public static final Logger LOG = LoggerFactory.getLogger(GrpcLogAppender.class);
 
+  private static final Comparator<Long> CALL_ID_COMPARATOR = (left, right) -> {
+    // calculate diff in order to take care the possibility of numerical overflow,

Review Comment:
   typo , -> .



##########
ratis-server/src/main/java/org/apache/ratis/server/impl/ReadRequests.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.ratis.server.impl;
+
+import org.apache.ratis.proto.RaftProtos.AppendEntriesReplyProto;
+import org.apache.ratis.server.leader.LogAppender;
+
+/** For supporting linearizable read. */
+class ReadRequests {
+  static class HeartbeatAck {
+    private final LogAppender appender;
+    private final long minCallId;
+    private volatile boolean acknowledged = false;
+
+    HeartbeatAck(LogAppender appender) {
+      this.appender = appender;
+      this.minCallId = appender.getCallId();
+    }
+
+    boolean isAcknowledged() {

Review Comment:
   Could you add a comment for this method?



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