You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2020/05/27 11:58:11 UTC
[asterixdb] 02/03: [NO ISSUE][*HYR] Span enhancements
This is an automated email from the ASF dual-hosted git repository.
mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 1d6f811b6e88b5956ef83811b18840f611f2aa7f
Author: Michael Blow <mi...@couchbase.com>
AuthorDate: Mon May 25 08:58:48 2020 -0400
[NO ISSUE][*HYR] Span enhancements
- add reset() to start the span over again
- add sleep() to sleep for the remainder of the span
Change-Id: I93799354f2e238b759d2ef11aed109ec96baaf21
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/6483
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mb...@apache.org>
Reviewed-by: Hussain Towaileb <hu...@gmail.com>
---
.../src/main/java/org/apache/hyracks/util/Span.java | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
index 183cb6f..bc33e6d 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/Span.java
@@ -21,18 +21,26 @@ package org.apache.hyracks.util;
import java.util.concurrent.TimeUnit;
public class Span {
- private final long startNanos;
private final long spanNanos;
+ private volatile long startNanos;
private Span(long span, TimeUnit unit) {
- startNanos = System.nanoTime();
spanNanos = unit.toNanos(span);
+ reset();
+ }
+
+ public void reset() {
+ startNanos = System.nanoTime();
}
public long getSpanNanos() {
return spanNanos;
}
+ public long getSpan(TimeUnit unit) {
+ return unit.convert(spanNanos, TimeUnit.NANOSECONDS);
+ }
+
public static Span start(long span, TimeUnit unit) {
return new Span(span, unit);
}
@@ -46,6 +54,15 @@ public class Span {
}
/**
+ * Sleep for the remainder of this span
+ *
+ * @throws InterruptedException
+ */
+ public void sleep() throws InterruptedException {
+ TimeUnit.NANOSECONDS.sleep(remaining(TimeUnit.NANOSECONDS));
+ }
+
+ /**
* Sleep for the minimum of the duration or the remaining of this span
*
* @param sleep