You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by ta...@apache.org on 2020/04/15 16:57:53 UTC

[impala] 02/02: IMPALA-9160 (Part 2): Instantiate rangerConfig_ using RangerPluginConfig

This is an automated email from the ASF dual-hosted git repository.

tarmstrong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 026ae182ef4b5111aba625a26d50b8b53563088d
Author: Fang-Yu Rao <fa...@cloudera.com>
AuthorDate: Mon Apr 13 14:47:44 2020 -0700

    IMPALA-9160 (Part 2): Instantiate rangerConfig_ using RangerPluginConfig
    
    Now that we are using a CDP_BUILD_NUMBER newer than 1626038, we are able
    to instantiate rangerConfig_ in RangerAuthorizationConfig.java using the
    class of RangerPluginConfig provided in the newer version of Ranger due
    to RANGER-2646. This patch adds back rangerConfig_, which was removed
    from RangerAuthorizationConfig.java in part 1 of this patch.
    
    Testing:
    - Verified that this patch passes the exhaustive tests in the DEBUG
      build.
    
    Change-Id: I710a6362a2494bf5ab3784259a44c3470823512f
    Reviewed-on: http://gerrit.cloudera.org:8080/15721
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 .../ranger/RangerAuthorizationConfig.java          | 35 ++++++++++++++++++++--
 .../ranger/RangerAuthorizationFactory.java         |  3 +-
 .../authorization/AuthorizationTestBase.java       |  2 +-
 3 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationConfig.java b/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationConfig.java
index a15b854..47f81fa 100644
--- a/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationConfig.java
+++ b/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationConfig.java
@@ -19,7 +19,8 @@ package org.apache.impala.authorization.ranger;
 
 import com.google.common.base.Preconditions;
 import org.apache.impala.authorization.AuthorizationConfig;
-import org.apache.impala.authorization.AuthorizationProvider;
+import org.apache.ranger.authorization.hadoop.config.RangerPluginConfig;
+import org.apache.ranger.plugin.policyengine.RangerPolicyEngineOptions;
 
 /**
  * Impala authorization config with Ranger.
@@ -28,11 +29,22 @@ public class RangerAuthorizationConfig implements AuthorizationConfig {
   private final String serviceType_;
   private final String appId_;
   private final String serverName_;
+  private final String clusterName_;
+  private final String clusterType_;
+  private final RangerPolicyEngineOptions policyEngineOptions_;
+  private final RangerPluginConfig rangerConfig_;
 
-  public RangerAuthorizationConfig(String serviceType, String appId, String serverName) {
+  public RangerAuthorizationConfig(String serviceType, String appId, String serverName,
+      String clusterName, String clusterType,
+      RangerPolicyEngineOptions policyEngineOptions) {
     serviceType_ = Preconditions.checkNotNull(serviceType);
     appId_ = Preconditions.checkNotNull(appId);
     serverName_ = Preconditions.checkNotNull(serverName);
+    clusterName_ = clusterName;
+    clusterType_ = clusterType;
+    policyEngineOptions_ = policyEngineOptions;
+    rangerConfig_ = new RangerPluginConfig(serviceType_, serverName_, appId_,
+        clusterName_, clusterType_, policyEngineOptions_);
   }
 
   @Override
@@ -53,4 +65,23 @@ public class RangerAuthorizationConfig implements AuthorizationConfig {
    * Returns the Ranger application ID.
    */
   public String getAppId() { return appId_; }
+
+  /**
+   * Returns the Ranger cluster name.
+   */
+  public String getClusterName() { return clusterName_; }
+
+  /**
+   * Returns the Ranger cluster type.
+   */
+  public String getClusterType() { return clusterType_; }
+
+  /**
+   * Returns the Ranger policy engine options.
+   */
+  public RangerPolicyEngineOptions getPolicyEngineOptions() {
+      return policyEngineOptions_;
+  }
+
+  public RangerPluginConfig getRangerConfig() { return rangerConfig_; }
 }
diff --git a/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationFactory.java b/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationFactory.java
index 92e8cd9..eb8a1a0 100644
--- a/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationFactory.java
+++ b/fe/src/main/java/org/apache/impala/authorization/ranger/RangerAuthorizationFactory.java
@@ -67,7 +67,8 @@ public class RangerAuthorizationFactory implements AuthorizationFactory {
         "Ranger application ID is empty. Set the Ranger application ID using " +
             "impalad and catalogd --ranger_app_id flag.");
     return new RangerAuthorizationConfig(backendConfig.getRangerServiceType(),
-        backendConfig.getRangerAppId(), backendConfig.getBackendCfg().getServer_name());
+        backendConfig.getRangerAppId(), backendConfig.getBackendCfg().getServer_name(),
+        null, null, null);
   }
 
   @Override
diff --git a/fe/src/test/java/org/apache/impala/authorization/AuthorizationTestBase.java b/fe/src/test/java/org/apache/impala/authorization/AuthorizationTestBase.java
index cbee2f9..1d2b203 100644
--- a/fe/src/test/java/org/apache/impala/authorization/AuthorizationTestBase.java
+++ b/fe/src/test/java/org/apache/impala/authorization/AuthorizationTestBase.java
@@ -139,7 +139,7 @@ public abstract class AuthorizationTestBase extends FrontendTestBase {
       case RANGER:
         user_ = new User("non_owner");
         authzConfig_ = new RangerAuthorizationConfig(RANGER_SERVICE_TYPE, RANGER_APP_ID,
-            SERVER_NAME);
+            SERVER_NAME, null, null, null);
         authzFactory_ = createAuthorizationFactory(authzProvider);
         authzCtx_ = createAnalysisCtx(authzFactory_, user_.getName());
         authzCatalog_ = new ImpaladTestCatalog(authzFactory_);