Skip to content

Apache Lucene open-source search software

Fix API change and add javadoc.

Andrzej Bialecki93926e9c83a9
diff --git a/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java b/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java
index f904a98eb5a..d277e31cbde 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ActionThrottleTest.java
@@ -45,6 +45,12 @@ public class ActionThrottleTest extends SolrTestCaseJ4 {
return getTimeNs();
}
+ @Override
+ public long[] getTimeAndEpochNs() {
+ long time = getTimeNs();
+ return new long[]{time, time};
+ }
+
@Override
public void sleep(long ms) throws InterruptedException {
throw new UnsupportedOperationException();
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java b/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java
index 69aa40ff6a4..ac8749d79bd 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/TimeSource.java
@@ -52,7 +52,7 @@ public abstract class TimeSource {
}
@Override
- long[] getTimeAndEpochNs() {
+ public long[] getTimeAndEpochNs() {
long time = getTimeNs();
return new long[] {time, time};
}
@@ -94,7 +94,7 @@ public abstract class TimeSource {
}
@Override
- long[] getTimeAndEpochNs() {
+ public long[] getTimeAndEpochNs() {
long time = getTimeNs();
return new long[] {time, epochStart + time - nanoStart};
}
@@ -138,7 +138,7 @@ public abstract class TimeSource {
}
@Override
- long[] getTimeAndEpochNs() {
+ public long[] getTimeAndEpochNs() {
long time = getTimeNs();
return new long[] {time, epochStart + time - nanoStart};
}
@@ -216,8 +216,14 @@ public abstract class TimeSource {
*/
public abstract long getEpochTimeNs();
- // for unit testing
- abstract long[] getTimeAndEpochNs();
+ /**
+ * Return both the source's time value and the corresponding epoch time
+ * value. This method ensures that epoch time calculations use the same internal
+ * value of time as that reported by {@link #getTimeNs()}.
+ * @return an array where the first element is {@link #getTimeNs()} and the
+ * second element is {@link #getEpochTimeNs()}.
+ */
+ public abstract long[] getTimeAndEpochNs();
/**
* Sleep according to this source's notion of time. Eg. accelerated time source such as