LUCENE-6823: use System.nanoTime for expiration in LocalReplicator

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1707683 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-10-09 09:39:12 +00:00
parent d557d725ed
commit 55befa558e
2 changed files with 9 additions and 3 deletions

View File

@ -177,6 +177,10 @@ Bug Fixes
terms because they were filtered out by e.g. a FilterCodecReader terms because they were filtered out by e.g. a FilterCodecReader
(Trejkaz via Mike McCandless) (Trejkaz via Mike McCandless)
* LUCENE-6823: LocalReplicator should use System.nanoTime as its clock
source for checking for expiration (Ishan Chattopadhyaya via Mike
McCandless)
Other Other
* LUCENE-6827: Use explicit capacity ArrayList instead of a LinkedList * LUCENE-6827: Use explicit capacity ArrayList instead of a LinkedList

View File

@ -22,6 +22,7 @@ import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.apache.lucene.store.AlreadyClosedException; import org.apache.lucene.store.AlreadyClosedException;
@ -87,15 +88,16 @@ public class LocalReplicator implements Replicator {
ReplicationSession(SessionToken session, RefCountedRevision revision) { ReplicationSession(SessionToken session, RefCountedRevision revision) {
this.session = session; this.session = session;
this.revision = revision; this.revision = revision;
lastAccessTime = System.currentTimeMillis(); lastAccessTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
} }
boolean isExpired(long expirationThreshold) { boolean isExpired(long expirationThreshold) {
return lastAccessTime < (System.currentTimeMillis() - expirationThreshold); return lastAccessTime < (TimeUnit.MILLISECONDS.convert(System.nanoTime(),
TimeUnit.NANOSECONDS) - expirationThreshold);
} }
void markAccessed() { void markAccessed() {
lastAccessTime = System.currentTimeMillis(); lastAccessTime = TimeUnit.MILLISECONDS.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
} }
} }