From 1d2f172db4b3cc99061ec9457491cd34c9bcfc53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=87=E7=BF=94?= Date: Tue, 28 Sep 2021 13:29:58 +0800 Subject: [PATCH] [KYUUBI #1067] Catch exception if logRoot is not exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUGFIX: #1067 This PR is just for version_1.3.0 ### _Why are the changes needed?_ ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [ ] [Run test](https://kyuubi.readthedocs.io/en/latest/develop_tools/testing.html#running-tests) locally before make a pull request Closes #1154 from zhang1002/branh-1.3_catch-exception. Closes #1067 2d9aaa5c [张宇翔] catch exception if logRoot is not exist Authored-by: 张宇翔 Signed-off-by: ulysses-you --- .../apache/kyuubi/engine/spark/SparkSQLEngine.scala | 10 +++++++--- .../kyuubi/engine/spark/events/EngineEvent.scala | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala index e5aa7294b..793b98d7c 100644 --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/SparkSQLEngine.scala @@ -65,8 +65,10 @@ case class SparkSQLEngine(spark: SparkSession) extends Serverable("SparkSQLEngin } override def stop(): Unit = { - eventLogging.onEvent( - engineStatus.copy(state = ServiceState.STOPPED.id, endTime = System.currentTimeMillis())) + if (!state.equals(ServiceState.LATENT)) { + eventLogging.onEvent( + engineStatus.copy(state = ServiceState.STOPPED.id, endTime = System.currentTimeMillis())) + } super.stop() } @@ -150,7 +152,9 @@ object SparkSQLEngine extends Logging { currentEngine.foreach { engine => val status = engine.engineStatus.copy(diagnostic = s"Error State SparkSQL Engine ${t.getMessage}") - EventLoggingService.onEvent(status) + if (!engine.getServiceState.equals(ServiceState.LATENT)) { + EventLoggingService.onEvent(status) + } error(status, t) engine.stop() } diff --git a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/events/EngineEvent.scala b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/events/EngineEvent.scala index b90b873d8..789b91bbc 100644 --- a/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/events/EngineEvent.scala +++ b/externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/kyuubi/engine/spark/events/EngineEvent.scala @@ -98,13 +98,18 @@ object EngineEvent { val webUrl = sc.getConf.getOption( "spark.org.apache.hadoop.yarn.server.webproxy.amfilter.AmIpFilter.param.PROXY_URI_BASES") .orElse(sc.uiWebUrl).getOrElse("") + val connectionUrl = if (engine.getServiceState.equals(ServiceState.LATENT)) { + null + } else { + engine.connectionUrl + } new EngineEvent( sc.applicationId, sc.applicationAttemptId, sc.appName, sc.sparkUser, engine.getConf.get(ENGINE_SHARE_LEVEL), - engine.connectionUrl, + connectionUrl, sc.master, sc.version, webUrl,