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 32c791f..6fa464e 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,7 @@ import java.util.Properties; 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.apache.tez.dag.api.TezConfiguration; @@ -222,7 +223,7 @@ private void run(String[] args) throws Exception { - 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"); 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 e066742..5e73663 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.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; @@ -57,6 +58,7 @@ 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; @@ -68,6 +70,7 @@ 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; @@ -110,6 +113,8 @@ public LlapDaemon(Configuration daemonConf, int numExecutors, long executorMemor Preconditions.checkArgument(shufflePort == 0 || (shufflePort > 1024 && shufflePort < 65536), "Shuffle Port must be betwee 1024 and 65535, or 0 for automatic selection"); + initializeLogging(); + this.maxJvmMemory = getTotalHeapSize(); this.llapIoEnabled = ioEnabled; this.executorMemoryPerInstance = executorMemoryBytes; @@ -205,6 +210,19 @@ public LlapDaemon(Configuration daemonConf, int numExecutors, long executorMemor 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