This is an automated email from the ASF dual-hosted git repository. szetszwo pushed a commit to branch branch-3.1.1_review in repository https://gitbox.apache.org/repos/asf/ratis.git
commit d621c14efccf4ccd851b99a659e15251df8796e3 Author: Tsz-Wo Nicholas Sze <[email protected]> AuthorDate: Mon Aug 26 11:11:03 2024 -0700 Revert "RATIS-2099. Cache TermIndexImpl instead of using anonymous class (#1100)" This reverts commit 428ce4ae3d5a0349f3425cb85ef1a3d38dea24b1. --- .../org/apache/ratis/server/protocol/TermIndex.java | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java b/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java index 6a9bd1cfb..7def686bb 100644 --- a/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java +++ b/ratis-server-api/src/main/java/org/apache/ratis/server/protocol/TermIndex.java @@ -19,21 +19,13 @@ package org.apache.ratis.server.protocol; import org.apache.ratis.proto.RaftProtos.LogEntryProto; import org.apache.ratis.proto.RaftProtos.TermIndexProto; -import org.apache.ratis.thirdparty.com.google.common.cache.Cache; -import org.apache.ratis.thirdparty.com.google.common.cache.CacheBuilder; import java.util.Comparator; import java.util.Optional; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; /** The term and the log index defined in the Raft consensus algorithm. */ public interface TermIndex extends Comparable<TermIndex> { - /** An LRU Cache for {@link TermIndex} instances */ - Cache<TermIndex, TermIndex> PRIVATE_CACHE = CacheBuilder.newBuilder() - .maximumSize(1 << 16) - .expireAfterAccess(1, TimeUnit.MINUTES) - .build(); + TermIndex[] EMPTY_ARRAY = {}; /** @return the term. */ long getTerm(); @@ -68,7 +60,7 @@ public interface TermIndex extends Comparable<TermIndex> { /** @return a {@link TermIndex} object. */ static TermIndex valueOf(long term, long index) { - final TermIndex key = new TermIndex() { + return new TermIndex() { @Override public long getTerm() { return term; @@ -106,10 +98,5 @@ public interface TermIndex extends Comparable<TermIndex> { return String.format("(t:%s, i:%s)", longToString(term), longToString(index)); } }; - try { - return PRIVATE_CACHE.get(key, () -> key); - } catch (ExecutionException e) { - throw new IllegalStateException("Failed to valueOf(" + term + ", " + index + "), key=" + key, e); - } } } \ No newline at end of file
