pvary commented on a change in pull request #1937:
URL: https://github.com/apache/hive/pull/1937#discussion_r568640128



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Worker.java
##########
@@ -574,6 +573,35 @@ protected Boolean findNextCompactionAndExecute(boolean 
computeStats) throws Inte
     return true;
   }
 
+  /**
+   * Just AcidUtils.getAcidState, but with impersonation if needed.
+   */
+  private AcidDirectory getAcidStateForWorker(CompactionInfo ci, 
StorageDescriptor sd,
+          ValidCompactorWriteIdList tblValidWriteIds) throws IOException, 
InterruptedException {
+    Ref<AcidDirectory> acidDirectoryRef = Ref.from(null);
+    if (runJobAsSelf(ci.runAs)) {
+      acidDirectoryRef.value = AcidUtils.getAcidState(null, new 
Path(sd.getLocation()), conf,
+              tblValidWriteIds, Ref.from(false), true);
+    } else {
+      UserGroupInformation ugi = 
UserGroupInformation.createProxyUser(ci.runAs, 
UserGroupInformation.getLoginUser());
+      try {
+        ugi.doAs((PrivilegedExceptionAction<Object>) () -> {
+          acidDirectoryRef.value = AcidUtils.getAcidState(null, new 
Path(sd.getLocation()), conf,
+                  tblValidWriteIds, Ref.from(false), true);
+          return null;
+        });

Review comment:
       Maybe this:
   ```
           acidDirectoryRef = 
ugi.doAs((PrivilegedExceptionAction<AcidDirectory>) () -> 
                AcidUtils.getAcidState(null, new Path(sd.getLocation()), conf,
                 tblValidWriteIds, Ref.from(false), true)
           );
   ```

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/Worker.java
##########
@@ -574,6 +573,35 @@ protected Boolean findNextCompactionAndExecute(boolean 
computeStats) throws Inte
     return true;
   }
 
+  /**
+   * Just AcidUtils.getAcidState, but with impersonation if needed.
+   */
+  private AcidDirectory getAcidStateForWorker(CompactionInfo ci, 
StorageDescriptor sd,
+          ValidCompactorWriteIdList tblValidWriteIds) throws IOException, 
InterruptedException {
+    Ref<AcidDirectory> acidDirectoryRef = Ref.from(null);
+    if (runJobAsSelf(ci.runAs)) {
+      acidDirectoryRef.value = AcidUtils.getAcidState(null, new 
Path(sd.getLocation()), conf,
+              tblValidWriteIds, Ref.from(false), true);
+    } else {
+      UserGroupInformation ugi = 
UserGroupInformation.createProxyUser(ci.runAs, 
UserGroupInformation.getLoginUser());
+      try {
+        ugi.doAs((PrivilegedExceptionAction<Object>) () -> {
+          acidDirectoryRef.value = AcidUtils.getAcidState(null, new 
Path(sd.getLocation()), conf,
+                  tblValidWriteIds, Ref.from(false), true);
+          return null;
+        });

Review comment:
       Maybe this:
   ```
           acidDirectory = ugi.doAs((PrivilegedExceptionAction<AcidDirectory>) 
() -> 
                AcidUtils.getAcidState(null, new Path(sd.getLocation()), conf,
                 tblValidWriteIds, Ref.from(false), true)
           );
   ```




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

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