From 66c50d796a5dfc87e4d089818904f386e504ba80 Mon Sep 17 00:00:00 2001 From: Alex Petrov Date: Mon, 26 Aug 2024 12:54:54 +0200 Subject: [PATCH] Revert acccord module to absolute path --- .gitmodules | 2 +- src/java/org/apache/cassandra/tcm/Retry.java | 30 ++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 60a9510e7a..616dacf610 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "modules/accord"] path = modules/accord - url = ../cassandra-accord.git + url = https://github.com/apache/cassandra-accord.git branch = trunk diff --git a/src/java/org/apache/cassandra/tcm/Retry.java b/src/java/org/apache/cassandra/tcm/Retry.java index 3277531444..bf2e0fbf2b 100644 --- a/src/java/org/apache/cassandra/tcm/Retry.java +++ b/src/java/org/apache/cassandra/tcm/Retry.java @@ -27,6 +27,7 @@ import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.utils.Clock; import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; +import static org.apache.cassandra.tcm.Retry.Jitter.MAX_JITTER_MS; public abstract class Retry { @@ -160,6 +161,35 @@ public abstract class Retry return new Deadline(Clock.Global.nanoTime() + timeoutNanos, delegate); } + /** + * Since we are using message expiration for communicating timeouts to CMS nodes, we have to be careful not + * to overflow the long, since messaging is using only 32 bits for deadlines. To achieve that, we are + * giving `timeoutNanos` every time we retry, but will retry indefinitely. + */ + public static Deadline retryIndefinitely(long timeoutNanos, Meter retryMeter) + { + return new Deadline(Clock.Global.nanoTime() + timeoutNanos, + new Retry.Jitter(Integer.MAX_VALUE, MAX_JITTER_MS, new Random(), retryMeter)) + { + @Override + public boolean reachedMax() + { + return false; + } + + @Override + public long remainingNanos() + { + return timeoutNanos; + } + + public String toString() + { + return String.format("RetryIndefinitely{tries=%d}", currentTries()); + } + }; + } + @Override public boolean reachedMax() {