FAQ
Author: hashutosh
Date: Fri Aug 2 04:58:34 2013
New Revision: 1509544

URL: http://svn.apache.org/r1509544
Log:
HIVE-4638 : Thread local PerfLog can get shared by multiple hiveserver2 sessions (Prasad Mujumdar via Ashutosh Chauhan)

Modified:
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java
     hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java?rev=1509544&r1=1509543&r2=1509544&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/log/PerfLogger.java Fri Aug 2 04:58:34 2013
@@ -23,11 +23,8 @@ import java.util.Map;

  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
-import org.apache.hadoop.hive.conf.HiveConf;
-import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
  import org.apache.hadoop.hive.ql.QueryPlan;
  import org.apache.hadoop.hive.ql.session.SessionState;
-import org.apache.hadoop.util.ReflectionUtils;

  /**
   * PerfLogger.
@@ -55,7 +52,7 @@ public class PerfLogger {

    static final private Log LOG = LogFactory.getLog(PerfLogger.class.getName());

- protected PerfLogger() {
+ public PerfLogger() {
      // Use getPerfLogger to get an instance of PerfLogger
    }

@@ -68,26 +65,17 @@ public class PerfLogger {
     *
     * Use resetPerfLogger to require a new instance. Useful at the beginning of execution.
     *
- * @return Tries to return an instance of the class whose name is configured in
- * hive.exec.perf.logger, but if it can't it just returns an instance of
- * the base PerfLogger class
+ * @return Session perflogger if there's a sessionstate, otherwise return the thread local instance
     */
    public static PerfLogger getPerfLogger(boolean resetPerfLogger) {
- if (perfLogger.get() == null || resetPerfLogger) {
- if (SessionState.get() == null) {
+ if (SessionState.get() == null) {
+ if (perfLogger.get() == null || resetPerfLogger) {
          perfLogger.set(new PerfLogger());
- } else {
- HiveConf conf = SessionState.get().getConf();
- try {
- perfLogger.set((PerfLogger) ReflectionUtils.newInstance(conf.getClassByName(
- conf.getVar(ConfVars.HIVE_PERF_LOGGER)), conf));
- } catch (ClassNotFoundException e) {
- LOG.error("Performance Logger Class not found:" + e.getMessage());
- perfLogger.set(new PerfLogger());
- }
        }
+ return perfLogger.get();
+ } else {
+ return SessionState.get().getPerfLogger(resetPerfLogger);
      }
- return perfLogger.get();
    }

    /**

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java?rev=1509544&r1=1509543&r2=1509544&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java Fri Aug 2 04:58:34 2013
@@ -40,15 +40,18 @@ import org.apache.hadoop.conf.Configurat
  import org.apache.hadoop.fs.FileSystem;
  import org.apache.hadoop.fs.Path;
  import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
  import org.apache.hadoop.hive.ql.MapRedStats;
  import org.apache.hadoop.hive.ql.exec.Utilities;
  import org.apache.hadoop.hive.ql.history.HiveHistory;
+import org.apache.hadoop.hive.ql.log.PerfLogger;
  import org.apache.hadoop.hive.ql.metadata.HiveException;
  import org.apache.hadoop.hive.ql.metadata.HiveUtils;
  import org.apache.hadoop.hive.ql.plan.HiveOperation;
  import org.apache.hadoop.hive.ql.security.HiveAuthenticationProvider;
  import org.apache.hadoop.hive.ql.security.authorization.HiveAuthorizationProvider;
  import org.apache.hadoop.hive.ql.util.DosToUnix;
+import org.apache.hadoop.util.ReflectionUtils;

  /**
   * SessionState encapsulates common data associated with a session.
@@ -133,6 +136,7 @@ public class SessionState {
     */
    LineageState ls;

+ private PerfLogger perfLogger;
    /**
     * Get the lineage state stored in this session.
     *
@@ -746,4 +750,25 @@ public class SessionState {
        LOG.info("Error removing session resource dir " + resourceDir, e);
      }
    }
+
+ /**
+ * @param resetPerfLogger
+ * @return Tries to return an instance of the class whose name is configured in
+ * hive.exec.perf.logger, but if it can't it just returns an instance of
+ * the base PerfLogger class
+
+ */
+ public PerfLogger getPerfLogger(boolean resetPerfLogger) {
+ if ((perfLogger == null) || resetPerfLogger) {
+ try {
+ perfLogger = (PerfLogger) ReflectionUtils.newInstance(conf.getClassByName(
+ conf.getVar(ConfVars.HIVE_PERF_LOGGER)), conf);
+ } catch (ClassNotFoundException e) {
+ LOG.error("Performance Logger Class not found:" + e.getMessage());
+ perfLogger = new PerfLogger();
+ }
+ }
+ return perfLogger;
+ }
+
  }

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcommits @
categorieshive, hadoop
postedAug 2, '13 at 4:59a
activeAug 2, '13 at 4:59a
posts1
users1
websitehive.apache.org

1 user in discussion

Hashutosh: 1 post

People

Translate

site design / logo © 2021 Grokbase