jerqi commented on code in PR #9569:
URL: https://github.com/apache/gravitino/pull/9569#discussion_r2667296320


##########
catalogs/hadoop-common/src/main/java/org/apache/gravitino/catalog/hadoop/fs/HDFSFileSystemProxy.java:
##########
@@ -148,46 +136,41 @@ public Object intercept(Object o, Method method, Object[] 
objects, MethodProxy m
     }
   }
 
-  /** Schedule periodic Kerberos re-login to refresh TGT before expiry. */
-  private void startKerberosRenewalTask(String principal) {
-    kerberosRenewExecutor =
-        Executors.newSingleThreadScheduledExecutor(
-            r -> {
-              Thread t = new Thread(r, "HDFSFileSystemProxy 
Kerberos-Renewal-Thread");
-              t.setDaemon(true);
-              return t;
-            });
-
-    kerberosRenewExecutor.scheduleAtFixedRate(
-        () -> {
-          try {
-            if (ugi.hasKerberosCredentials()) {
-              ugi.checkTGTAndReloginFromKeytab();
-            }
-          } catch (Exception e) {
-            LOG.error(
-                "[Kerberos] Failed to renew TGT for principal {}: {}",
-                principal,
-                e.getMessage(),
-                e);
-          }
-        },
-        DEFAULT_RENEW_INTERVAL_MS,
-        DEFAULT_RENEW_INTERVAL_MS,
-        TimeUnit.MILLISECONDS);
+  @SuppressWarnings("removal")
+  public static Principal getCurrentPrincipal() {
+    java.security.AccessControlContext context = 
java.security.AccessController.getContext();
+    Subject subject = Subject.getSubject(context);
+    if (subject == null || 
subject.getPrincipals(UserPrincipal.class).isEmpty()) {
+      return null;
+    }
+    return subject.getPrincipals(UserPrincipal.class).iterator().next();
   }
 
-  /** Close the Kerberos renewal executor service to prevent resource leaks. */
-  private void close() {
-    if (kerberosRenewExecutor != null) {
-      kerberosRenewExecutor.shutdownNow();
-      kerberosRenewExecutor = null;
+  private UserGroupInformation getHadoopUser() throws Exception {
+    UserGroupInformation currentUgi;
+    if (impersonationEnabled) {
+      Principal principal = getCurrentPrincipal();
+      if (principal != null) {
+        String proxyUserName = getCurrentPrincipal().getName();
+        if (!proxyUserName.contains("@")) {

Review Comment:
   UserPrincipal won't occur in the client side. Some classes will only occur 
in the server side.



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