diff --git service/src/java/org/apache/hive/service/server/HiveServer2.java service/src/java/org/apache/hive/service/server/HiveServer2.java index 6184fdcc91..e8b37becd1 100644 --- service/src/java/org/apache/hive/service/server/HiveServer2.java +++ service/src/java/org/apache/hive/service/server/HiveServer2.java @@ -39,6 +39,7 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.GnuParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; @@ -1014,7 +1015,7 @@ public void startPrivilegeSynchonizer(HiveConf hiveConf) throws Exception { } } - private static void startHiveServer2() throws Throwable { + private static void startHiveServer2(CommandLine commandLine) throws Throwable { long attempts = 0, maxAttempts = 1; while (true) { LOG.info("Starting HiveServer2"); @@ -1032,6 +1033,14 @@ private static void startHiveServer2() throws Throwable { // avoid intial spike when using multiple HS2 scheduleClearDanglingScratchDir(hiveConf, new Random().nextInt(600)); + // Set hiveconf options + if (commandLine.hasOption("hiveconf")) { + Properties confProps = commandLine.getOptionProperties("hiveconf"); + for (String propKey : confProps.stringPropertyNames()) { + hiveConf.set(propKey, confProps.getProperty(propKey)); + } + } + server = new HiveServer2(); server.init(hiveConf); server.start(); @@ -1245,7 +1254,7 @@ ServerOptionsProcessorResponse parse(String[] argv) { System.exit(-1); } // Default executor, when no option is specified - return new ServerOptionsProcessorResponse(new StartOptionExecutor()); + return new ServerOptionsProcessorResponse(new StartOptionExecutor(commandLine)); } StringBuilder getDebugMessage() { @@ -1299,10 +1308,16 @@ public void execute() { * This is the default executor, when no option is specified. */ static class StartOptionExecutor implements ServerOptionsExecutor { + private final CommandLine commandLine; + + StartOptionExecutor(CommandLine commandLine) { + this.commandLine = commandLine; + } + @Override public void execute() { try { - startHiveServer2(); + startHiveServer2(commandLine); } catch (Throwable t) { LOG.error("Error starting HiveServer2", t); System.exit(-1);