You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by "kevinrr888 (via GitHub)" <gi...@apache.org> on 2024/01/03 15:29:45 UTC

[PR] ZooStore deferral time to use System.nanoTime() [accumulo]

kevinrr888 opened a new pull request, #4126:
URL: https://github.com/apache/accumulo/pull/4126

   Closes #4068
   - `ZooStore` now uses `System.nanoTime()` instead of `System.currentTimeMillis()`
   - Added `TimeUnit` param to `unreserve()`
   - Renamed 'defered' -> 'deferred'
   
   Also have branch ready to be compared against elasticity if these changes are good (changes were also requested for AccumuloStore in elasticity in #4068)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZooStore deferral time to use System.nanoTime() [accumulo]

Posted by "kevinrr888 (via GitHub)" <gi...@apache.org>.
kevinrr888 commented on code in PR #4126:
URL: https://github.com/apache/accumulo/pull/4126#discussion_r1441930719


##########
core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java:
##########
@@ -200,11 +201,12 @@ public long reserve() {
         synchronized (this) {
           // suppress lgtm alert - synchronized variable is not always true
           if (events == statusChangeEvents) { // lgtm [java/constant-comparison]
-            if (defered.isEmpty()) {
+            if (deferred.isEmpty()) {
               this.wait(5000);
             } else {
-              Long minTime = Collections.min(defered.values());
-              long waitTime = minTime - System.currentTimeMillis();
+              Long minTime = Collections.min(deferred.values());

Review Comment:
   Good catch! Changed to suggested.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZooStore deferral time to use System.nanoTime() [accumulo]

Posted by "keith-turner (via GitHub)" <gi...@apache.org>.
keith-turner commented on code in PR #4126:
URL: https://github.com/apache/accumulo/pull/4126#discussion_r1441103144


##########
core/src/main/java/org/apache/accumulo/core/fate/ZooStore.java:
##########
@@ -200,11 +201,12 @@ public long reserve() {
         synchronized (this) {
           // suppress lgtm alert - synchronized variable is not always true
           if (events == statusChangeEvents) { // lgtm [java/constant-comparison]
-            if (defered.isEmpty()) {
+            if (deferred.isEmpty()) {
               this.wait(5000);
             } else {
-              Long minTime = Collections.min(defered.values());
-              long waitTime = minTime - System.currentTimeMillis();
+              Long minTime = Collections.min(deferred.values());

Review Comment:
   because nanoTime can wrap, the min wait time could be `Long.MAX_VALUE - 10` but this could return something like `Long.MAX_VALUE + 10` if its in the values because that would be negative.   
   
   Did the following experiment
   
   ```
   jshell> var vals = List.of(Long.MAX_VALUE - 10, Long.MAX_VALUE + 10)
   vals ==> [9223372036854775797, -9223372036854775799]
   
   jshell> long currTime = Long.MAX_VALUE + 5
   currTime ==> -9223372036854775804
   
   jshell> vals.stream().mapToLong(l-> l - currTime).min().getAsLong()
   $15 ==> -15
   
   jshell> Collections.min(vals) - currTime
   $16 ==> 5
   ```
   
   Based on that, thinking this code could be.  Hopefully the following code is correct even if nano time wraps.
   
   ```java
   long currTime = System.nanoTime();
   long minDuration = deferred.values().stream().mapToLong(l-> l - currTime).min().getAsLong()
    waitTime = TimeUnit.MILLISECONDS.convert(minDuration, TimeUnit.NANOSECONDS);
   ```
   
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZooStore deferral time to use System.nanoTime() [accumulo]

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo commented on PR #4126:
URL: https://github.com/apache/accumulo/pull/4126#issuecomment-1877640038

   Borrow from https://github.com/apache/accumulo/pull/2906#issuecomment-1234611631:
   
   Thanks for the PR @kevinrr888. If you wish to be added as a contributor to https://accumulo.apache.org/people/ , please open a pull request to add yourself (in alphabetical order) at https://github.com/apache/accumulo-website/edit/main/pages/people.md and leave a reference to apache/accumulo#4126 in your commit log.
   
   If you intend to be a regular contributor to Accumulo projects, please consider subscribing to our developer mailing list (https://accumulo.apache.org/contact-us/) and introducing yourself.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] ZooStore deferral time to use System.nanoTime() [accumulo]

Posted by "DomGarguilo (via GitHub)" <gi...@apache.org>.
DomGarguilo merged PR #4126:
URL: https://github.com/apache/accumulo/pull/4126


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org