virajjasani commented on PR #5837:
URL: https://github.com/apache/hbase/pull/5837#issuecomment-2146135324

   @Apache9, I looked into this with Divneet today. How about this?
   
   ```
     public CompletableFuture<byte[]> getWithTimeout(String path, long endTime) 
{
       CompletableFuture<byte[]> future = get(path);
       TimerTask timerTask = new TimerTask() {
         @Override
         public void run(Timeout timeout) throws Exception {
           if (EnvironmentEdgeManager.currentTime() > endTime) {
             if (!future.isCancelled() && !future.isDone() && 
!future.isCompletedExceptionally()) {
               future.completeExceptionally(
                 new DoNotRetryIOException("Zookeeper get could not be 
completed by " + endTime));
             }
           } else {
             if (!future.isCancelled() && !future.isDone() && 
!future.isCompletedExceptionally()) {
               AsyncConnectionImpl.RETRY_TIMER.newTimeout(this, 10, 
TimeUnit.MILLISECONDS);
             }
           }
         }
       };
       AsyncConnectionImpl.RETRY_TIMER.newTimeout(timerTask, 1, 
TimeUnit.MILLISECONDS);
       return future;
     }
   ```
   
   At ZKConnectionRegistry, we can call zk#getWithTimeout rather than zk#get.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to