hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prasan...@apache.org
Subject hive git commit: HIVE-13086: LLAP: Programmatically initialize log4j2 to print out the properties location (Prasanth Jayachandran reviewed by Gopal V)
Date Tue, 05 Apr 2016 18:27:32 GMT
Repository: hive
Updated Branches:
  refs/heads/branch-2.0 d8a28d209 -> 9c0549a48


HIVE-13086: LLAP: Programmatically initialize log4j2 to print out the properties location
(Prasanth Jayachandran reviewed by Gopal V)


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

Branch: refs/heads/branch-2.0
Commit: 9c0549a48ab3b5bdfa429dfbcfd986a52de5417e
Parents: d8a28d2
Author: Prasanth Jayachandran <j.prasanth.j@gmail.com>
Authored: Fri Feb 19 19:59:25 2016 -0600
Committer: Prasanth Jayachandran <prasanthj@apache.org>
Committed: Tue Apr 5 13:27:19 2016 -0500

----------------------------------------------------------------------
 .../hadoop/hive/llap/cli/LlapServiceDriver.java   |  5 ++++-
 .../hadoop/hive/llap/daemon/impl/LlapDaemon.java  | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/9c0549a4/llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java b/llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java
index 082d24c..ca0f85e 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/cli/LlapServiceDriver.java
@@ -26,6 +26,8 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Collection;
 
+import org.apache.hadoop.hive.llap.configuration.LlapDaemonConfiguration;
+import org.apache.hadoop.hive.llap.daemon.impl.LlapDaemon;
 import org.apache.hadoop.hive.llap.daemon.rpc.LlapDaemonProtocolProtos;
 import org.apache.hadoop.hive.llap.tezplugins.LlapTezUtils;
 import org.slf4j.Logger;
@@ -192,7 +194,8 @@ public class LlapServiceDriver {
       conf.set((String) props.getKey(), (String) props.getValue());
     }
 
-    URL logger = conf.getResource("llap-daemon-log4j2.properties");
+
+    URL logger = conf.getResource(LlapDaemon.LOG4j2_PROPERTIES_FILE);
 
     if (null == logger) {
       throw new Exception("Unable to find required config file: llap-daemon-log4j2.properties");

http://git-wip-us.apache.org/repos/asf/hive/blob/9c0549a4/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
----------------------------------------------------------------------
diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
index 37120d2..9b7c163 100644
--- a/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
+++ b/llap-server/src/java/org/apache/hadoop/hive/llap/daemon/impl/LlapDaemon.java
@@ -19,6 +19,7 @@ import java.lang.management.ManagementFactory;
 import java.lang.management.MemoryPoolMXBean;
 import java.lang.management.MemoryType;
 import java.net.InetSocketAddress;
+import java.net.URL;
 import java.util.Arrays;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
@@ -53,6 +54,7 @@ import org.apache.hadoop.util.ExitUtil;
 import org.apache.hadoop.util.JvmPauseMonitor;
 import org.apache.hadoop.util.StringUtils;
 import org.apache.hive.common.util.ShutdownHookManager;
+import org.apache.logging.log4j.core.config.Configurator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -64,6 +66,7 @@ public class LlapDaemon extends CompositeService implements ContainerRunner,
Lla
 
   private static final Logger LOG = LoggerFactory.getLogger(LlapDaemon.class);
 
+  public static final String LOG4j2_PROPERTIES_FILE = "llap-daemon-log4j2.properties";
   private final Configuration shuffleHandlerConf;
   private final LlapProtocolServerImpl server;
   private final ContainerRunnerImpl containerRunner;
@@ -93,6 +96,8 @@ public class LlapDaemon extends CompositeService implements ContainerRunner,
Lla
       int mngPort, int shufflePort) {
     super("LlapDaemon");
 
+    initializeLogging();
+
     printAsciiArt();
 
     Preconditions.checkArgument(numExecutors > 0);
@@ -194,6 +199,19 @@ public class LlapDaemon extends CompositeService implements ContainerRunner,
Lla
     addIfService(amReporter);
   }
 
+  private void initializeLogging() {
+    long start = System.currentTimeMillis();
+    URL llap_l4j2 = LlapDaemon.class.getClassLoader().getResource(LOG4j2_PROPERTIES_FILE);
+    if (llap_l4j2 != null) {
+      Configurator.initialize("LlapDaemonLog4j2", llap_l4j2.toString());
+      long end = System.currentTimeMillis();
+      LOG.info("LLAP daemon logging initialized from {} in {} ms", llap_l4j2, (end - start));
+    } else {
+      throw new RuntimeException("Log initialization failed." +
+          " Unable to locate " + LOG4j2_PROPERTIES_FILE + " file in classpath");
+    }
+  }
+
   public static long getTotalHeapSize() {
     // runtime.getMax() gives a very different number from the actual Xmx sizing.
     // you can iterate through the


Mime
View raw message