Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use System.nanoTime() for timeout calculation #205

Merged
merged 1 commit into from

3 participants

@ash2k

This fixes #150.

@elandau
Owner

I wonder if we should just use Guava's Stopwatch everywhere instead. What do you think?

@ash2k

I think that it's just a matter of taste.

@ash2k

Should i provide a new pull request with Stopwatch? Looks like authors are planing to redesign Stopwatch. Maybe just use nanoTime()?

@sagarl sagarl merged commit 5afcbce into Netflix:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 24, 2012
  1. @ash2k

    Use System.nanoTime() for timeout calculation

    ash2k authored
    This fixes #150.
This page is out of date. Refresh to see the latest.
View
4 src/main/java/com/netflix/astyanax/recipes/locks/ColumnPrefixDistributedRowLock.java
@@ -256,7 +256,7 @@ public void acquire() throws Exception {
m.execute();
verifyLock(curTimeMicros);
- acquireTime = System.currentTimeMillis();
+ acquireTime = System.nanoTime();
return;
}
catch (BusyLockException e) {
@@ -335,7 +335,7 @@ public void releaseWithMutation(MutationBatch m) throws Exception {
}
public boolean releaseWithMutation(MutationBatch m, boolean force) throws Exception {
- long elapsed = System.currentTimeMillis() - acquireTime;
+ long elapsed = TimeUnit.MILLISECONDS.convert(System.nanoTime() - acquireTime, TimeUnit.NANOSECONDS);
boolean isStale = false;
if (timeout > 0 && elapsed > TimeUnit.MILLISECONDS.convert(timeout, this.timeoutUnits)) {
isStale = true;
Something went wrong with that request. Please try again.