From e533d34aeda6376235b566337047f75f0a83c746 Mon Sep 17 00:00:00 2001 From: Kousuke Saruta Date: Sun, 14 Jun 2020 14:17:16 +0900 Subject: [PATCH] [SPARK-31632][CORE][WEBUI][FOLLOWUP] Enrich the exception message when application summary is unavailable ### What changes were proposed in this pull request? This PR enriches the exception message when application summary is not available. #28444 covers the case when application information is not available but the case application summary is not available is not covered. ### Why are the changes needed? To complement #28444 . ### Does this PR introduce _any_ user-facing change? Yes. Before this change, we can get the following error message when we access to `/jobs` if application summary is not available. no-such-element-exception-error-message After this change, we can get the following error message. It's like #28444 does. enriched-errorm-message ### How was this patch tested? I checked with the following procedure. 1. Set breakpoint in the line of `kvstore.write(appSummary)` in `AppStatusListener#onStartApplicatin`. Only the thread reaching this line should be suspended. 2. Start spark-shell and wait few seconds. 3. Access to `/jobs` Closes #28820 from sarutak/fix-no-such-element. Authored-by: Kousuke Saruta Signed-off-by: HyukjinKwon (cherry picked from commit c2e5012a0a76734acf94b8716ee293ba2f58ccb4) Signed-off-by: HyukjinKwon --- .../scala/org/apache/spark/status/AppStatusStore.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala b/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala index d7f5ac8d3dbc9..a4fa256b18adb 100644 --- a/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala +++ b/core/src/main/scala/org/apache/spark/status/AppStatusStore.scala @@ -519,7 +519,13 @@ private[spark] class AppStatusStore( } def appSummary(): AppSummary = { - store.read(classOf[AppSummary], classOf[AppSummary].getName()) + try { + store.read(classOf[AppSummary], classOf[AppSummary].getName()) + } catch { + case _: NoSuchElementException => + throw new NoSuchElementException("Failed to get the application summary. " + + "If you are starting up Spark, please wait a while until it's ready.") + } } def close(): Unit = {