rdblue commented on code in PR #4830:
URL: https://github.com/apache/iceberg/pull/4830#discussion_r879948727


##########
core/src/main/java/org/apache/iceberg/rest/RESTSessionCatalog.java:
##########
@@ -222,11 +278,61 @@ public boolean updateNamespaceMetadata(SessionContext 
context, Namespace ns,
     return !response.updated().isEmpty();
   }
 
+  private ScheduledExecutorService tokenRefreshExecutor() {
+    if (refreshExecutor == null) {
+      synchronized (this) {
+        if (refreshExecutor == null) {
+          this.refreshExecutor = ThreadPools.newScheduledPool(name() + 
"-token-refresh", 1);
+        }
+      }
+    }
+
+    return refreshExecutor;
+  }
+
+  private void scheduleTokenRefresh(
+      AuthSession session, long startTimeMillis, long expiresIn, TimeUnit 
unit) {
+    // convert expiration interval to milliseconds
+    long expiresInMillis = unit.toMillis(expiresIn);
+    // how much ahead of time to start the request to allow it to complete
+    long refreshWindowMillis = Math.min(expiresInMillis / 10, 
MAX_REFRESH_WINDOW_MILLIS);

Review Comment:
   The logic here is to start the refresh with 10% of the retry window left, 
but no more than some maximum (in case expires-in is long, like 10 hours).



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to