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

   The other example is for `execProcedure`:
   
   ```
     @Override
     public CompletableFuture<Void> execProcedure(String signature, String 
instance,
       Map<String, String> props) {
       CompletableFuture<Void> future = new CompletableFuture<>();
       ProcedureDescription procDesc =
         ProtobufUtil.buildProcedureDescription(signature, instance, props);
       addListener(this.<Long> newMasterCaller()
         .action((controller, stub) -> this.<ExecProcedureRequest, 
ExecProcedureResponse, Long> call(
           controller, stub, 
ExecProcedureRequest.newBuilder().setProcedure(procDesc).build(),
           (s, c, req, done) -> s.execProcedure(c, req, done), resp -> 
resp.getExpectedTimeout()))
         .call(), (expectedTimeout, err) -> {
           if (err != null) {
             future.completeExceptionally(err);
             return;
           }
           TimerTask pollingTask = new TimerTask() {
             int tries = 0;
             long startTime = EnvironmentEdgeManager.currentTime();
             long endTime = startTime + expectedTimeout;
             long maxPauseTime = expectedTimeout / maxAttempts;
   
             @Override
             public void run(Timeout timeout) throws Exception {
               if (EnvironmentEdgeManager.currentTime() < endTime) {
                 addListener(isProcedureFinished(signature, instance, props), 
(done, err2) -> {
                   if (err2 != null) {
                     future.completeExceptionally(err2);
                     return;
                   }
                   if (done) {
                     future.complete(null);
                   } else {
                     // retry again after pauseTime.
                     long pauseTime =
                       
ConnectionUtils.getPauseTime(TimeUnit.NANOSECONDS.toMillis(pauseNs), ++tries);
                     pauseTime = Math.min(pauseTime, maxPauseTime);
                     AsyncConnectionImpl.RETRY_TIMER.newTimeout(this, pauseTime,
                       TimeUnit.MICROSECONDS);
                   }
                 });
               } else {
                 future.completeExceptionally(new IOException("Procedure '" + 
signature + " : "
                   + instance + "' wasn't completed in expectedTime:" + 
expectedTimeout + " ms"));
               }
             }
           };
           // Queue the polling task into RETRY_TIMER to poll procedure state 
asynchronously.
           AsyncConnectionImpl.RETRY_TIMER.newTimeout(pollingTask, 1, 
TimeUnit.MILLISECONDS);
         });
       return future;
     }
   ```


-- 
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: issues-unsubscr...@hbase.apache.org

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

Reply via email to