FAQ
Repository: hive
Updated Branches:
   refs/heads/branch-1.0 a4eb78c82 -> 35914dbcd


HIVE-9622 - Getting NPE when trying to restart HS2 when metastore is configured to use org.apache.hadoop.hive.thrift.DBTokenStore (Aihua via Brock)


Project: http://git-wip-us.apache.org/repos/asf/hive/repo
Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/35914dbc
Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/35914dbc
Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/35914dbc

Branch: refs/heads/branch-1.0
Commit: 35914dbcd41bc9eb71e1f26e9a2b9ea2807c656b
Parents: a4eb78c
Author: Jason Dere <jdere@hortonworks.com>
Authored: Wed Aug 12 12:39:09 2015 -0700
Committer: Jason Dere <jdere@hortonworks.com>
Committed: Wed Aug 12 12:39:09 2015 -0700

----------------------------------------------------------------------
  .../hive/minikdc/TestHiveAuthFactory.java | 69 ++++++++++++++++++++
  .../hive/service/auth/HiveAuthFactory.java | 13 +++-
  2 files changed, 80 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/35914dbc/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java
----------------------------------------------------------------------
diff --git a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java
new file mode 100644
index 0000000..38601b8
--- /dev/null
+++ b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hive.minikdc;
+
+import org.junit.Assert;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
+import org.apache.hive.service.auth.HiveAuthFactory;
+import org.apache.hadoop.hive.thrift.DBTokenStore;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class TestHiveAuthFactory {
+ private static HiveConf hiveConf;
+ private static MiniHiveKdc miniHiveKdc = null;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ hiveConf = new HiveConf();
+ miniHiveKdc = MiniHiveKdc.getMiniHiveKdc(hiveConf);
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ }
+
+ /**
+ * Verify that delegation token manager is started with no exception
+ * @throws Exception
+ */
+ @Test
+ public void testStartTokenManager() throws Exception {
+ hiveConf.setVar(ConfVars.HIVE_SERVER2_AUTHENTICATION, HiveAuthFactory.AuthTypes.KERBEROS.name());
+ hiveConf.setVar(ConfVars.METASTORE_CLUSTER_DELEGATION_TOKEN_STORE_CLS, DBTokenStore.class.getName());
+ String principalName = miniHiveKdc.getFullHiveServicePrincipal();
+ System.out.println("Principal: " + principalName);
+
+ hiveConf.setVar(ConfVars.HIVE_SERVER2_KERBEROS_PRINCIPAL, principalName);
+ String keyTabFile = miniHiveKdc.getKeyTabFile(miniHiveKdc.getHiveServicePrincipal());
+ System.out.println("keyTabFile: " + keyTabFile);
+ Assert.assertNotNull(keyTabFile);
+ hiveConf.setVar(ConfVars.HIVE_SERVER2_KERBEROS_KEYTAB, keyTabFile);
+
+ System.out.println("rawStoreClassName =" + hiveConf.getVar(ConfVars.METASTORE_RAW_STORE_IMPL));
+
+ HiveAuthFactory authFactory = new HiveAuthFactory(hiveConf);
+ Assert.assertNotNull(authFactory);
+ // In Hive-1.0, HadoopThriftAuthBridge23 is using its parent class (20S) Server
+ Assert.assertEquals("org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge20S$Server$TUGIAssumingTransportFactory",
+ authFactory.getAuthTransFactory().getClass().getName());
+ }
+}

http://git-wip-us.apache.org/repos/asf/hive/blob/35914dbc/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java
----------------------------------------------------------------------
diff --git a/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java b/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java
index f8daf1a..406ab41 100644
--- a/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java
+++ b/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java
@@ -33,6 +33,9 @@ import javax.security.sasl.Sasl;

  import org.apache.hadoop.hive.conf.HiveConf;
  import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
+import org.apache.hadoop.hive.metastore.HiveMetaStore;
+import org.apache.hadoop.hive.metastore.HiveMetaStore.HMSHandler;
+import org.apache.hadoop.hive.metastore.api.MetaException;
  import org.apache.hadoop.hive.shims.HadoopShims.KerberosNameShim;
  import org.apache.hadoop.hive.shims.ShimLoader;
  import org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge;
@@ -102,8 +105,14 @@ public class HiveAuthFactory {
                conf.getVar(ConfVars.HIVE_SERVER2_KERBEROS_PRINCIPAL));
        // start delegation token manager
        try {
- saslServer.startDelegationTokenSecretManager(conf, null, ServerMode.HIVESERVER2);
- } catch (Exception e) {
+ HMSHandler baseHandler = new HiveMetaStore.HMSHandler(
+ "new db based metaserver", conf, true);
+ saslServer.startDelegationTokenSecretManager(conf, baseHandler.getMS(), ServerMode.HIVESERVER2);
+ }
+ catch (MetaException e) {
+ throw new TTransportException("Failed to start token manager", e);
+ }
+ catch (IOException e) {
          throw new TTransportException("Failed to start token manager", e);
        }
      } else {

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupcommits @
categorieshive, hadoop
postedAug 12, '15 at 7:41p
activeAug 12, '15 at 7:41p
posts1
users1
websitehive.apache.org

1 user in discussion

Jdere: 1 post

People

Translate

site design / logo © 2021 Grokbase