gobblin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hut...@apache.org
Subject incubator-gobblin git commit: [GOBBLIN-186] Add support for using the Kerberos authentication plugin without a GobblinDriverInstance[]
Date Wed, 09 Aug 2017 17:20:27 GMT
Repository: incubator-gobblin
Updated Branches:
  refs/heads/master f502cbee3 -> 3ab02b3f2


[GOBBLIN-186] Add support for using the Kerberos authentication plugin without a GobblinDriverInstance[]

Closes #2041 from htran1/kerberos_from_config


Project: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/commit/3ab02b3f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/tree/3ab02b3f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-gobblin/diff/3ab02b3f

Branch: refs/heads/master
Commit: 3ab02b3f25b0769181e7dab2a99f2ca2b124719b
Parents: f502cbe
Author: Hung Tran <hutran@linkedin.com>
Authored: Wed Aug 9 10:20:18 2017 -0700
Committer: Hung Tran <hutran@linkedin.com>
Committed: Wed Aug 9 10:20:18 2017 -0700

----------------------------------------------------------------------
 ...HadoopKerberosKeytabAuthenticationPlugin.java | 19 +++++++++++++------
 ...HadoopKerberosKeytabAuthenticationPlugin.java | 14 ++++++++++++++
 2 files changed, 27 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/3ab02b3f/gobblin-runtime-hadoop/src/main/java/org/apache/gobblin/runtime/instance/plugin/hadoop/HadoopKerberosKeytabAuthenticationPlugin.java
----------------------------------------------------------------------
diff --git a/gobblin-runtime-hadoop/src/main/java/org/apache/gobblin/runtime/instance/plugin/hadoop/HadoopKerberosKeytabAuthenticationPlugin.java
b/gobblin-runtime-hadoop/src/main/java/org/apache/gobblin/runtime/instance/plugin/hadoop/HadoopKerberosKeytabAuthenticationPlugin.java
index 4e1747d..c30f268 100644
--- a/gobblin-runtime-hadoop/src/main/java/org/apache/gobblin/runtime/instance/plugin/hadoop/HadoopKerberosKeytabAuthenticationPlugin.java
+++ b/gobblin-runtime-hadoop/src/main/java/org/apache/gobblin/runtime/instance/plugin/hadoop/HadoopKerberosKeytabAuthenticationPlugin.java
@@ -48,8 +48,10 @@ public class HadoopKerberosKeytabAuthenticationPlugin extends BaseIdlePluginImpl
   public static class ConfigBasedFactory implements GobblinInstancePluginFactory {
     @Override
     public GobblinInstancePlugin createPlugin(GobblinInstanceDriver instance) {
+      return createPlugin(instance.getSysConfig().getConfig());
+    }
 
-      Config sysConfig = instance.getSysConfig().getConfig();
+    public GobblinInstancePlugin createPlugin(Config sysConfig) {
       if (!sysConfig.hasPath(PluginStaticKeys.LOGIN_USER_FULL_KEY)) {
         throw new RuntimeException("Missing required sys config: " + PluginStaticKeys.LOGIN_USER_FULL_KEY);
       }
@@ -60,7 +62,7 @@ public class HadoopKerberosKeytabAuthenticationPlugin extends BaseIdlePluginImpl
       String loginUser = sysConfig.getString(PluginStaticKeys.LOGIN_USER_FULL_KEY);
       String loginUserKeytabFile = sysConfig.getString(PluginStaticKeys.LOGIN_USER_KEYTAB_FILE_FULL_KEY);
 
-      return new HadoopKerberosKeytabAuthenticationPlugin(instance, loginUser, loginUserKeytabFile);
+      return new HadoopKerberosKeytabAuthenticationPlugin(sysConfig, loginUser, loginUserKeytabFile);
     }
   }
 
