diff --git a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java index 4f8209a..5e83243 100644 --- a/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java +++ b/common/src/java/org/apache/hadoop/hive/conf/HiveConf.java @@ -3116,7 +3116,6 @@ private static String getSQLStdAuthDefaultWhiteListPattern() { ConfVars.OUTPUT_FILE_EXTENSION.varname, ConfVars.SHOW_JOB_FAIL_DEBUG_INFO.varname, ConfVars.TASKLOG_DEBUG_TIMEOUT.varname, - ConfVars.HIVEQUERYID.varname, }; /** diff --git a/service/src/java/org/apache/hive/service/cli/operation/ExecuteStatementOperation.java b/service/src/java/org/apache/hive/service/cli/operation/ExecuteStatementOperation.java index 3f2de10..b3d9b52 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/ExecuteStatementOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/ExecuteStatementOperation.java @@ -18,7 +18,6 @@ package org.apache.hive.service.cli.operation; import java.sql.SQLException; -import java.util.HashMap; import java.util.Map; import org.apache.hadoop.hive.ql.processors.CommandProcessor; @@ -29,13 +28,11 @@ public abstract class ExecuteStatementOperation extends Operation { protected String statement = null; - protected Map confOverlay = new HashMap(); public ExecuteStatementOperation(HiveSession parentSession, String statement, Map confOverlay, boolean runInBackground) { - super(parentSession, OperationType.EXECUTE_STATEMENT, runInBackground); + super(parentSession, confOverlay, OperationType.EXECUTE_STATEMENT, runInBackground); this.statement = statement; - setConfOverlay(confOverlay); } public String getStatement() { @@ -57,14 +54,4 @@ public static ExecuteStatementOperation newExecuteStatementOperation( } return new HiveCommandOperation(parentSession, statement, processor, confOverlay); } - - protected Map getConfOverlay() { - return confOverlay; - } - - protected void setConfOverlay(Map confOverlay) { - if (confOverlay != null) { - this.confOverlay = confOverlay; - } - } } diff --git a/service/src/java/org/apache/hive/service/cli/operation/Operation.java b/service/src/java/org/apache/hive/service/cli/operation/Operation.java index d13415e..5389101 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/Operation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/Operation.java @@ -21,11 +21,14 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; import java.util.Set; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import com.google.common.collect.Sets; + import org.apache.hadoop.hive.common.metrics.common.Metrics; import org.apache.hadoop.hive.common.metrics.common.MetricsConstant; import org.apache.hadoop.hive.common.metrics.common.MetricsFactory; @@ -50,8 +53,8 @@ public abstract class Operation { // Constants of the key strings for the log4j ThreadContext. - private static final String QUERYID = "QueryId"; - private static final String SESSIONID = "SessionId"; + public static final String MDC_SESSIONID = "sessionId"; + public static final String MDC_QUERYID = "queryId"; protected final HiveSession parentSession; private OperationState state = OperationState.INITIALIZED; @@ -67,6 +70,7 @@ protected volatile Future backgroundHandle; protected OperationLog operationLog; protected boolean isOperationLogEnabled; + protected Map confOverlay = new HashMap(); private long operationTimeout; private long lastAccessTime; @@ -75,7 +79,14 @@ EnumSet.of(FetchOrientation.FETCH_NEXT,FetchOrientation.FETCH_FIRST); protected Operation(HiveSession parentSession, OperationType opType, boolean runInBackground) { + this(parentSession, null, opType, runInBackground); + } + + protected Operation(HiveSession parentSession, Map confOverlay, OperationType opType, boolean runInBackground) { this.parentSession = parentSession; + if (confOverlay != null) { + this.confOverlay = confOverlay; + } this.runAsync = runInBackground; this.opHandle = new OperationHandle(opType, parentSession.getProtocolVersion()); lastAccessTime = System.currentTimeMillis(); @@ -258,8 +269,8 @@ protected void beforeRun() { * Register logging context so that Log4J can print QueryId and/or SessionId for each message */ protected void registerLoggingContext() { - ThreadContext.put(QUERYID, SessionState.get().getQueryId()); - ThreadContext.put(SESSIONID, SessionState.get().getSessionId()); + ThreadContext.put(MDC_SESSIONID, SessionState.get().getSessionId()); + ThreadContext.put(MDC_QUERYID, confOverlay.get(HiveConf.ConfVars.HIVEQUERYID.varname)); } /** diff --git a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java index 8b42265..1331a99 100644 --- a/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java +++ b/service/src/java/org/apache/hive/service/cli/operation/SQLOperation.java @@ -466,12 +466,12 @@ private SerDe getSerDe() throws SQLException { */ private HiveConf getConfigForOperation() throws HiveSQLException { HiveConf sqlOperationConf = getParentSession().getHiveConf(); - if (!getConfOverlay().isEmpty() || shouldRunAsync()) { + if (!confOverlay.isEmpty() || shouldRunAsync()) { // clone the partent session config for this query sqlOperationConf = new HiveConf(sqlOperationConf); // apply overlay query specific settings, if any - for (Map.Entry confEntry : getConfOverlay().entrySet()) { + for (Map.Entry confEntry : confOverlay.entrySet()) { try { sqlOperationConf.verifyAndSet(confEntry.getKey(), confEntry.getValue()); } catch (IllegalArgumentException e) { diff --git a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java index 2d784f0..a14908b 100644 --- a/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java +++ b/service/src/java/org/apache/hive/service/cli/session/HiveSessionImpl.java @@ -443,7 +443,6 @@ private OperationHandle executeStatementInternal(String statement, Map