Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C1AD017D7F for ; Thu, 12 Feb 2015 16:15:26 +0000 (UTC) Received: (qmail 41696 invoked by uid 500); 12 Feb 2015 16:15:15 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 41629 invoked by uid 500); 12 Feb 2015 16:15:15 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 41530 invoked by uid 99); 12 Feb 2015 16:15:14 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2015 16:15:14 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 7DAC1AC010E for ; Thu, 12 Feb 2015 16:15:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1659302 - in /hive/trunk: itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java Date: Thu, 12 Feb 2015 16:15:14 -0000 To: commits@hive.apache.org From: brock@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150212161514.7DAC1AC010E@hades.apache.org> Author: brock Date: Thu Feb 12 16:15:14 2015 New Revision: 1659302 URL: http://svn.apache.org/r1659302 Log: HIVE-9622 - Getting NPE when trying to restart HS2 when metastore is configured to use org.apache.hadoop.hive.thrift.DBTokenStore (Aihua via Brock) Added: hive/trunk/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java Modified: hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java Added: hive/trunk/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java?rev=1659302&view=auto ============================================================================== --- hive/trunk/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java (added) +++ hive/trunk/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestHiveAuthFactory.java Thu Feb 12 16:15:14 2015 @@ -0,0 +1,66 @@ +/** + * 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.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.getAuthName()); + 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); + Assert.assertEquals("org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge$Server$TUGIAssumingTransportFactory", + authFactory.getAuthTransFactory().getClass().getName()); + } +} Modified: hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java?rev=1659302&r1=1659301&r2=1659302&view=diff ============================================================================== --- hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java (original) +++ hive/trunk/service/src/java/org/apache/hive/service/auth/HiveAuthFactory.java Thu Feb 12 16:15:14 2015 @@ -18,7 +18,6 @@ package org.apache.hive.service.auth; import java.io.IOException; -import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.UnknownHostException; import java.util.ArrayList; @@ -33,6 +32,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; @@ -108,8 +110,11 @@ public class HiveAuthFactory { conf.getVar(ConfVars.HIVE_SERVER2_KERBEROS_PRINCIPAL)); // start delegation token manager try { - saslServer.startDelegationTokenSecretManager(conf, null, ServerMode.HIVESERVER2); - } catch (IOException e) { + HMSHandler baseHandler = new HiveMetaStore.HMSHandler( + "new db based metaserver", conf, true); + saslServer.startDelegationTokenSecretManager(conf, baseHandler.getMS(), ServerMode.HIVESERVER2); + } + catch (MetaException|IOException e) { throw new TTransportException("Failed to start token manager", e); } }