This is an automated email from the ASF dual-hosted git repository.
kturner 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 5aca4f67bc simplifies handling of time in unload handler (#4548)
5aca4f67bc is described below
commit 5aca4f67bc18d221e766a9aec17e6dae0e153ea5
Author: Keith Turner <[email protected]>
AuthorDate: Fri May 10 16:53:01 2024 -0400
simplifies handling of time in unload handler (#4548)
---
.../org/apache/accumulo/core/util/time/SteadyTime.java | 5 +++++
.../apache/accumulo/tserver/TabletClientHandler.java | 5 +++--
.../apache/accumulo/tserver/UnloadTabletHandler.java | 18 ++++++++----------
3 files changed, 16 insertions(+), 12 deletions(-)
diff --git
a/core/src/main/java/org/apache/accumulo/core/util/time/SteadyTime.java
b/core/src/main/java/org/apache/accumulo/core/util/time/SteadyTime.java
index 4007b514c0..d16f15c201 100644
--- a/core/src/main/java/org/apache/accumulo/core/util/time/SteadyTime.java
+++ b/core/src/main/java/org/apache/accumulo/core/util/time/SteadyTime.java
@@ -56,6 +56,10 @@ public class SteadyTime implements Comparable<SteadyTime> {
return time.minus(other.getDuration());
}
+ public SteadyTime plus(Duration other) {
+ return SteadyTime.from(time.plus(other));
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) {
@@ -90,4 +94,5 @@ public class SteadyTime implements Comparable<SteadyTime> {
public static SteadyTime from(Duration time) {
return new SteadyTime(time);
}
+
}
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
index 7a6358b2b0..af16beed4c 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletClientHandler.java
@@ -103,6 +103,7 @@ import org.apache.accumulo.core.util.ByteBufferUtil;
import org.apache.accumulo.core.util.Halt;
import org.apache.accumulo.core.util.Pair;
import org.apache.accumulo.core.util.threads.Threads;
+import org.apache.accumulo.core.util.time.SteadyTime;
import org.apache.accumulo.server.ServerContext;
import org.apache.accumulo.server.compaction.CompactionInfo;
import org.apache.accumulo.server.compaction.FileCompactor;
@@ -1075,8 +1076,8 @@ public class TabletClientHandler implements
TabletServerClientService.Iface,
KeyExtent extent = KeyExtent.fromThrift(textent);
- server.resourceManager.addMigration(extent,
- new UnloadTabletHandler(server, extent, goal, requestTime));
+ server.resourceManager.addMigration(extent, new
UnloadTabletHandler(server, extent, goal,
+ SteadyTime.from(requestTime, TimeUnit.MILLISECONDS)));
}
@Override
diff --git
a/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java
index 1458901202..27c1048b24 100644
---
a/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java
+++
b/server/tserver/src/main/java/org/apache/accumulo/tserver/UnloadTabletHandler.java
@@ -18,11 +18,6 @@
*/
package org.apache.accumulo.tserver;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static java.util.concurrent.TimeUnit.NANOSECONDS;
-
-import java.util.concurrent.TimeUnit;
-
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.dataImpl.KeyExtent;
import org.apache.accumulo.core.manager.thrift.TabletLoadState;
@@ -31,6 +26,7 @@ import org.apache.accumulo.core.metadata.TabletLocationState;
import
org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException;
import org.apache.accumulo.core.metadata.schema.TabletMetadata.Location;
import org.apache.accumulo.core.tablet.thrift.TUnloadTabletGoal;
+import org.apache.accumulo.core.util.time.NanoTime;
import org.apache.accumulo.core.util.time.SteadyTime;
import org.apache.accumulo.server.manager.state.DistributedStoreException;
import org.apache.accumulo.server.manager.state.TabletStateStore;
@@ -43,15 +39,17 @@ class UnloadTabletHandler implements Runnable {
private static final Logger log =
LoggerFactory.getLogger(UnloadTabletHandler.class);
private final KeyExtent extent;
private final TUnloadTabletGoal goalState;
- private final long requestTimeSkew;
+ private final SteadyTime requestTime;
+ private final NanoTime createTime;
private final TabletServer server;
public UnloadTabletHandler(TabletServer server, KeyExtent extent,
TUnloadTabletGoal goalState,
- long requestTime) {
+ SteadyTime requestTime) {
this.extent = extent;
this.goalState = goalState;
this.server = server;
- this.requestTimeSkew = requestTime -
NANOSECONDS.toMillis(System.nanoTime());
+ this.requestTime = requestTime;
+ this.createTime = NanoTime.now();
}
@Override
@@ -124,8 +122,8 @@ class UnloadTabletHandler implements Runnable {
&&
!server.getConfiguration().getBoolean(Property.MANAGER_METADATA_SUSPENDABLE))) {
TabletStateStore.unassign(server.getContext(), tls, null);
} else {
- TabletStateStore.suspend(server.getContext(), tls, null,
SteadyTime.from(
- requestTimeSkew + NANOSECONDS.toMillis(System.nanoTime()),
TimeUnit.MILLISECONDS));
+ TabletStateStore.suspend(server.getContext(), tls, null,
+ requestTime.plus(createTime.elapsed()));
}
} catch (DistributedStoreException ex) {
log.warn("Unable to update storage", ex);