@@ -75,7 +77,8 @@ public class HadoopKerberosKeytabAuthenticationPlugin extends BaseIdlePluginImpl
 
     @Override
     public GobblinInstancePlugin createPlugin(GobblinInstanceDriver instance) {
-      return new HadoopKerberosKeytabAuthenticationPlugin(instance, _loginUser, _loginUserKeytabFile);
+      return new HadoopKerberosKeytabAuthenticationPlugin(instance.getSysConfig().getConfig(),
_loginUser,
+          _loginUserKeytabFile);
     }
   }
 
@@ -83,9 +86,8 @@ public class HadoopKerberosKeytabAuthenticationPlugin extends BaseIdlePluginImpl
   private final String _loginUserKeytabFile;
   private final Configuration _hadoopConf;
 
-  private HadoopKerberosKeytabAuthenticationPlugin(GobblinInstanceDriver instance, String
loginUser, String loginUserKeytabFile) {
-    super(instance);
-    Config sysConfig = instance.getSysConfig().getConfig();
+  private HadoopKerberosKeytabAuthenticationPlugin(Config sysConfig, String loginUser, String
loginUserKeytabFile) {
+    super(null);
 
     _loginUser = loginUser;
     _loginUserKeytabFile = loginUserKeytabFile;
@@ -110,6 +112,11 @@ public class HadoopKerberosKeytabAuthenticationPlugin extends BaseIdlePluginImpl
 
   }
 
+  @Override
+  protected void shutDown() throws Exception {
+    log.info("Plugin shutdown: " + this);
+  }
+
   public String getLoginUser() {
     return _loginUser;
   }

http://git-wip-us.apache.org/repos/asf/incubator-gobblin/blob/3ab02b3f/gobblin-runtime-hadoop/src/test/java/org/apache/gobblin/runtime/instance/plugin/hadoop/TestHadoopKerberosKeytabAuthenticationPlugin.java
----------------------------------------------------------------------
diff --git a/gobblin-runtime-hadoop/src/test/java/org/apache/gobblin/runtime/instance/plugin/hadoop/TestHadoopKerberosKeytabAuthenticationPlugin.java
b/gobblin-runtime-hadoop/src/test/java/org/apache/gobblin/runtime/instance/plugin/hadoop/TestHadoopKerberosKeytabAuthenticationPlugin.java
index 92802c3..0a567a1 100644
--- a/gobblin-runtime-hadoop/src/test/java/org/apache/gobblin/runtime/instance/plugin/hadoop/TestHadoopKerberosKeytabAuthenticationPlugin.java
+++ b/gobblin-runtime-hadoop/src/test/java/org/apache/gobblin/runtime/instance/plugin/hadoop/TestHadoopKerberosKeytabAuthenticationPlugin.java
@@ -51,6 +51,20 @@ public class TestHadoopKerberosKeytabAuthenticationPlugin {
   }
 
   @Test
+  public void testConfigConstructor() {
+    final Config testConfig = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder()
+        .put("hadoop-inject.hadoop.security.authentication", "simple")
+        .put("gobblin.instance.hadoop.loginUser", "foo")
+        .put("gobblin.instance.hadoop.loginUserKeytabFile", "/tmp/bar")
+        .build());
+    HadoopKerberosKeytabAuthenticationPlugin plugin = (HadoopKerberosKeytabAuthenticationPlugin)
+        (new HadoopKerberosKeytabAuthenticationPlugin.ConfigBasedFactory()).createPlugin(testConfig);
+    Assert.assertEquals(plugin.getLoginUser(), "foo");
+    Assert.assertEquals(plugin.getLoginUserKeytabFile(), "/tmp/bar");
+    Assert.assertEquals(plugin.getHadoopConf().get("hadoop.security.authentication"), "simple");
+  }
+
+  @Test
   public void testMissingOptions() {
     final Config testConfig1 = ConfigFactory.parseMap(ImmutableMap.<String, Object>builder()
         .put("hadoop-inject.hadoop.security.authentication", "simple")


Mime
View raw message