[SPARK-22496][SQL] thrift server adds operation logs

## What changes were proposed in this pull request?
since hive 2.0+  upgrades log4j to log4j2,a lot of [changes](https://issues.apache.org/jira/browse/HIVE-11304) are made working on it.
as spark is not to ready to update its inner hive version(1.2.1) , so I manage to make little changes.
the function registerCurrentOperationLog  is moved from SQLOperstion to its parent class ExecuteStatementOperation so spark can use it.

## How was this patch tested?
manual test

Author: zouchenjun <zouchenjun@youzan.com>

Closes #19721 from ChenjunZou/operation-log.
This commit is contained in:
zouchenjun 2017-12-10 20:36:14 -08:00 committed by gatorsmile
parent ab1b6ee731
commit 4289ac9d8d
3 changed files with 14 additions and 12 deletions

View file

@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.hadoop.hive.ql.processors.CommandProcessor;
import org.apache.hadoop.hive.ql.processors.CommandProcessorFactory;
import org.apache.hadoop.hive.ql.session.OperationLog;
import org.apache.hive.service.cli.HiveSQLException;
import org.apache.hive.service.cli.OperationType;
import org.apache.hive.service.cli.session.HiveSession;
@ -67,4 +68,16 @@ public abstract class ExecuteStatementOperation extends Operation {
this.confOverlay = confOverlay;
}
}
protected void registerCurrentOperationLog() {
if (isOperationLogEnabled) {
if (operationLog == null) {
LOG.warn("Failed to get current OperationLog object of Operation: " +
getHandle().getHandleIdentifier());
isOperationLogEnabled = false;
return;
}
OperationLog.setCurrentOperationLog(operationLog);
}
}
}

View file

@ -274,18 +274,6 @@ public class SQLOperation extends ExecuteStatementOperation {
}
}
private void registerCurrentOperationLog() {
if (isOperationLogEnabled) {
if (operationLog == null) {
LOG.warn("Failed to get current OperationLog object of Operation: " +
getHandle().getHandleIdentifier());
isOperationLogEnabled = false;
return;
}
OperationLog.setCurrentOperationLog(operationLog);
}
}
private void cleanup(OperationState state) throws HiveSQLException {
setState(state);
if (shouldRunAsync()) {

View file

@ -170,6 +170,7 @@ private[hive] class SparkExecuteStatementOperation(
override def run(): Unit = {
val doAsAction = new PrivilegedExceptionAction[Unit]() {
override def run(): Unit = {
registerCurrentOperationLog()
try {
execute()
} catch {