Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/20474#discussion_r166409473
--- Diff:
core/src/main/scala/org/apache/spark/status/api/v1/OneApplicationResource.scala
---
@@ -51,6 +51,31 @@ private[v1] class AbstractApplicationResource extends
BaseAppResource {
@Path("executors")
def executorList(): Seq[ExecutorSummary] =
withUI(_.store.executorList(true))
+ @GET
+ @Path("executors/{executorId}/threads")
+ def threadDump(@PathParam("executorId") executorId: String): Response =
withUI { ui =>
+ def isAllDigits(x: String) = x.forall(Character.isDigit)
+
+ if (executorId != SparkContext.DRIVER_IDENTIFIER &&
!isAllDigits(executorId)) {
+ throw new BadParameterException(
+ s"Invalid executorId: neither '${SparkContext.DRIVER_IDENTIFIER}'
nor number.")
+ }
+
+ val safeSparkContext = ui.sc.getOrElse {
+ throw new ServiceUnavailable("Thread dumps not available through the
history server.")
+ }
+
+ ui.store.asOption(ui.store.executorSummary(executorId)) match {
+ case Some(executorSummary) if executorSummary.isActive =>
+ val safeThreadDump =
safeSparkContext.getExecutorThreadDump(executorId).getOrElse {
+ throw new NotFoundException("No thread dump is available.")
+ }
+ return Response.ok(safeThreadDump).build()
+ case Some(_) => throw new BadParameterException("Executor is already
dead.")
--- End diff --
nit: "Executor is not active."
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]