This is an automated email from the ASF dual-hosted git repository. domgarguilo pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/main by this push: new 23e17129de Revert #4358 - Replace long + TimeUnit with Duration in ReadOnlyTStore.unreserve() 23e17129de is described below commit 23e17129de0350d5496345c78d7fd86080bb1115 Author: Dom G <domgargu...@apache.org> AuthorDate: Wed Mar 13 15:02:23 2024 -0400 Revert #4358 - Replace long + TimeUnit with Duration in ReadOnlyTStore.unreserve() --- .../java/org/apache/accumulo/core/fate/AdminUtil.java | 8 ++++---- .../org/apache/accumulo/core/fate/AgeOffStore.java | 10 +++++----- .../main/java/org/apache/accumulo/core/fate/Fate.java | 14 +++++++------- .../org/apache/accumulo/core/fate/ReadOnlyTStore.java | 5 +++-- .../java/org/apache/accumulo/core/fate/ZooStore.java | 10 ++++++---- .../org/apache/accumulo/core/logging/FateLogger.java | 6 +++--- .../org/apache/accumulo/core/fate/AgeOffStoreTest.java | 18 +++++++++--------- .../java/org/apache/accumulo/core/fate/TestStore.java | 4 ++-- 8 files changed, 39 insertions(+), 36 deletions(-) diff --git a/core/src/main/java/org/apache/accumulo/core/fate/AdminUtil.java b/core/src/main/java/org/apache/accumulo/core/fate/AdminUtil.java index 7cc0a9c004..858e6e6998 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/AdminUtil.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/AdminUtil.java @@ -20,7 +20,6 @@ package org.apache.accumulo.core.fate; import static java.nio.charset.StandardCharsets.UTF_8; -import java.time.Duration; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -33,6 +32,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.fate.ReadOnlyTStore.TStatus; import org.apache.accumulo.core.fate.zookeeper.FateLock; @@ -368,7 +368,7 @@ public class AdminUtil<T> { long timeCreated = zs.timeCreated(tid); - zs.unreserve(tid, Duration.ZERO); + zs.unreserve(tid, 0, TimeUnit.MILLISECONDS); if (includeByStatus(status, filterStatus) && includeByTxid(tid, filterTxid)) { statuses.add(new TransactionStatus(tid, status, txName, hlocks, wlocks, top, timeCreated)); @@ -451,7 +451,7 @@ public class AdminUtil<T> { break; } - zs.unreserve(txid, Duration.ZERO); + zs.unreserve(txid, 0, TimeUnit.MILLISECONDS); return state; } @@ -495,7 +495,7 @@ public class AdminUtil<T> { break; } - zs.unreserve(txid, Duration.ZERO); + zs.unreserve(txid, 0, TimeUnit.MILLISECONDS); return state; } diff --git a/core/src/main/java/org/apache/accumulo/core/fate/AgeOffStore.java b/core/src/main/java/org/apache/accumulo/core/fate/AgeOffStore.java index bd2bd5208b..ca016d0c9c 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/AgeOffStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/AgeOffStore.java @@ -19,13 +19,13 @@ package org.apache.accumulo.core.fate; import java.io.Serializable; -import java.time.Duration; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -108,7 +108,7 @@ public class AgeOffStore<T> implements TStore<T> { } } finally { - store.unreserve(txid, Duration.ZERO); + store.unreserve(txid, 0, TimeUnit.MILLISECONDS); } } catch (Exception e) { log.warn("Failed to age off FATE tx " + FateTxId.formatTid(txid), e); @@ -138,7 +138,7 @@ public class AgeOffStore<T> implements TStore<T> { break; } } finally { - store.unreserve(txid, Duration.ZERO); + store.unreserve(txid, 0, TimeUnit.MILLISECONDS); } } } @@ -166,8 +166,8 @@ public class AgeOffStore<T> implements TStore<T> { } @Override - public void unreserve(long tid, Duration deferTime) { - store.unreserve(tid, deferTime); + public void unreserve(long tid, long deferTime, TimeUnit deferTimeUnit) { + store.unreserve(tid, deferTime, deferTimeUnit); } @Override diff --git a/core/src/main/java/org/apache/accumulo/core/fate/Fate.java b/core/src/main/java/org/apache/accumulo/core/fate/Fate.java index 4fe07bb8b2..1a14418b1a 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/Fate.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/Fate.java @@ -30,12 +30,12 @@ import static org.apache.accumulo.core.fate.ReadOnlyTStore.TStatus.SUCCESSFUL; import static org.apache.accumulo.core.fate.ReadOnlyTStore.TStatus.UNKNOWN; import static org.apache.accumulo.core.util.ShutdownUtil.isIOException; -import java.time.Duration; import java.util.EnumSet; import java.util.concurrent.ExecutorService; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; @@ -133,7 +133,7 @@ public class Fate<T> { runnerLog.error("Uncaught exception in FATE runner thread.", e); } finally { if (tid != null) { - store.unreserve(tid, Duration.ofMillis(deferTime)); + store.unreserve(tid, deferTime, TimeUnit.MILLISECONDS); } } } @@ -289,7 +289,7 @@ public class Fate<T> { store.setStatus(tid, SUBMITTED); } } finally { - store.unreserve(tid, Duration.ZERO); + store.unreserve(tid, 0, TimeUnit.MILLISECONDS); } } @@ -325,7 +325,7 @@ public class Fate<T> { return false; } } finally { - store.unreserve(tid, Duration.ZERO); + store.unreserve(tid, 0, TimeUnit.MILLISECONDS); } } else { // reserved, lets retry. @@ -356,7 +356,7 @@ public class Fate<T> { break; } } finally { - store.unreserve(tid, Duration.ZERO); + store.unreserve(tid, 0, TimeUnit.MILLISECONDS); } } @@ -369,7 +369,7 @@ public class Fate<T> { } return (String) store.getTransactionInfo(tid, TxInfo.RETURN_VALUE); } finally { - store.unreserve(tid, Duration.ZERO); + store.unreserve(tid, 0, TimeUnit.MILLISECONDS); } } @@ -383,7 +383,7 @@ public class Fate<T> { } return (Exception) store.getTransactionInfo(tid, TxInfo.EXCEPTION); } finally { - store.unreserve(tid, Duration.ZERO); + store.unreserve(tid, 0, TimeUnit.MILLISECONDS); } } diff --git a/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyTStore.java b/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyTStore.java index 0b48c3b823..4a216f1e36 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyTStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/ReadOnlyTStore.java @@ -19,9 +19,9 @@ package org.apache.accumulo.core.fate; import java.io.Serializable; -import java.time.Duration; import java.util.EnumSet; import java.util.List; +import java.util.concurrent.TimeUnit; /** * Read only access to a Transaction Store. @@ -79,8 +79,9 @@ public interface ReadOnlyTStore<T> { * @param tid transaction id, previously reserved. * @param deferTime time to keep this transaction out of the pool used in the {@link #reserve() * reserve} method. must be non-negative. + * @param deferTimeUnit the time unit of deferTime */ - void unreserve(long tid, Duration deferTime); + void unreserve(long tid, long deferTime, TimeUnit deferTimeUnit); /** * Get the current operation for the given transaction id. diff --git a/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java b/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java index c3de5f29df..b7f5539a3c 100644 --- a/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java +++ b/core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java @@ -39,6 +39,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.fate.zookeeper.ZooReaderWriter; import org.apache.accumulo.core.fate.zookeeper.ZooUtil.NodeExistsPolicy; @@ -272,9 +273,10 @@ public class ZooStore<T> implements TStore<T> { } @Override - public void unreserve(long tid, Duration deferTime) { + public void unreserve(long tid, long deferTime, TimeUnit deferTimeUnit) { + Duration deferDuration = Duration.of(deferTime, deferTimeUnit.toChronoUnit()); - if (deferTime.isNegative()) { + if (deferDuration.compareTo(Duration.ZERO) < 0) { throw new IllegalArgumentException("deferTime < 0 : " + deferTime); } @@ -284,8 +286,8 @@ public class ZooStore<T> implements TStore<T> { "Tried to unreserve id that was not reserved " + FateTxId.formatTid(tid)); } - if (deferTime.compareTo(Duration.ZERO) > 0) { - deferred.put(tid, NanoTime.nowPlus(deferTime)); + if (deferTime > 0) { + deferred.put(tid, NanoTime.nowPlus(deferDuration)); } this.notifyAll(); diff --git a/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java b/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java index fa7ed86e08..ccad01a7f1 100644 --- a/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java +++ b/core/src/main/java/org/apache/accumulo/core/logging/FateLogger.java @@ -21,9 +21,9 @@ package org.apache.accumulo.core.logging; import static org.apache.accumulo.core.fate.FateTxId.formatTid; import java.io.Serializable; -import java.time.Duration; import java.util.EnumSet; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.function.Function; import org.apache.accumulo.core.fate.Fate; @@ -62,8 +62,8 @@ public class FateLogger { } @Override - public void unreserve(long tid, Duration deferTime) { - store.unreserve(tid, deferTime); + public void unreserve(long tid, long deferTime, TimeUnit deferTimeUnit) { + store.unreserve(tid, deferTime, deferTimeUnit); } @Override diff --git a/core/src/test/java/org/apache/accumulo/core/fate/AgeOffStoreTest.java b/core/src/test/java/org/apache/accumulo/core/fate/AgeOffStoreTest.java index 42adc60bef..c2b086ee34 100644 --- a/core/src/test/java/org/apache/accumulo/core/fate/AgeOffStoreTest.java +++ b/core/src/test/java/org/apache/accumulo/core/fate/AgeOffStoreTest.java @@ -20,9 +20,9 @@ package org.apache.accumulo.core.fate; import static org.junit.jupiter.api.Assertions.assertEquals; -import java.time.Duration; import java.util.HashSet; import java.util.Set; +import java.util.concurrent.TimeUnit; import org.apache.accumulo.core.fate.AgeOffStore.TimeSource; import org.apache.accumulo.core.fate.ReadOnlyTStore.TStatus; @@ -53,7 +53,7 @@ public class AgeOffStoreTest { long txid1 = aoStore.create(); aoStore.reserve(txid1); aoStore.setStatus(txid1, TStatus.IN_PROGRESS); - aoStore.unreserve(txid1, Duration.ZERO); + aoStore.unreserve(txid1, 0, TimeUnit.MILLISECONDS); aoStore.ageOff(); @@ -61,7 +61,7 @@ public class AgeOffStoreTest { aoStore.reserve(txid2); aoStore.setStatus(txid2, TStatus.IN_PROGRESS); aoStore.setStatus(txid2, TStatus.FAILED); - aoStore.unreserve(txid2, Duration.ZERO); + aoStore.unreserve(txid2, 0, TimeUnit.MILLISECONDS); tts.time = 6; @@ -69,7 +69,7 @@ public class AgeOffStoreTest { aoStore.reserve(txid3); aoStore.setStatus(txid3, TStatus.IN_PROGRESS); aoStore.setStatus(txid3, TStatus.SUCCESSFUL); - aoStore.unreserve(txid3, Duration.ZERO); + aoStore.unreserve(txid3, 0, TimeUnit.MILLISECONDS); Long txid4 = aoStore.create(); @@ -102,19 +102,19 @@ public class AgeOffStoreTest { long txid1 = testStore.create(); testStore.reserve(txid1); testStore.setStatus(txid1, TStatus.IN_PROGRESS); - testStore.unreserve(txid1, Duration.ZERO); + testStore.unreserve(txid1, 0, TimeUnit.MILLISECONDS); long txid2 = testStore.create(); testStore.reserve(txid2); testStore.setStatus(txid2, TStatus.IN_PROGRESS); testStore.setStatus(txid2, TStatus.FAILED); - testStore.unreserve(txid2, Duration.ZERO); + testStore.unreserve(txid2, 0, TimeUnit.MILLISECONDS); long txid3 = testStore.create(); testStore.reserve(txid3); testStore.setStatus(txid3, TStatus.IN_PROGRESS); testStore.setStatus(txid3, TStatus.SUCCESSFUL); - testStore.unreserve(txid3, Duration.ZERO); + testStore.unreserve(txid3, 0, TimeUnit.MILLISECONDS); Long txid4 = testStore.create(); @@ -137,7 +137,7 @@ public class AgeOffStoreTest { aoStore.reserve(txid1); aoStore.setStatus(txid1, TStatus.FAILED_IN_PROGRESS); - aoStore.unreserve(txid1, Duration.ZERO); + aoStore.unreserve(txid1, 0, TimeUnit.MILLISECONDS); tts.time = 30; @@ -148,7 +148,7 @@ public class AgeOffStoreTest { aoStore.reserve(txid1); aoStore.setStatus(txid1, TStatus.FAILED); - aoStore.unreserve(txid1, Duration.ZERO); + aoStore.unreserve(txid1, 0, TimeUnit.MILLISECONDS); aoStore.ageOff(); diff --git a/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java b/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java index ba06a51ff9..3253c41a90 100644 --- a/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java +++ b/core/src/test/java/org/apache/accumulo/core/fate/TestStore.java @@ -18,13 +18,13 @@ */ package org.apache.accumulo.core.fate; -import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; /** * Transient in memory store for transactions. @@ -62,7 +62,7 @@ public class TestStore extends ZooStore<String> { } @Override - public void unreserve(long tid, Duration deferTime) { + public void unreserve(long tid, long deferTime, TimeUnit deferTimeUnit) { if (!reserved.remove(tid)) { throw new IllegalStateException(); }