This is an automated email from the ASF dual-hosted git repository. viirya pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new d4dca2dabd8 [SPARK-41459][SQL] fix thrift server operation log output is empty d4dca2dabd8 is described below commit d4dca2dabd8761c0ce80194d4d1b7194b0b467aa Author: lixiang <lixiang....@aloudata.com> AuthorDate: Sat Dec 10 09:50:21 2022 -0800 [SPARK-41459][SQL] fix thrift server operation log output is empty ### What changes were proposed in this pull request? this PR change LogDivertAppender to fix operation log output ### Why are the changes needed? fix spark thrift server operation log output is empty ### Does this PR introduce _any_ user-facing change? 'No'. ### How was this patch tested? tests were not added, it was difficult to add. Closes #38993 from idealspark/SPARK-41459. Authored-by: lixiang <lixiang....@aloudata.com> Signed-off-by: Liang-Chi Hsieh <vii...@gmail.com> --- .../hive/service/cli/operation/LogDivertAppender.java | 15 +++++++++++---- .../hive/service/cli/operation/OperationManager.java | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/LogDivertAppender.java b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/LogDivertAppender.java index 8ee606be314..32cc42f008b 100644 --- a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/LogDivertAppender.java +++ b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/LogDivertAppender.java @@ -242,7 +242,7 @@ public class LogDivertAppender extends AbstractWriterAppender<WriterManager> { } /** This is where the log message will go to */ - private final CharArrayWriter writer = new CharArrayWriter(); + private final CharArrayWriter writer; private static StringLayout getLayout(boolean isVerbose, StringLayout lo) { if (isVerbose) { @@ -276,12 +276,19 @@ public class LogDivertAppender extends AbstractWriterAppender<WriterManager> { return getLayout(isVerbose, layout); } - public LogDivertAppender(OperationManager operationManager, + public static LogDivertAppender create(OperationManager operationManager, OperationLog.LoggingLevel loggingMode) { + CharArrayWriter writer = new CharArrayWriter(); + return new LogDivertAppender(operationManager, loggingMode, writer); + } + + private LogDivertAppender(OperationManager operationManager, + OperationLog.LoggingLevel loggingMode, CharArrayWriter writer) { super("LogDivertAppender", initLayout(loggingMode), null, false, true, Property.EMPTY_ARRAY, - new WriterManager(new CharArrayWriter(), "LogDivertAppender", + new WriterManager(writer, "LogDivertAppender", initLayout(loggingMode), true)); + this.writer = writer; this.isVerbose = (loggingMode == OperationLog.LoggingLevel.VERBOSE); this.operationManager = operationManager; addFilter(new NameFilter(loggingMode, operationManager)); @@ -301,7 +308,7 @@ public class LogDivertAppender extends AbstractWriterAppender<WriterManager> { isVerbose = isCurrModeVerbose; } } - + super.append(event); // That should've gone into our writer. Notify the LogContext. String logOutput = writer.toString(); diff --git a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/OperationManager.java b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/OperationManager.java index 6ee48186e7e..bb68c840496 100644 --- a/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/OperationManager.java +++ b/sql/hive-thriftserver/src/main/java/org/apache/hive/service/cli/operation/OperationManager.java @@ -82,7 +82,7 @@ public class OperationManager extends AbstractService { private void initOperationLogCapture(String loggingMode) { // Register another Appender (with the same layout) that talks to us. - Appender ap = new LogDivertAppender(this, OperationLog.getLoggingLevel(loggingMode)); + Appender ap = LogDivertAppender.create(this, OperationLog.getLoggingLevel(loggingMode)); ((org.apache.logging.log4j.core.Logger)org.apache.logging.log4j.LogManager.getRootLogger()).addAppender(ap); ap.start(); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org