All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.spark.deploy.master.ui.ApplicationPage.scala Maven / Gradle / Ivy

There is a newer version: 2.4.8
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.spark.deploy.master.ui

import javax.servlet.http.HttpServletRequest

import scala.xml.Node

import org.apache.spark.deploy.DeployMessages.{MasterStateResponse, RequestMasterState}
import org.apache.spark.deploy.ExecutorState
import org.apache.spark.deploy.master.ExecutorDesc
import org.apache.spark.ui.{ToolTips, UIUtils, WebUIPage}
import org.apache.spark.util.Utils

private[ui] class ApplicationPage(parent: MasterWebUI) extends WebUIPage("app") {

  private val master = parent.masterEndpointRef

  /** Executor details for a particular application */
  def render(request: HttpServletRequest): Seq[Node] = {
    // stripXSS is called first to remove suspicious characters used in XSS attacks
    val appId = UIUtils.stripXSS(request.getParameter("appId"))
    val state = master.askSync[MasterStateResponse](RequestMasterState)
    val app = state.activeApps.find(_.id == appId)
      .getOrElse(state.completedApps.find(_.id == appId).orNull)
    if (app == null) {
      val msg = 
No running application with ID {appId}
return UIUtils.basicSparkPage(request, msg, "Not Found") } val executorHeaders = Seq("ExecutorID", "Worker", "Cores", "Memory", "State", "Logs") val allExecutors = (app.executors.values ++ app.removedExecutors).toSet.toSeq // This includes executors that are either still running or have exited cleanly val executors = allExecutors.filter { exec => !ExecutorState.isFinished(exec.state) || exec.state == ExecutorState.EXITED } val removedExecutors = allExecutors.diff(executors) val executorsTable = UIUtils.listingTable(executorHeaders, executorRow, executors) val removedExecutorsTable = UIUtils.listingTable(executorHeaders, executorRow, removedExecutors) val content =
  • ID: {app.id}
  • Name: {app.desc.name}
  • User: {app.desc.user}
  • Cores: { if (app.desc.maxCores.isEmpty) { "Unlimited (%s granted)".format(app.coresGranted) } else { "%s (%s granted, %s left)".format( app.desc.maxCores.get, app.coresGranted, app.coresLeft) } }
  • Executor Limit: { if (app.executorLimit == Int.MaxValue) "Unlimited" else app.executorLimit } ({app.executors.size} granted)
  • Executor Memory: {Utils.megabytesToString(app.desc.memoryPerExecutorMB)}
  • Submit Date: {UIUtils.formatDate(app.submitDate)}
  • State: {app.state}
  • { if (!app.isFinished) {
  • Application Detail UI
  • } }

Executor Summary ({allExecutors.length})

{executorsTable}
{ if (removedExecutors.nonEmpty) {

Removed Executors ({removedExecutors.length})

++
{removedExecutorsTable}
} }
; UIUtils.basicSparkPage(request, content, "Application: " + app.desc.name) } private def executorRow(executor: ExecutorDesc): Seq[Node] = { val workerUrlRef = UIUtils.makeHref(parent.master.reverseProxy, executor.worker.id, executor.worker.webUiAddress) {executor.id} {executor.worker.id} {executor.cores} {executor.memory} {executor.state} stdout stderr } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy