You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2013/10/16 04:44:15 UTC
svn commit: r1532632 - in
/hive/trunk/service/src/java/org/apache/hive/service/server:
HiveServer2.java ServerOptionsProcessor.java
Author: thejas
Date: Wed Oct 16 02:44:15 2013
New Revision: 1532632
URL: http://svn.apache.org/r1532632
Log:
HIVE-5531: Hiverserver2 doesn't honor command line argument when initializing log4j (Shuaishuai Nie via Thejas Nair)
Modified:
hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java
hive/trunk/service/src/java/org/apache/hive/service/server/ServerOptionsProcessor.java
Modified: hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java?rev=1532632&r1=1532631&r2=1532632&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/server/HiveServer2.java Wed Oct 16 02:44:15 2013
@@ -82,25 +82,26 @@ public class HiveServer2 extends Composi
* @param args
*/
public static void main(String[] args) {
- //NOTE: It is critical to do this here so that log4j is reinitialized
- // before any of the other core hive classes are loaded
- try {
- LogUtils.initHiveLog4j();
- } catch (LogInitializationException e) {
- LOG.warn(e.getMessage());
- }
-
- HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG);
try {
ServerOptionsProcessor oproc = new ServerOptionsProcessor("hiveserver2");
if (!oproc.process(args)) {
- LOG.fatal("Error starting HiveServer2 with given arguments");
+ System.err.println("Error starting HiveServer2 with given arguments");
System.exit(-1);
}
+
+ //NOTE: It is critical to do this here so that log4j is reinitialized
+ // before any of the other core hive classes are loaded
+ LogUtils.initHiveLog4j();
+
+ HiveStringUtils.startupShutdownMessage(HiveServer2.class, args, LOG);
+ //log debug message from "oproc" after log4j initialize properly
+ LOG.debug(oproc.getDebugMessage().toString());
HiveConf hiveConf = new HiveConf();
HiveServer2 server = new HiveServer2();
server.init(hiveConf);
server.start();
+ } catch (LogInitializationException e) {
+ LOG.warn(e.getMessage());
} catch (Throwable t) {
LOG.fatal("Error starting HiveServer2", t);
System.exit(-1);
Modified: hive/trunk/service/src/java/org/apache/hive/service/server/ServerOptionsProcessor.java
URL: http://svn.apache.org/viewvc/hive/trunk/service/src/java/org/apache/hive/service/server/ServerOptionsProcessor.java?rev=1532632&r1=1532631&r2=1532632&view=diff
==============================================================================
--- hive/trunk/service/src/java/org/apache/hive/service/server/ServerOptionsProcessor.java (original)
+++ hive/trunk/service/src/java/org/apache/hive/service/server/ServerOptionsProcessor.java Wed Oct 16 02:44:15 2013
@@ -39,6 +39,7 @@ public class ServerOptionsProcessor {
private final Options options = new Options();
private org.apache.commons.cli.CommandLine commandLine;
private final String serverName;
+ private StringBuilder debugMessage = new StringBuilder();
@SuppressWarnings("static-access")
@@ -67,7 +68,8 @@ public class ServerOptionsProcessor {
//get hiveconf param values and set the System property values
Properties confProps = commandLine.getOptionProperties("hiveconf");
for (String propKey : confProps.stringPropertyNames()) {
- LOG.debug("Setting " + propKey + "=" + confProps.getProperty(propKey) + ";");
+ //save logging message for log4j output latter after log4j initialize properly
+ debugMessage.append("Setting " + propKey + "=" + confProps.getProperty(propKey) + ";\n");
System.setProperty(propKey, confProps.getProperty(propKey));
}
} catch (ParseException e) {
@@ -78,6 +80,10 @@ public class ServerOptionsProcessor {
return true;
}
+ public StringBuilder getDebugMessage() {
+ return debugMessage;
+ }
+
private void printUsage() {
new HelpFormatter().printHelp(serverName, options);
}