You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by br...@apache.org on 2014/09/22 23:19:20 UTC
svn commit: r1626898 - in /hive/trunk:
common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
Author: brock
Date: Mon Sep 22 21:19:20 2014
New Revision: 1626898
URL: http://svn.apache.org/r1626898
Log:
HIVE-8138 - Global Init file should allow specifying file name not only directory (Brock reviewed by Szehon)
Modified:
hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
hive/trunk/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java?rev=1626898&r1=1626897&r2=1626898&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java Mon Sep 22 21:19:20 2014
@@ -1503,8 +1503,8 @@ public class HiveConf extends Configurat
"The parent node in ZooKeeper used by HiveServer2 when supporting dynamic service discovery."),
// HiveServer2 global init file location
HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION("hive.server2.global.init.file.location", "${env:HIVE_CONF_DIR}",
- "The location of HS2 global init file (.hiverc).\n" +
- "If the property is reset, the value must be a valid path where the init file is located."),
+ "Either the location of a HS2 global init file or a directory containing a .hiverc file. If the \n" +
+ "property is set, the value must be a valid path to an init file or directory where the init file is located."),
HIVE_SERVER2_TRANSPORT_MODE("hive.server2.transport.mode", "binary", new StringSet("binary", "http"),
"Transport mode of HiveServer2."),
HIVE_SERVER2_THRIFT_BIND_HOST("hive.server2.thrift.bind.host", "",
Modified: hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java?rev=1626898&r1=1626897&r2=1626898&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java Mon Sep 22 21:19:20 2014
@@ -166,15 +166,20 @@ public class HiveSessionImpl implements
IHiveFileProcessor processor = new GlobalHivercFileProcessor();
try {
- if (hiveConf.getVar(ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION) != null) {
- String hiverc = hiveConf.getVar(ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION)
- + File.separator + SessionManager.HIVERCFILE;
- if (new File(hiverc).exists()) {
- LOG.info("Running global init file: " + hiverc);
- int rc = processor.processFile(hiverc);
+ String hiverc = hiveConf.getVar(ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION);
+ if (hiverc != null) {
+ File hivercFile = new File(hiverc);
+ if (hivercFile.isDirectory()) {
+ hivercFile = new File(hivercFile, SessionManager.HIVERCFILE);
+ }
+ if (hivercFile.isFile()) {
+ LOG.info("Running global init file: " + hivercFile);
+ int rc = processor.processFile(hivercFile.getAbsolutePath());
if (rc != 0) {
- LOG.warn("Failed on initializing global .hiverc file");
+ LOG.error("Failed on initializing global .hiverc file");
}
+ } else {
+ LOG.debug("Global init file " + hivercFile + " does not exist");
}
}
} catch (IOException e) {
Modified: hive/trunk/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java?rev=1626898&r1=1626897&r2=1626898&view=diff
==============================================================================
--- hive/trunk/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java (original)
+++ hive/trunk/service/src/test/org/apache/hive/service/cli/session/TestSessionGlobalInitFile.java Mon Sep 22 21:19:20 2014
@@ -44,6 +44,7 @@ public class TestSessionGlobalInitFile e
private ThriftCLIServiceClient client;
private File initFile;
private String tmpDir;
+ private HiveConf hiveConf;
/**
* This class is almost the same as EmbeddedThriftBinaryCLIService,
@@ -86,7 +87,7 @@ public class TestSessionGlobalInitFile e
FileUtils.writeLines(initFile, Arrays.asList(fileContent));
// set up service and client
- HiveConf hiveConf = new HiveConf();
+ hiveConf = new HiveConf();
hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION,
initFile.getParentFile().getAbsolutePath());
service = new FakeEmbeddedThriftBinaryCLIService(hiveConf);
@@ -102,11 +103,26 @@ public class TestSessionGlobalInitFile e
@Test
public void testSessionGlobalInitFile() throws Exception {
- /**
- * create session, and fetch the property set in global init file. Test if
- * the global init file .hiverc is loaded correctly by checking the expected
- * setting property.
- */
+ File tmpInitFile = new File(initFile.getParent(), "hiverc");
+ Assert.assertTrue("Failed to rename " + initFile + " to " + tmpInitFile,
+ initFile.renameTo(tmpInitFile));
+ initFile = tmpInitFile;
+ hiveConf.setVar(HiveConf.ConfVars.HIVE_SERVER2_GLOBAL_INIT_FILE_LOCATION,
+ initFile.getAbsolutePath());
+ doTestSessionGlobalInitFile();
+ }
+
+ @Test
+ public void testSessionGlobalInitDir() throws Exception {
+ doTestSessionGlobalInitFile();
+ }
+
+ /**
+ * create session, and fetch the property set in global init file. Test if
+ * the global init file .hiverc is loaded correctly by checking the expected
+ * setting property.
+ */
+ private void doTestSessionGlobalInitFile() throws Exception {
SessionHandle sessionHandle = client.openSession(null, null, null);
verifyInitProperty("a", "1", sessionHandle);