org.apache.spark.ui.SparkUI Scala Examples
The following examples show how to use org.apache.spark.ui.SparkUI.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: JobsTab.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") { val sc = parent.sc val killEnabled = parent.killEnabled val jobProgresslistener = parent.jobProgressListener val executorListener = parent.executorsListener val operationGraphListener = parent.operationGraphListener def isFairScheduler: Boolean = jobProgresslistener.schedulingMode.exists(_ == SchedulingMode.FAIR) attachPage(new AllJobsPage(this)) attachPage(new JobPage(this)) }
Example 2
Source File: StagesTab.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages") { val sc = parent.sc val conf = parent.conf val killEnabled = parent.killEnabled val progressListener = parent.jobProgressListener val operationGraphListener = parent.operationGraphListener attachPage(new AllStagesPage(this)) attachPage(new StagePage(this)) attachPage(new PoolPage(this)) def isFairScheduler: Boolean = progressListener.schedulingMode.exists(_ == SchedulingMode.FAIR) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val killFlag = Option(request.getParameter("terminate")).getOrElse("false").toBoolean val stageId = Option(request.getParameter("id")).getOrElse("-1").toInt if (stageId >= 0 && killFlag && progressListener.activeStages.contains(stageId)) { sc.get.cancelStage(stageId) } // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. //在这里快速暂停给Spark时间杀死stage,所以它在刷新后显示为被杀。 // 请注意,这将阻止服务线程,所以时间应该被限制在持续时间。 Thread.sleep(100) } } }
Example 3
Source File: WorkerWebUI.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.{Logging, SparkConf} import org.apache.spark.deploy.worker.Worker import org.apache.spark.deploy.worker.ui.WorkerWebUI._ import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr)) } } private[worker] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR val DEFAULT_RETAINED_DRIVERS = 1000 val DEFAULT_RETAINED_EXECUTORS = 1000 }
Example 4
Source File: MasterWebUI.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.master.ui import org.apache.spark.Logging import org.apache.spark.deploy.master.Master import org.apache.spark.status.api.v1.{ApiRootResource, ApplicationsListResource, ApplicationInfo, UIRoot} import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ def detachSparkUI(ui: SparkUI) { assert(serverInfo.isDefined, "Master UI must be bound to a server before detaching SparkUIs") ui.getHandlers.foreach(detachHandler) } def getApplicationInfoList: Iterator[ApplicationInfo] = { val state = masterPage.getMasterState val activeApps = state.activeApps.sortBy(_.startTime).reverse val completedApps = state.completedApps.sortBy(_.endTime).reverse activeApps.iterator.map { ApplicationsListResource.convertApplicationInfo(_, false) } ++ completedApps.iterator.map { ApplicationsListResource.convertApplicationInfo(_, true) } } def getSparkUI(appId: String): Option[SparkUI] = { val state = masterPage.getMasterState val activeApps = state.activeApps.sortBy(_.startTime).reverse val completedApps = state.completedApps.sortBy(_.endTime).reverse (activeApps ++ completedApps).find { _.id == appId }.flatMap { master.rebuildSparkUI } } } private[master] object MasterWebUI { private val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 5
Source File: MesosClusterUI.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.mesos.ui import org.apache.spark.scheduler.cluster.mesos.MesosClusterScheduler import org.apache.spark.{SecurityManager, SparkConf} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.ui.{SparkUI, WebUI} private[spark] class MesosClusterUI( securityManager: SecurityManager, port: Int, conf: SparkConf, dispatcherPublicAddress: String, val scheduler: MesosClusterScheduler) extends WebUI(securityManager, port, conf) { initialize() def activeWebUiUrl: String = "http://" + dispatcherPublicAddress + ":" + boundPort override def initialize() { attachPage(new MesosClusterPage(this)) attachPage(new DriverPage(this)) attachHandler(createStaticHandler(MesosClusterUI.STATIC_RESOURCE_DIR, "/static")) } } private object MesosClusterUI { val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 6
Source File: ExecutorListResource.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class ExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. //以下代码应由“监听器”保护,以确保在查询状态之前不会删除执行程序,参见SPARK-12784。 val storageStatusList = listener.storageStatusList (0 until storageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId) } } } }
Example 7
Source File: OneJobResource.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{PathParam, GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.UIData.JobUIData //注解@Produces用于定义方法的响应实体的数据类型,可以定义一个或多个 @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class OneJobResource(ui: SparkUI) { @GET def oneJob(@PathParam("jobId") jobId: Int): JobData = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val jobOpt = statusToJobs.map {_._2} .flatten.find { jobInfo => jobInfo.jobId == jobId} jobOpt.map { job => AllJobsResource.convertJobData(job, ui.jobProgressListener, false) }.getOrElse { throw new NotFoundException("unknown job: " + jobId) } } }
Example 8
Source File: OneRDDResource.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{PathParam, GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI //注解@Produces用于定义方法的响应实体的数据类型,可以定义一个或多个 @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class OneRDDResource(ui: SparkUI) { @GET def rddData(@PathParam("rddId") rddId: Int): RDDStorageInfo = { AllRDDResource.getRDDStorageInfo(rddId, ui.storageListener, true).getOrElse( throw new NotFoundException(s"no rdd found w/ id $rddId") ) } }
Example 9
Source File: AllRDDResource.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.storage.{RDDInfo, StorageStatus, StorageUtils} import org.apache.spark.ui.SparkUI import org.apache.spark.ui.storage.StorageListener @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllRDDResource(ui: SparkUI) { @GET def rddList(): Seq[RDDStorageInfo] = { val storageStatusList = ui.storageListener.storageStatusList val rddInfos = ui.storageListener.rddInfoList rddInfos.map{rddInfo => AllRDDResource.getRDDStorageInfo(rddInfo.id, rddInfo, storageStatusList, includeDetails = false) } } } private[spark] object AllRDDResource { def getRDDStorageInfo( rddId: Int, listener: StorageListener, includeDetails: Boolean): Option[RDDStorageInfo] = { val storageStatusList = listener.storageStatusList listener.rddInfoList.find { _.id == rddId }.map { rddInfo => getRDDStorageInfo(rddId, rddInfo, storageStatusList, includeDetails) } } def getRDDStorageInfo( rddId: Int, rddInfo: RDDInfo, storageStatusList: Seq[StorageStatus], includeDetails: Boolean): RDDStorageInfo = { val workers = storageStatusList.map { (rddId, _) } val blockLocations = StorageUtils.getRddBlockLocations(rddId, storageStatusList) val blocks = storageStatusList .flatMap { _.rddBlocksById(rddId) } .sortWith { _._1.name < _._1.name } .map { case (blockId, status) => (blockId, status, blockLocations.get(blockId).getOrElse(Seq[String]("Unknown"))) } val dataDistribution = if (includeDetails) { Some(storageStatusList.map { status => new RDDDataDistribution( address = status.blockManagerId.hostPort, memoryUsed = status.memUsedByRdd(rddId), memoryRemaining = status.memRemaining, diskUsed = status.diskUsedByRdd(rddId) ) } ) } else { None } val partitions = if (includeDetails) { Some(blocks.map { case (id, block, locations) => new RDDPartitionInfo( blockName = id.name, storageLevel = block.storageLevel.description, memoryUsed = block.memSize, diskUsed = block.diskSize, executors = locations ) } ) } else { None } new RDDStorageInfo( id = rddId, name = rddInfo.name, numPartitions = rddInfo.numPartitions, numCachedPartitions = rddInfo.numCachedPartitions, storageLevel = rddInfo.storageLevel.description, memoryUsed = rddInfo.memSize, diskUsed = rddInfo.diskSize, dataDistribution = dataDistribution, partitions = partitions ) } }
Example 10
Source File: AllJobsResource.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.{Arrays, Date, List => JList} import javax.ws.rs._ import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.JobProgressListener import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllJobsResource(ui: SparkUI) { @GET def jobsList(@QueryParam("status") statuses: JList[JobExecutionStatus]): Seq[JobData] = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val adjStatuses: JList[JobExecutionStatus] = { if (statuses.isEmpty) { Arrays.asList(JobExecutionStatus.values(): _*) } else { statuses } } val jobInfos = for { (status, jobs) <- statusToJobs job <- jobs if adjStatuses.contains(status) } yield { AllJobsResource.convertJobData(job, ui.jobProgressListener, false) } jobInfos.sortBy{- _.jobId} } } private[v1] object AllJobsResource { def getStatusToJobs(ui: SparkUI): Seq[(JobExecutionStatus, Seq[JobUIData])] = { val statusToJobs = ui.jobProgressListener.synchronized { Seq( JobExecutionStatus.RUNNING -> ui.jobProgressListener.activeJobs.values.toSeq, JobExecutionStatus.SUCCEEDED -> ui.jobProgressListener.completedJobs.toSeq, JobExecutionStatus.FAILED -> ui.jobProgressListener.failedJobs.reverse.toSeq ) } statusToJobs } def convertJobData( job: JobUIData, listener: JobProgressListener, includeStageDetails: Boolean): JobData = { listener.synchronized { val lastStageInfo = listener.stageIdToInfo.get(job.stageIds.max) val lastStageData = lastStageInfo.flatMap { s => listener.stageIdToData.get((s.stageId, s.attemptId)) } val lastStageName = lastStageInfo.map { _.name }.getOrElse("(Unknown Stage Name)") val lastStageDescription = lastStageData.flatMap { _.description } new JobData( jobId = job.jobId, name = lastStageName, description = lastStageDescription, submissionTime = job.submissionTime.map{new Date(_)}, completionTime = job.completionTime.map{new Date(_)}, stageIds = job.stageIds, jobGroup = job.jobGroup, status = job.status, numTasks = job.numTasks, numActiveTasks = job.numActiveTasks, numCompletedTasks = job.numCompletedTasks, numSkippedTasks = job.numCompletedTasks, numFailedTasks = job.numFailedTasks, numActiveStages = job.numActiveStages, numCompletedStages = job.completedStageIndices.size, numSkippedStages = job.numSkippedStages, numFailedStages = job.numFailedStages ) } } }
Example 11
Source File: StreamingTab.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.streaming.ui import org.apache.spark.{Logging, SparkException} import org.apache.spark.streaming.StreamingContext import org.apache.spark.ui.{SparkUI, SparkUITab} import StreamingTab._ private[spark] class StreamingTab(val ssc: StreamingContext) extends SparkUITab(getSparkUI(ssc), "streaming") with Logging { private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static" val parent = getSparkUI(ssc) val listener = ssc.progressListener ssc.addStreamingListener(listener) ssc.sc.addSparkListener(listener) attachPage(new StreamingPage(this)) attachPage(new BatchPage(this)) def attach() { getSparkUI(ssc).attachTab(this) getSparkUI(ssc).addStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming") } def detach() { getSparkUI(ssc).detachTab(this) getSparkUI(ssc).removeStaticHandler("/static/streaming") } } private object StreamingTab { def getSparkUI(ssc: StreamingContext): SparkUI = { ssc.sc.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 12
Source File: ThriftServerTab.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.sql.hive.thriftserver.{HiveThriftServer2, SparkSQLEnv} import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} import org.apache.spark.{SparkContext, Logging, SparkException} private[thriftserver] class ThriftServerTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" val parent = getSparkUI(sparkContext) val listener = HiveThriftServer2.listener attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 13
Source File: JobsTab.scala From spark1.52 with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") { val sc = parent.sc val killEnabled = parent.killEnabled //利用jobProgressListener中的统计监控数据生成激活,完成,失败等状态的Job摘要信息 val jobProgresslistener = parent.jobProgressListener val executorListener = parent.executorsListener val operationGraphListener = parent.operationGraphListener def isFairScheduler: Boolean = jobProgresslistener.schedulingMode.exists(_ == SchedulingMode.FAIR) attachPage(new AllJobsPage(this)) attachPage(new JobPage(this)) }
Example 14
Source File: StagesTab.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages") { val sc = parent.sc val conf = parent.conf val killEnabled = parent.killEnabled val progressListener = parent.jobProgressListener val operationGraphListener = parent.operationGraphListener attachPage(new AllStagesPage(this)) attachPage(new StagePage(this)) attachPage(new PoolPage(this)) def isFairScheduler: Boolean = progressListener.schedulingMode.exists(_ == SchedulingMode.FAIR) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val killFlag = Option(request.getParameter("terminate")).getOrElse("false").toBoolean val stageId = Option(request.getParameter("id")).getOrElse("-1").toInt if (stageId >= 0 && killFlag && progressListener.activeStages.contains(stageId)) { sc.get.cancelStage(stageId) } // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } }
Example 15
Source File: ExecutorsTab.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.exec import scala.collection.mutable.HashMap import org.apache.spark.ExceptionFailure import org.apache.spark.annotation.DeveloperApi import org.apache.spark.scheduler._ import org.apache.spark.storage.{StorageStatus, StorageStatusListener} import org.apache.spark.ui.{SparkUI, SparkUITab} import org.apache.spark.ui.jobs.UIData.ExecutorUIData private[ui] class ExecutorsTab(parent: SparkUI) extends SparkUITab(parent, "executors") { val listener = parent.executorsListener val sc = parent.sc val threadDumpEnabled = sc.isDefined && parent.conf.getBoolean("spark.ui.threadDumpsEnabled", true) attachPage(new ExecutorsPage(this, threadDumpEnabled)) if (threadDumpEnabled) { attachPage(new ExecutorThreadDumpPage(this)) } } @DeveloperApi class ExecutorsListener(storageStatusListener: StorageStatusListener) extends SparkListener { val executorToTasksActive = HashMap[String, Int]() val executorToTasksComplete = HashMap[String, Int]() val executorToTasksFailed = HashMap[String, Int]() val executorToDuration = HashMap[String, Long]() val executorToInputBytes = HashMap[String, Long]() val executorToInputRecords = HashMap[String, Long]() val executorToOutputBytes = HashMap[String, Long]() val executorToOutputRecords = HashMap[String, Long]() val executorToShuffleRead = HashMap[String, Long]() val executorToShuffleWrite = HashMap[String, Long]() val executorToLogUrls = HashMap[String, Map[String, String]]() val executorIdToData = HashMap[String, ExecutorUIData]() def storageStatusList: Seq[StorageStatus] = storageStatusListener.storageStatusList override def onExecutorAdded(executorAdded: SparkListenerExecutorAdded): Unit = synchronized { val eid = executorAdded.executorId executorToLogUrls(eid) = executorAdded.executorInfo.logUrlMap executorIdToData(eid) = ExecutorUIData(executorAdded.time) } override def onExecutorRemoved( executorRemoved: SparkListenerExecutorRemoved): Unit = synchronized { val eid = executorRemoved.executorId val uiData = executorIdToData(eid) uiData.finishTime = Some(executorRemoved.time) uiData.finishReason = Some(executorRemoved.reason) } override def onTaskStart(taskStart: SparkListenerTaskStart): Unit = synchronized { val eid = taskStart.taskInfo.executorId executorToTasksActive(eid) = executorToTasksActive.getOrElse(eid, 0) + 1 } override def onTaskEnd(taskEnd: SparkListenerTaskEnd): Unit = synchronized { val info = taskEnd.taskInfo if (info != null) { val eid = info.executorId executorToTasksActive(eid) = executorToTasksActive.getOrElse(eid, 1) - 1 executorToDuration(eid) = executorToDuration.getOrElse(eid, 0L) + info.duration taskEnd.reason match { case e: ExceptionFailure => executorToTasksFailed(eid) = executorToTasksFailed.getOrElse(eid, 0) + 1 case _ => executorToTasksComplete(eid) = executorToTasksComplete.getOrElse(eid, 0) + 1 } // Update shuffle read/write val metrics = taskEnd.taskMetrics if (metrics != null) { metrics.inputMetrics.foreach { inputMetrics => executorToInputBytes(eid) = executorToInputBytes.getOrElse(eid, 0L) + inputMetrics.bytesRead executorToInputRecords(eid) = executorToInputRecords.getOrElse(eid, 0L) + inputMetrics.recordsRead } metrics.outputMetrics.foreach { outputMetrics => executorToOutputBytes(eid) = executorToOutputBytes.getOrElse(eid, 0L) + outputMetrics.bytesWritten executorToOutputRecords(eid) = executorToOutputRecords.getOrElse(eid, 0L) + outputMetrics.recordsWritten } metrics.shuffleReadMetrics.foreach { shuffleRead => executorToShuffleRead(eid) = executorToShuffleRead.getOrElse(eid, 0L) + shuffleRead.remoteBytesRead } metrics.shuffleWriteMetrics.foreach { shuffleWrite => executorToShuffleWrite(eid) = executorToShuffleWrite.getOrElse(eid, 0L) + shuffleWrite.shuffleBytesWritten } } } } }
Example 16
Source File: WorkerWebUI.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.{Logging, SparkConf} import org.apache.spark.deploy.worker.Worker import org.apache.spark.deploy.worker.ui.WorkerWebUI._ import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr)) } } private[ui] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR }
Example 17
Source File: MasterWebUI.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.master.ui import org.apache.spark.Logging import org.apache.spark.deploy.master.Master import org.apache.spark.status.api.v1.{ApiRootResource, ApplicationsListResource, ApplicationInfo, UIRoot} import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def detachSparkUI(ui: SparkUI) { assert(serverInfo.isDefined, "Master UI must be bound to a server before detaching SparkUIs") ui.getHandlers.foreach(detachHandler) } def getApplicationInfoList: Iterator[ApplicationInfo] = { val state = masterPage.getMasterState val activeApps = state.activeApps.sortBy(_.startTime).reverse val completedApps = state.completedApps.sortBy(_.endTime).reverse activeApps.iterator.map { ApplicationsListResource.convertApplicationInfo(_, false) } ++ completedApps.iterator.map { ApplicationsListResource.convertApplicationInfo(_, true) } } def getSparkUI(appId: String): Option[SparkUI] = { val state = masterPage.getMasterState val activeApps = state.activeApps.sortBy(_.startTime).reverse val completedApps = state.completedApps.sortBy(_.endTime).reverse (activeApps ++ completedApps).find { _.id == appId }.flatMap { master.rebuildSparkUI } } } private[master] object MasterWebUI { private val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 18
Source File: MesosClusterUI.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.mesos.ui import org.apache.spark.scheduler.cluster.mesos.MesosClusterScheduler import org.apache.spark.{SecurityManager, SparkConf} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.ui.{SparkUI, WebUI} private[spark] class MesosClusterUI( securityManager: SecurityManager, port: Int, conf: SparkConf, dispatcherPublicAddress: String, val scheduler: MesosClusterScheduler) extends WebUI(securityManager, port, conf) { initialize() def activeWebUiUrl: String = "http://" + dispatcherPublicAddress + ":" + boundPort override def initialize() { attachPage(new MesosClusterPage(this)) attachPage(new DriverPage(this)) attachHandler(createStaticHandler(MesosClusterUI.STATIC_RESOURCE_DIR, "/static")) } } private object MesosClusterUI { val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 19
Source File: ExecutorListResource.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class ExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener val storageStatusList = listener.storageStatusList (0 until storageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId) } } }
Example 20
Source File: OneJobResource.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{PathParam, GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class OneJobResource(ui: SparkUI) { @GET def oneJob(@PathParam("jobId") jobId: Int): JobData = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val jobOpt = statusToJobs.map {_._2} .flatten.find { jobInfo => jobInfo.jobId == jobId} jobOpt.map { job => AllJobsResource.convertJobData(job, ui.jobProgressListener, false) }.getOrElse { throw new NotFoundException("unknown job: " + jobId) } } }
Example 21
Source File: AllRDDResource.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.storage.{RDDInfo, StorageStatus, StorageUtils} import org.apache.spark.ui.SparkUI import org.apache.spark.ui.storage.StorageListener @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllRDDResource(ui: SparkUI) { @GET def rddList(): Seq[RDDStorageInfo] = { val storageStatusList = ui.storageListener.storageStatusList val rddInfos = ui.storageListener.rddInfoList rddInfos.map{rddInfo => AllRDDResource.getRDDStorageInfo(rddInfo.id, rddInfo, storageStatusList, includeDetails = false) } } } private[spark] object AllRDDResource { def getRDDStorageInfo( rddId: Int, listener: StorageListener, includeDetails: Boolean): Option[RDDStorageInfo] = { val storageStatusList = listener.storageStatusList listener.rddInfoList.find { _.id == rddId }.map { rddInfo => getRDDStorageInfo(rddId, rddInfo, storageStatusList, includeDetails) } } def getRDDStorageInfo( rddId: Int, rddInfo: RDDInfo, storageStatusList: Seq[StorageStatus], includeDetails: Boolean): RDDStorageInfo = { val workers = storageStatusList.map { (rddId, _) } val blockLocations = StorageUtils.getRddBlockLocations(rddId, storageStatusList) val blocks = storageStatusList .flatMap { _.rddBlocksById(rddId) } .sortWith { _._1.name < _._1.name } .map { case (blockId, status) => (blockId, status, blockLocations.get(blockId).getOrElse(Seq[String]("Unknown"))) } val dataDistribution = if (includeDetails) { Some(storageStatusList.map { status => new RDDDataDistribution( address = status.blockManagerId.hostPort, memoryUsed = status.memUsedByRdd(rddId), memoryRemaining = status.memRemaining, diskUsed = status.diskUsedByRdd(rddId) ) } ) } else { None } val partitions = if (includeDetails) { Some(blocks.map { case (id, block, locations) => new RDDPartitionInfo( blockName = id.name, storageLevel = block.storageLevel.description, memoryUsed = block.memSize, diskUsed = block.diskSize, executors = locations ) } ) } else { None } new RDDStorageInfo( id = rddId, name = rddInfo.name, numPartitions = rddInfo.numPartitions, numCachedPartitions = rddInfo.numCachedPartitions, storageLevel = rddInfo.storageLevel.description, memoryUsed = rddInfo.memSize, diskUsed = rddInfo.diskSize, dataDistribution = dataDistribution, partitions = partitions ) } }
Example 22
Source File: AllJobsResource.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.{Arrays, Date, List => JList} import javax.ws.rs._ import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.JobProgressListener import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllJobsResource(ui: SparkUI) { @GET def jobsList(@QueryParam("status") statuses: JList[JobExecutionStatus]): Seq[JobData] = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val adjStatuses: JList[JobExecutionStatus] = { if (statuses.isEmpty) { Arrays.asList(JobExecutionStatus.values(): _*) } else { statuses } } val jobInfos = for { (status, jobs) <- statusToJobs job <- jobs if adjStatuses.contains(status) } yield { AllJobsResource.convertJobData(job, ui.jobProgressListener, false) } jobInfos.sortBy{- _.jobId} } } private[v1] object AllJobsResource { def getStatusToJobs(ui: SparkUI): Seq[(JobExecutionStatus, Seq[JobUIData])] = { val statusToJobs = ui.jobProgressListener.synchronized { Seq( JobExecutionStatus.RUNNING -> ui.jobProgressListener.activeJobs.values.toSeq, JobExecutionStatus.SUCCEEDED -> ui.jobProgressListener.completedJobs.toSeq, JobExecutionStatus.FAILED -> ui.jobProgressListener.failedJobs.reverse.toSeq ) } statusToJobs } def convertJobData( job: JobUIData, listener: JobProgressListener, includeStageDetails: Boolean): JobData = { listener.synchronized { val lastStageInfo = listener.stageIdToInfo.get(job.stageIds.max) val lastStageData = lastStageInfo.flatMap { s => listener.stageIdToData.get((s.stageId, s.attemptId)) } val lastStageName = lastStageInfo.map { _.name }.getOrElse("(Unknown Stage Name)") val lastStageDescription = lastStageData.flatMap { _.description } new JobData( jobId = job.jobId, name = lastStageName, description = lastStageDescription, submissionTime = job.submissionTime.map{new Date(_)}, completionTime = job.completionTime.map{new Date(_)}, stageIds = job.stageIds, jobGroup = job.jobGroup, status = job.status, numTasks = job.numTasks, numActiveTasks = job.numActiveTasks, numCompletedTasks = job.numCompletedTasks, numSkippedTasks = job.numCompletedTasks, numFailedTasks = job.numFailedTasks, numActiveStages = job.numActiveStages, numCompletedStages = job.completedStageIndices.size, numSkippedStages = job.numSkippedStages, numFailedStages = job.numFailedStages ) } } }
Example 23
Source File: StreamingTab.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.streaming.ui import org.eclipse.jetty.servlet.ServletContextHandler import org.apache.spark.{Logging, SparkException} import org.apache.spark.streaming.StreamingContext import org.apache.spark.ui.{JettyUtils, SparkUI, SparkUITab} import StreamingTab._ private[spark] class StreamingTab(val ssc: StreamingContext) extends SparkUITab(getSparkUI(ssc), "streaming") with Logging { private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static" val parent = getSparkUI(ssc) val listener = ssc.progressListener ssc.addStreamingListener(listener) ssc.sc.addSparkListener(listener) attachPage(new StreamingPage(this)) attachPage(new BatchPage(this)) var staticHandler: ServletContextHandler = null def attach() { getSparkUI(ssc).attachTab(this) staticHandler = JettyUtils.createStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming") getSparkUI(ssc).attachHandler(staticHandler) } def detach() { getSparkUI(ssc).detachTab(this) getSparkUI(ssc).detachHandler(staticHandler) staticHandler = null } } private object StreamingTab { def getSparkUI(ssc: StreamingContext): SparkUI = { ssc.sc.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 24
Source File: StreamingTab.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.streaming.ui import org.apache.spark.{Logging, SparkException} import org.apache.spark.streaming.StreamingContext import org.apache.spark.ui.{SparkUI, SparkUITab} import StreamingTab._ private[spark] class StreamingTab(val ssc: StreamingContext) extends SparkUITab(getSparkUI(ssc), "streaming") with Logging { private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static" val parent = getSparkUI(ssc) val listener = ssc.progressListener ssc.addStreamingListener(listener) ssc.sc.addSparkListener(listener) attachPage(new StreamingPage(this)) attachPage(new BatchPage(this)) def attach() { getSparkUI(ssc).attachTab(this) getSparkUI(ssc).addStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming") } def detach() { getSparkUI(ssc).detachTab(this) getSparkUI(ssc).removeStaticHandler("/static/streaming") } } private object StreamingTab { def getSparkUI(ssc: StreamingContext): SparkUI = { ssc.sc.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 25
Source File: SQLServerTab.scala From spark-sql-server with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.server.ui import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.internal.Logging import org.apache.spark.sql.server.SQLServerListener import org.apache.spark.sql.server.ui.SQLServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} case class SQLServerTab( sparkContext: SparkContext, listener: SQLServerListener) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" private val parent = getSparkUI(sparkContext) attachPage(new SQLServerPage(this)) attachPage(new SQLServerSessionPage(this)) parent.attachTab(this) def detach() { parent.detachTab(this) } } object SQLServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 26
Source File: ThriftServerTabSeq.scala From bdg-sequila with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2Seq.HiveThriftServer2ListenerSeq import org.apache.spark.sql.hive.thriftserver.{HiveThriftServer2, SequilaThriftServer} import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} private[thriftserver] class ThriftServerTabSeq(sparkContext: SparkContext, list: HiveThriftServer2ListenerSeq) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "SeQuiLa JDBC/ODBC Server" val parent = getSparkUI(sparkContext) val listener = list attachPage(new ThriftServerPageSeq(this)) attachPage(new ThriftServerSessionPageSeq(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 27
Source File: JobsTab.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") { val sc = parent.sc val killEnabled = parent.killEnabled val jobProgresslistener = parent.jobProgressListener val executorListener = parent.executorsListener val operationGraphListener = parent.operationGraphListener def isFairScheduler: Boolean = jobProgresslistener.schedulingMode.exists(_ == SchedulingMode.FAIR) attachPage(new AllJobsPage(this)) attachPage(new JobPage(this)) }
Example 28
Source File: StagesTab.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages") { val sc = parent.sc val conf = parent.conf val killEnabled = parent.killEnabled val progressListener = parent.jobProgressListener val operationGraphListener = parent.operationGraphListener attachPage(new AllStagesPage(this)) attachPage(new StagePage(this)) attachPage(new PoolPage(this)) def isFairScheduler: Boolean = progressListener.schedulingMode.exists(_ == SchedulingMode.FAIR) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val killFlag = Option(request.getParameter("terminate")).getOrElse("false").toBoolean val stageId = Option(request.getParameter("id")).getOrElse("-1").toInt if (stageId >= 0 && killFlag && progressListener.activeStages.contains(stageId)) { sc.get.cancelStage(stageId) } // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } }
Example 29
Source File: WorkerWebUI.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.Logging import org.apache.spark.deploy.worker.Worker import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr, worker.conf)) } } private[worker] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR val DEFAULT_RETAINED_DRIVERS = 1000 val DEFAULT_RETAINED_EXECUTORS = 1000 }
Example 30
Source File: MasterWebUI.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.master.ui import org.apache.spark.Logging import org.apache.spark.deploy.master.Master import org.apache.spark.status.api.v1.{ApiRootResource, ApplicationsListResource, ApplicationInfo, UIRoot} import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ def detachSparkUI(ui: SparkUI) { assert(serverInfo.isDefined, "Master UI must be bound to a server before detaching SparkUIs") ui.getHandlers.foreach(detachHandler) } def getApplicationInfoList: Iterator[ApplicationInfo] = { val state = masterPage.getMasterState val activeApps = state.activeApps.sortBy(_.startTime).reverse val completedApps = state.completedApps.sortBy(_.endTime).reverse activeApps.iterator.map { ApplicationsListResource.convertApplicationInfo(_, false) } ++ completedApps.iterator.map { ApplicationsListResource.convertApplicationInfo(_, true) } } def getSparkUI(appId: String): Option[SparkUI] = { val state = masterPage.getMasterState val activeApps = state.activeApps.sortBy(_.startTime).reverse val completedApps = state.completedApps.sortBy(_.endTime).reverse (activeApps ++ completedApps).find { _.id == appId }.flatMap { master.rebuildSparkUI } } } private[master] object MasterWebUI { private val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 31
Source File: MesosClusterUI.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.mesos.ui import org.apache.spark.scheduler.cluster.mesos.MesosClusterScheduler import org.apache.spark.{SecurityManager, SparkConf} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.ui.{SparkUI, WebUI} private[spark] class MesosClusterUI( securityManager: SecurityManager, port: Int, conf: SparkConf, dispatcherPublicAddress: String, val scheduler: MesosClusterScheduler) extends WebUI(securityManager, port, conf) { initialize() def activeWebUiUrl: String = "http://" + dispatcherPublicAddress + ":" + boundPort override def initialize() { attachPage(new MesosClusterPage(this)) attachPage(new DriverPage(this)) attachHandler(createStaticHandler(MesosClusterUI.STATIC_RESOURCE_DIR, "/static")) } } private object MesosClusterUI { val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 32
Source File: ExecutorListResource.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class ExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. val storageStatusList = listener.storageStatusList (0 until storageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId) } } } }
Example 33
Source File: OneJobResource.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{PathParam, GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class OneJobResource(ui: SparkUI) { @GET def oneJob(@PathParam("jobId") jobId: Int): JobData = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val jobOpt = statusToJobs.map {_._2} .flatten.find { jobInfo => jobInfo.jobId == jobId} jobOpt.map { job => AllJobsResource.convertJobData(job, ui.jobProgressListener, false) }.getOrElse { throw new NotFoundException("unknown job: " + jobId) } } }
Example 34
Source File: AllRDDResource.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.storage.{RDDInfo, StorageStatus, StorageUtils} import org.apache.spark.ui.SparkUI import org.apache.spark.ui.storage.StorageListener @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllRDDResource(ui: SparkUI) { @GET def rddList(): Seq[RDDStorageInfo] = { val storageStatusList = ui.storageListener.storageStatusList val rddInfos = ui.storageListener.rddInfoList rddInfos.map{rddInfo => AllRDDResource.getRDDStorageInfo(rddInfo.id, rddInfo, storageStatusList, includeDetails = false) } } } private[spark] object AllRDDResource { def getRDDStorageInfo( rddId: Int, listener: StorageListener, includeDetails: Boolean): Option[RDDStorageInfo] = { val storageStatusList = listener.storageStatusList listener.rddInfoList.find { _.id == rddId }.map { rddInfo => getRDDStorageInfo(rddId, rddInfo, storageStatusList, includeDetails) } } def getRDDStorageInfo( rddId: Int, rddInfo: RDDInfo, storageStatusList: Seq[StorageStatus], includeDetails: Boolean): RDDStorageInfo = { val workers = storageStatusList.map { (rddId, _) } val blockLocations = StorageUtils.getRddBlockLocations(rddId, storageStatusList) val blocks = storageStatusList .flatMap { _.rddBlocksById(rddId) } .sortWith { _._1.name < _._1.name } .map { case (blockId, status) => (blockId, status, blockLocations.get(blockId).getOrElse(Seq[String]("Unknown"))) } val dataDistribution = if (includeDetails) { Some(storageStatusList.map { status => new RDDDataDistribution( address = status.blockManagerId.hostPort, memoryUsed = status.memUsedByRdd(rddId), memoryRemaining = status.memRemaining, diskUsed = status.diskUsedByRdd(rddId) ) } ) } else { None } val partitions = if (includeDetails) { Some(blocks.map { case (id, block, locations) => new RDDPartitionInfo( blockName = id.name, storageLevel = block.storageLevel.description, memoryUsed = block.memSize, diskUsed = block.diskSize, executors = locations ) } ) } else { None } new RDDStorageInfo( id = rddId, name = rddInfo.name, numPartitions = rddInfo.numPartitions, numCachedPartitions = rddInfo.numCachedPartitions, storageLevel = rddInfo.storageLevel.description, memoryUsed = rddInfo.memSize, diskUsed = rddInfo.diskSize, dataDistribution = dataDistribution, partitions = partitions ) } }
Example 35
Source File: AllJobsResource.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.{Arrays, Date, List => JList} import javax.ws.rs._ import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.JobProgressListener import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllJobsResource(ui: SparkUI) { @GET def jobsList(@QueryParam("status") statuses: JList[JobExecutionStatus]): Seq[JobData] = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val adjStatuses: JList[JobExecutionStatus] = { if (statuses.isEmpty) { Arrays.asList(JobExecutionStatus.values(): _*) } else { statuses } } val jobInfos = for { (status, jobs) <- statusToJobs job <- jobs if adjStatuses.contains(status) } yield { AllJobsResource.convertJobData(job, ui.jobProgressListener, false) } jobInfos.sortBy{- _.jobId} } } private[v1] object AllJobsResource { def getStatusToJobs(ui: SparkUI): Seq[(JobExecutionStatus, Seq[JobUIData])] = { val statusToJobs = ui.jobProgressListener.synchronized { Seq( JobExecutionStatus.RUNNING -> ui.jobProgressListener.activeJobs.values.toSeq, JobExecutionStatus.SUCCEEDED -> ui.jobProgressListener.completedJobs.toSeq, JobExecutionStatus.FAILED -> ui.jobProgressListener.failedJobs.reverse.toSeq ) } statusToJobs } def convertJobData( job: JobUIData, listener: JobProgressListener, includeStageDetails: Boolean): JobData = { listener.synchronized { val lastStageInfo = listener.stageIdToInfo.get(job.stageIds.max) val lastStageData = lastStageInfo.flatMap { s => listener.stageIdToData.get((s.stageId, s.attemptId)) } val lastStageName = lastStageInfo.map { _.name }.getOrElse("(Unknown Stage Name)") val lastStageDescription = lastStageData.flatMap { _.description } new JobData( jobId = job.jobId, name = lastStageName, description = lastStageDescription, submissionTime = job.submissionTime.map{new Date(_)}, completionTime = job.completionTime.map{new Date(_)}, stageIds = job.stageIds, jobGroup = job.jobGroup, status = job.status, numTasks = job.numTasks, numActiveTasks = job.numActiveTasks, numCompletedTasks = job.numCompletedTasks, numSkippedTasks = job.numCompletedTasks, numFailedTasks = job.numFailedTasks, numActiveStages = job.numActiveStages, numCompletedStages = job.completedStageIndices.size, numSkippedStages = job.numSkippedStages, numFailedStages = job.numFailedStages ) } } }
Example 36
Source File: ThriftServerTab.scala From iolap with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.sql.hive.thriftserver.{HiveThriftServer2, SparkSQLEnv} import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} import org.apache.spark.{SparkContext, Logging, SparkException} private[thriftserver] class ThriftServerTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sql") with Logging { override val name = "SQL" val parent = getSparkUI(sparkContext) val listener = HiveThriftServer2.listener attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 37
Source File: ThriftServerTab.scala From BigDatalog with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.sql.hive.thriftserver.{HiveThriftServer2, SparkSQLEnv} import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} import org.apache.spark.{SparkContext, Logging, SparkException} private[thriftserver] class ThriftServerTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" val parent = getSparkUI(sparkContext) val listener = HiveThriftServer2.listener attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 38
Source File: StagesTab.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.status.AppStatusStore import org.apache.spark.status.api.v1.StageStatus import org.apache.spark.ui.{SparkUI, SparkUITab, UIUtils} private[ui] class StagesTab(val parent: SparkUI, val store: AppStatusStore) extends SparkUITab(parent, "stages") { val sc = parent.sc val conf = parent.conf val killEnabled = parent.killEnabled attachPage(new AllStagesPage(this)) attachPage(new StagePage(this, store)) attachPage(new PoolPage(this)) def isFairScheduler: Boolean = { store .environmentInfo() .sparkProperties .contains(("spark.scheduler.mode", SchedulingMode.FAIR.toString)) } def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { // stripXSS is called first to remove suspicious characters used in XSS attacks val stageId = Option(UIUtils.stripXSS(request.getParameter("id"))).map(_.toInt) stageId.foreach { id => store.asOption(store.lastStageAttempt(id)).foreach { stage => val status = stage.status if (status == StageStatus.ACTIVE || status == StageStatus.PENDING) { sc.foreach(_.cancelStage(id, "killed via the Web UI")) // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } } } } }
Example 39
Source File: ExecutorsTab.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.exec import javax.servlet.http.HttpServletRequest import scala.xml.Node import org.apache.spark.ui.{SparkUI, SparkUITab, UIUtils, WebUIPage} private[ui] class ExecutorsTab(parent: SparkUI) extends SparkUITab(parent, "executors") { init() private def init(): Unit = { val threadDumpEnabled = parent.sc.isDefined && parent.conf.getBoolean("spark.ui.threadDumpsEnabled", true) attachPage(new ExecutorsPage(this, threadDumpEnabled)) if (threadDumpEnabled) { attachPage(new ExecutorThreadDumpPage(this, parent.sc)) } } } private[ui] class ExecutorsPage( parent: SparkUITab, threadDumpEnabled: Boolean) extends WebUIPage("") { def render(request: HttpServletRequest): Seq[Node] = { val content = <div> { <div id="active-executors" class="row-fluid"></div> ++ <script src={UIUtils.prependBaseUri("/static/utils.js")}></script> ++ <script src={UIUtils.prependBaseUri("/static/executorspage.js")}></script> ++ <script>setThreadDumpEnabled({threadDumpEnabled})</script> } </div> UIUtils.headerSparkPage("Executors", content, parent, useDataTables = true) } }
Example 40
Source File: WorkerWebUI.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.deploy.worker.Worker import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr, worker.conf)) } } private[worker] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR val DEFAULT_RETAINED_DRIVERS = 1000 val DEFAULT_RETAINED_EXECUTORS = 1000 }
Example 41
Source File: MasterWebUI.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.master.ui import org.apache.spark.deploy.DeployMessages.{MasterStateResponse, RequestMasterState} import org.apache.spark.deploy.master.Master import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ def initialize() { val masterPage = new MasterPage(this) attachPage(new ApplicationPage(this)) attachPage(masterPage) attachHandler(createStaticHandler(MasterWebUI.STATIC_RESOURCE_DIR, "/static")) attachHandler(createRedirectHandler( "/app/kill", "/", masterPage.handleAppKillRequest, httpMethods = Set("POST"))) attachHandler(createRedirectHandler( "/driver/kill", "/", masterPage.handleDriverKillRequest, httpMethods = Set("POST"))) } def addProxy(): Unit = { val handler = createProxyHandler(idToUiAddress) attachHandler(handler) } def idToUiAddress(id: String): Option[String] = { val state = masterEndpointRef.askSync[MasterStateResponse](RequestMasterState) val maybeWorkerUiAddress = state.workers.find(_.id == id).map(_.webUiAddress) val maybeAppUiAddress = state.activeApps.find(_.id == id).map(_.desc.appUiUrl) maybeWorkerUiAddress.orElse(maybeAppUiAddress) } } private[master] object MasterWebUI { private val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 42
Source File: StagesResource.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.{List => JList} import javax.ws.rs._ import javax.ws.rs.core.MediaType import org.apache.spark.SparkException import org.apache.spark.scheduler.StageInfo import org.apache.spark.status.api.v1.StageStatus._ import org.apache.spark.status.api.v1.TaskSorting._ import org.apache.spark.ui.SparkUI @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class StagesResource extends BaseAppResource { @GET def stageList(@QueryParam("status") statuses: JList[StageStatus]): Seq[StageData] = { withUI(_.store.stageList(statuses)) } @GET @Path("{stageId: \\d+}") def stageData( @PathParam("stageId") stageId: Int, @QueryParam("details") @DefaultValue("true") details: Boolean): Seq[StageData] = { withUI { ui => val ret = ui.store.stageData(stageId, details = details) if (ret.nonEmpty) { ret } else { throw new NotFoundException(s"unknown stage: $stageId") } } } @GET @Path("{stageId: \\d+}/{stageAttemptId: \\d+}") def oneAttemptData( @PathParam("stageId") stageId: Int, @PathParam("stageAttemptId") stageAttemptId: Int, @QueryParam("details") @DefaultValue("true") details: Boolean): StageData = withUI { ui => try { ui.store.stageAttempt(stageId, stageAttemptId, details = details) } catch { case _: NoSuchElementException => // Change the message depending on whether there are any attempts for the requested stage. val all = ui.store.stageData(stageId) val msg = if (all.nonEmpty) { val ids = all.map(_.attemptId) s"unknown attempt for stage $stageId. Found attempts: [${ids.mkString(",")}]" } else { s"unknown stage: $stageId" } throw new NotFoundException(msg) } } @GET @Path("{stageId: \\d+}/{stageAttemptId: \\d+}/taskSummary") def taskSummary( @PathParam("stageId") stageId: Int, @PathParam("stageAttemptId") stageAttemptId: Int, @DefaultValue("0.05,0.25,0.5,0.75,0.95") @QueryParam("quantiles") quantileString: String) : TaskMetricDistributions = withUI { ui => val quantiles = quantileString.split(",").map { s => try { s.toDouble } catch { case nfe: NumberFormatException => throw new BadParameterException("quantiles", "double", s) } } ui.store.taskSummary(stageId, stageAttemptId, quantiles).getOrElse( throw new NotFoundException(s"No tasks reported metrics for $stageId / $stageAttemptId yet.")) } @GET @Path("{stageId: \\d+}/{stageAttemptId: \\d+}/taskList") def taskList( @PathParam("stageId") stageId: Int, @PathParam("stageAttemptId") stageAttemptId: Int, @DefaultValue("0") @QueryParam("offset") offset: Int, @DefaultValue("20") @QueryParam("length") length: Int, @DefaultValue("ID") @QueryParam("sortBy") sortBy: TaskSorting): Seq[TaskData] = { withUI(_.store.taskList(stageId, stageAttemptId, offset, length, sortBy)) } }
Example 43
Source File: StreamingTab.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.streaming.ui import org.apache.spark.SparkException import org.apache.spark.internal.Logging import org.apache.spark.streaming.StreamingContext import org.apache.spark.ui.{SparkUI, SparkUITab} private[spark] class StreamingTab(val ssc: StreamingContext) extends SparkUITab(StreamingTab.getSparkUI(ssc), "streaming") with Logging { import StreamingTab._ private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static" val parent = getSparkUI(ssc) val listener = ssc.progressListener ssc.addStreamingListener(listener) ssc.sc.addSparkListener(listener) parent.setStreamingJobProgressListener(listener) attachPage(new StreamingPage(this)) attachPage(new BatchPage(this)) def attach() { getSparkUI(ssc).attachTab(this) getSparkUI(ssc).addStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming") } def detach() { getSparkUI(ssc).detachTab(this) getSparkUI(ssc).removeStaticHandler("/static/streaming") } } private object StreamingTab { def getSparkUI(ssc: StreamingContext): SparkUI = { ssc.sc.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 44
Source File: SQLHistoryServerPlugin.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.execution.ui import org.apache.spark.SparkConf import org.apache.spark.scheduler.SparkListener import org.apache.spark.status.{AppHistoryServerPlugin, ElementTrackingStore} import org.apache.spark.ui.SparkUI class SQLHistoryServerPlugin extends AppHistoryServerPlugin { override def createListeners(conf: SparkConf, store: ElementTrackingStore): Seq[SparkListener] = { Seq(new SQLAppStatusListener(conf, store, live = false)) } override def setupUI(ui: SparkUI): Unit = { val sqlStatusStore = new SQLAppStatusStore(ui.store.store) if (sqlStatusStore.executionsCount() > 0) { new SQLTab(sqlStatusStore, ui) } } }
Example 45
Source File: ThriftServerTab.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} private[thriftserver] class ThriftServerTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" val parent = getSparkUI(sparkContext) val listener = HiveThriftServer2.listener attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 46
Source File: MesosClusterUI.scala From Spark-2.3.1 with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.mesos.ui import org.apache.spark.{SecurityManager, SparkConf} import org.apache.spark.scheduler.cluster.mesos.MesosClusterScheduler import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ private[spark] class MesosClusterUI( securityManager: SecurityManager, port: Int, val conf: SparkConf, dispatcherPublicAddress: String, val scheduler: MesosClusterScheduler) extends WebUI(securityManager, securityManager.getSSLOptions("mesos"), port, conf) { initialize() def activeWebUiUrl: String = "http://" + dispatcherPublicAddress + ":" + boundPort override def initialize() { attachPage(new MesosClusterPage(this)) attachPage(new DriverPage(this)) attachHandler(createStaticHandler(MesosClusterUI.STATIC_RESOURCE_DIR, "/static")) } } private object MesosClusterUI { val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 47
Source File: StagesTab.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages") { val sc = parent.sc val conf = parent.conf val killEnabled = parent.killEnabled val progressListener = parent.jobProgressListener val operationGraphListener = parent.operationGraphListener val executorsListener = parent.executorsListener attachPage(new AllStagesPage(this)) attachPage(new StagePage(this)) attachPage(new PoolPage(this)) def isFairScheduler: Boolean = progressListener.schedulingMode == Some(SchedulingMode.FAIR) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val stageId = Option(request.getParameter("id")).map(_.toInt) stageId.foreach { id => if (progressListener.activeStages.contains(id)) { sc.foreach(_.cancelStage(id)) // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } } } }
Example 48
Source File: AllExecutorListResource.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. (0 until listener.activeStorageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = true) } ++ (0 until listener.deadStorageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = false) } } } }
Example 49
Source File: OneJobResource.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class OneJobResource(ui: SparkUI) { @GET def oneJob(@PathParam("jobId") jobId: Int): JobData = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val jobOpt = statusToJobs.flatMap(_._2).find { jobInfo => jobInfo.jobId == jobId} jobOpt.map { job => AllJobsResource.convertJobData(job, ui.jobProgressListener, false) }.getOrElse { throw new NotFoundException("unknown job: " + jobId) } } }
Example 50
Source File: AllRDDResource.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.storage.{RDDInfo, StorageStatus, StorageUtils} import org.apache.spark.ui.SparkUI import org.apache.spark.ui.storage.StorageListener @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllRDDResource(ui: SparkUI) { @GET def rddList(): Seq[RDDStorageInfo] = { val storageStatusList = ui.storageListener.activeStorageStatusList val rddInfos = ui.storageListener.rddInfoList rddInfos.map{rddInfo => AllRDDResource.getRDDStorageInfo(rddInfo.id, rddInfo, storageStatusList, includeDetails = false) } } } private[spark] object AllRDDResource { def getRDDStorageInfo( rddId: Int, listener: StorageListener, includeDetails: Boolean): Option[RDDStorageInfo] = { val storageStatusList = listener.activeStorageStatusList listener.rddInfoList.find { _.id == rddId }.map { rddInfo => getRDDStorageInfo(rddId, rddInfo, storageStatusList, includeDetails) } } def getRDDStorageInfo( rddId: Int, rddInfo: RDDInfo, storageStatusList: Seq[StorageStatus], includeDetails: Boolean): RDDStorageInfo = { val workers = storageStatusList.map { (rddId, _) } val blockLocations = StorageUtils.getRddBlockLocations(rddId, storageStatusList) val blocks = storageStatusList .flatMap { _.rddBlocksById(rddId) } .sortWith { _._1.name < _._1.name } .map { case (blockId, status) => (blockId, status, blockLocations.getOrElse(blockId, Seq[String]("Unknown"))) } val dataDistribution = if (includeDetails) { Some(storageStatusList.map { status => new RDDDataDistribution( address = status.blockManagerId.hostPort, memoryUsed = status.memUsedByRdd(rddId), memoryRemaining = status.memRemaining, diskUsed = status.diskUsedByRdd(rddId) ) } ) } else { None } val partitions = if (includeDetails) { Some(blocks.map { case (id, block, locations) => new RDDPartitionInfo( blockName = id.name, storageLevel = block.storageLevel.description, memoryUsed = block.memSize, diskUsed = block.diskSize, executors = locations ) } ) } else { None } new RDDStorageInfo( id = rddId, name = rddInfo.name, numPartitions = rddInfo.numPartitions, numCachedPartitions = rddInfo.numCachedPartitions, storageLevel = rddInfo.storageLevel.description, memoryUsed = rddInfo.memSize, diskUsed = rddInfo.diskSize, dataDistribution = dataDistribution, partitions = partitions ) } }
Example 51
Source File: AllJobsResource.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.{Arrays, Date, List => JList} import javax.ws.rs._ import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.JobProgressListener import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllJobsResource(ui: SparkUI) { @GET def jobsList(@QueryParam("status") statuses: JList[JobExecutionStatus]): Seq[JobData] = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val adjStatuses: JList[JobExecutionStatus] = { if (statuses.isEmpty) { Arrays.asList(JobExecutionStatus.values(): _*) } else { statuses } } val jobInfos = for { (status, jobs) <- statusToJobs job <- jobs if adjStatuses.contains(status) } yield { AllJobsResource.convertJobData(job, ui.jobProgressListener, false) } jobInfos.sortBy{- _.jobId} } } private[v1] object AllJobsResource { def getStatusToJobs(ui: SparkUI): Seq[(JobExecutionStatus, Seq[JobUIData])] = { val statusToJobs = ui.jobProgressListener.synchronized { Seq( JobExecutionStatus.RUNNING -> ui.jobProgressListener.activeJobs.values.toSeq, JobExecutionStatus.SUCCEEDED -> ui.jobProgressListener.completedJobs.toSeq, JobExecutionStatus.FAILED -> ui.jobProgressListener.failedJobs.reverse.toSeq ) } statusToJobs } def convertJobData( job: JobUIData, listener: JobProgressListener, includeStageDetails: Boolean): JobData = { listener.synchronized { val lastStageInfo = if (job.stageIds.isEmpty) { None } else { listener.stageIdToInfo.get(job.stageIds.max) } val lastStageData = lastStageInfo.flatMap { s => listener.stageIdToData.get((s.stageId, s.attemptId)) } val lastStageName = lastStageInfo.map { _.name }.getOrElse("(Unknown Stage Name)") val lastStageDescription = lastStageData.flatMap { _.description } new JobData( jobId = job.jobId, name = lastStageName, description = lastStageDescription, submissionTime = job.submissionTime.map{new Date(_)}, completionTime = job.completionTime.map{new Date(_)}, stageIds = job.stageIds, jobGroup = job.jobGroup, status = job.status, numTasks = job.numTasks, numActiveTasks = job.numActiveTasks, numCompletedTasks = job.numCompletedTasks, numSkippedTasks = job.numSkippedTasks, numFailedTasks = job.numFailedTasks, numActiveStages = job.numActiveStages, numCompletedStages = job.completedStageIndices.size, numSkippedStages = job.numSkippedStages, numFailedStages = job.numFailedStages ) } } }
Example 52
Source File: StreamingTab.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.streaming.ui import org.apache.spark.SparkException import org.apache.spark.internal.Logging import org.apache.spark.streaming.StreamingContext import org.apache.spark.ui.{SparkUI, SparkUITab} private[spark] class StreamingTab(val ssc: StreamingContext) extends SparkUITab(StreamingTab.getSparkUI(ssc), "streaming") with Logging { import StreamingTab._ private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static" val parent = getSparkUI(ssc) val listener = ssc.progressListener ssc.addStreamingListener(listener) ssc.sc.addSparkListener(listener) attachPage(new StreamingPage(this)) attachPage(new BatchPage(this)) def attach() { getSparkUI(ssc).attachTab(this) getSparkUI(ssc).addStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming") } def detach() { getSparkUI(ssc).detachTab(this) getSparkUI(ssc).removeStaticHandler("/static/streaming") } } private object StreamingTab { def getSparkUI(ssc: StreamingContext): SparkUI = { ssc.sc.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 53
Source File: ThriftServerTab.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} private[thriftserver] class ThriftServerTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" val parent = getSparkUI(sparkContext) val listener = HiveThriftServer2.listener attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 54
Source File: MesosClusterUI.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.mesos.ui import org.apache.spark.{SecurityManager, SparkConf} import org.apache.spark.scheduler.cluster.mesos.MesosClusterScheduler import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ private[spark] class MesosClusterUI( securityManager: SecurityManager, port: Int, val conf: SparkConf, dispatcherPublicAddress: String, val scheduler: MesosClusterScheduler) extends WebUI(securityManager, securityManager.getSSLOptions("mesos"), port, conf) { initialize() def activeWebUiUrl: String = "http://" + dispatcherPublicAddress + ":" + boundPort override def initialize() { attachPage(new MesosClusterPage(this)) attachPage(new DriverPage(this)) attachHandler(createStaticHandler(MesosClusterUI.STATIC_RESOURCE_DIR, "/static")) } } private object MesosClusterUI { val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 55
Source File: ExecutorNumTab.scala From XSQL with Apache License 2.0 | 5 votes |
package org.apache.spark.monitor import javax.servlet.http.HttpServletRequest import scala.xml.Node import org.apache.spark.ui.{SparkUI, SparkUITab, UIUtils, WebUIPage} private class ExecutorNumTab(parent: SparkUI) extends SparkUITab(parent, "resources") { init() private def init(): Unit = { attachPage(new ExecutorNumPage(this)) } } private class ExecutorNumPage(parent: SparkUITab) extends WebUIPage("") { def render(request: HttpServletRequest): Seq[Node] = { val content = <div> { <div id ="echart-container" class="row-fluid" style="height: 600px"></div> ++ <script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts.min.js"></script> ++ <script src={UIUtils.prependBaseUri( request, "/static/special/executornumpage.js")}></script> } </div> UIUtils.headerSparkPage(request, "ExecutorNumCurve", content, parent, useDataTables = false) } }
Example 56
Source File: SQLHistoryServerPlugin.scala From XSQL with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.execution.ui import org.apache.spark.SparkConf import org.apache.spark.scheduler.SparkListener import org.apache.spark.status.{AppHistoryServerPlugin, ElementTrackingStore} import org.apache.spark.ui.SparkUI class SQLHistoryServerPlugin extends AppHistoryServerPlugin { override def createListeners(conf: SparkConf, store: ElementTrackingStore): Seq[SparkListener] = { Seq(new SQLAppStatusListener(conf, store, live = false)) } override def setupUI(ui: SparkUI): Unit = { val sqlStatusStore = new SQLAppStatusStore(ui.store.store) if (sqlStatusStore.executionsCount() > 0) { new SQLTab(sqlStatusStore, ui) } } }
Example 57
Source File: ThriftServerTab.scala From XSQL with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} private[thriftserver] class ThriftServerTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" val parent = getSparkUI(sparkContext) val listener = HiveThriftServer2.listener attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 58
Source File: JobsTab.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") { val sc = parent.sc val killEnabled = parent.killEnabled val jobProgresslistener = parent.jobProgressListener val executorListener = parent.executorsListener val operationGraphListener = parent.operationGraphListener def isFairScheduler: Boolean = jobProgresslistener.schedulingMode == Some(SchedulingMode.FAIR) def getSparkUser: String = parent.getSparkUser attachPage(new AllJobsPage(this)) attachPage(new JobPage(this)) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val jobId = Option(request.getParameter("id")).map(_.toInt) jobId.foreach { id => if (jobProgresslistener.activeJobs.contains(id)) { sc.foreach(_.cancelJob(id)) // Do a quick pause here to give Spark time to kill the job so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } } } }
Example 59
Source File: ExecutorListResource.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class ExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. val storageStatusList = listener.activeStorageStatusList (0 until storageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = true) } } } }
Example 60
Source File: ApplicationHistoryProvider.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.history import java.util.zip.ZipOutputStream import scala.xml.Node import org.apache.spark.SparkException import org.apache.spark.ui.SparkUI private[spark] case class ApplicationAttemptInfo( attemptId: Option[String], startTime: Long, endTime: Long, lastUpdated: Long, sparkUser: String, completed: Boolean = false) private[spark] case class ApplicationHistoryInfo( id: String, name: String, attempts: List[ApplicationAttemptInfo]) { def getEmptyListingHtml(): Seq[Node] = Seq.empty }
Example 61
Source File: WorkerWebUI.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.deploy.worker.Worker import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr, worker.conf)) } } private[worker] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR val DEFAULT_RETAINED_DRIVERS = 1000 val DEFAULT_RETAINED_EXECUTORS = 1000 }
Example 62
Source File: MasterWebUI.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.master.ui import scala.collection.mutable.HashMap import org.eclipse.jetty.servlet.ServletContextHandler import org.apache.spark.deploy.master.Master import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ def initialize() { val masterPage = new MasterPage(this) attachPage(new ApplicationPage(this)) attachPage(masterPage) attachHandler(createStaticHandler(MasterWebUI.STATIC_RESOURCE_DIR, "/static")) attachHandler(createRedirectHandler( "/app/kill", "/", masterPage.handleAppKillRequest, httpMethods = Set("POST"))) attachHandler(createRedirectHandler( "/driver/kill", "/", masterPage.handleDriverKillRequest, httpMethods = Set("POST"))) } def addProxyTargets(id: String, target: String): Unit = { var endTarget = target.stripSuffix("/") val handler = createProxyHandler("/proxy/" + id, endTarget) attachHandler(handler) proxyHandlers(id) = handler } def removeProxyTargets(id: String): Unit = { proxyHandlers.remove(id).foreach(detachHandler) } } private[master] object MasterWebUI { private val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 63
Source File: ExecutorListResource.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class ExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. val storageStatusList = listener.activeStorageStatusList (0 until storageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = true) } } } }
Example 64
Source File: AllExecutorListResource.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. (0 until listener.activeStorageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = true) } ++ (0 until listener.deadStorageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = false) } } } }
Example 65
Source File: OneJobResource.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class OneJobResource(ui: SparkUI) { @GET def oneJob(@PathParam("jobId") jobId: Int): JobData = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val jobOpt = statusToJobs.flatMap(_._2).find { jobInfo => jobInfo.jobId == jobId} jobOpt.map { job => AllJobsResource.convertJobData(job, ui.jobProgressListener, false) }.getOrElse { throw new NotFoundException("unknown job: " + jobId) } } }
Example 66
Source File: AllRDDResource.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.storage.{RDDInfo, StorageStatus, StorageUtils} import org.apache.spark.ui.SparkUI import org.apache.spark.ui.storage.StorageListener @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllRDDResource(ui: SparkUI) { @GET def rddList(): Seq[RDDStorageInfo] = { val storageStatusList = ui.storageListener.activeStorageStatusList val rddInfos = ui.storageListener.rddInfoList rddInfos.map{rddInfo => AllRDDResource.getRDDStorageInfo(rddInfo.id, rddInfo, storageStatusList, includeDetails = false) } } } private[spark] object AllRDDResource { def getRDDStorageInfo( rddId: Int, listener: StorageListener, includeDetails: Boolean): Option[RDDStorageInfo] = { val storageStatusList = listener.activeStorageStatusList listener.rddInfoList.find { _.id == rddId }.map { rddInfo => getRDDStorageInfo(rddId, rddInfo, storageStatusList, includeDetails) } } def getRDDStorageInfo( rddId: Int, rddInfo: RDDInfo, storageStatusList: Seq[StorageStatus], includeDetails: Boolean): RDDStorageInfo = { val workers = storageStatusList.map { (rddId, _) } val blockLocations = StorageUtils.getRddBlockLocations(rddId, storageStatusList) val blocks = storageStatusList .flatMap { _.rddBlocksById(rddId) } .sortWith { _._1.name < _._1.name } .map { case (blockId, status) => (blockId, status, blockLocations.getOrElse(blockId, Seq[String]("Unknown"))) } val dataDistribution = if (includeDetails) { Some(storageStatusList.map { status => new RDDDataDistribution( address = status.blockManagerId.hostPort, memoryUsed = status.memUsedByRdd(rddId), memoryRemaining = status.memRemaining, diskUsed = status.diskUsedByRdd(rddId) ) } ) } else { None } val partitions = if (includeDetails) { Some(blocks.map { case (id, block, locations) => new RDDPartitionInfo( blockName = id.name, storageLevel = block.storageLevel.description, memoryUsed = block.memSize, diskUsed = block.diskSize, executors = locations ) } ) } else { None } new RDDStorageInfo( id = rddId, name = rddInfo.name, numPartitions = rddInfo.numPartitions, numCachedPartitions = rddInfo.numCachedPartitions, storageLevel = rddInfo.storageLevel.description, memoryUsed = rddInfo.memSize, diskUsed = rddInfo.diskSize, dataDistribution = dataDistribution, partitions = partitions ) } }
Example 67
Source File: AllJobsResource.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.{Arrays, Date, List => JList} import javax.ws.rs._ import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.JobProgressListener import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllJobsResource(ui: SparkUI) { @GET def jobsList(@QueryParam("status") statuses: JList[JobExecutionStatus]): Seq[JobData] = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val adjStatuses: JList[JobExecutionStatus] = { if (statuses.isEmpty) { Arrays.asList(JobExecutionStatus.values(): _*) } else { statuses } } val jobInfos = for { (status, jobs) <- statusToJobs job <- jobs if adjStatuses.contains(status) } yield { AllJobsResource.convertJobData(job, ui.jobProgressListener, false) } jobInfos.sortBy{- _.jobId} } } private[v1] object AllJobsResource { def getStatusToJobs(ui: SparkUI): Seq[(JobExecutionStatus, Seq[JobUIData])] = { val statusToJobs = ui.jobProgressListener.synchronized { Seq( JobExecutionStatus.RUNNING -> ui.jobProgressListener.activeJobs.values.toSeq, JobExecutionStatus.SUCCEEDED -> ui.jobProgressListener.completedJobs.toSeq, JobExecutionStatus.FAILED -> ui.jobProgressListener.failedJobs.reverse.toSeq ) } statusToJobs } def convertJobData( job: JobUIData, listener: JobProgressListener, includeStageDetails: Boolean): JobData = { listener.synchronized { val lastStageInfo = if (job.stageIds.isEmpty) { None } else { listener.stageIdToInfo.get(job.stageIds.max) } val lastStageData = lastStageInfo.flatMap { s => listener.stageIdToData.get((s.stageId, s.attemptId)) } val lastStageName = lastStageInfo.map { _.name }.getOrElse("(Unknown Stage Name)") val lastStageDescription = lastStageData.flatMap { _.description } new JobData( jobId = job.jobId, name = lastStageName, description = lastStageDescription, submissionTime = job.submissionTime.map{new Date(_)}, completionTime = job.completionTime.map{new Date(_)}, stageIds = job.stageIds, jobGroup = job.jobGroup, status = job.status, numTasks = job.numTasks, numActiveTasks = job.numActiveTasks, numCompletedTasks = job.numCompletedTasks, numSkippedTasks = job.numSkippedTasks, numFailedTasks = job.numFailedTasks, numActiveStages = job.numActiveStages, numCompletedStages = job.completedStageIndices.size, numSkippedStages = job.numSkippedStages, numFailedStages = job.numFailedStages ) } } }
Example 68
Source File: StreamingTab.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.streaming.ui import org.apache.spark.SparkException import org.apache.spark.internal.Logging import org.apache.spark.streaming.StreamingContext import org.apache.spark.ui.{SparkUI, SparkUITab} private[spark] class StreamingTab(val ssc: StreamingContext) extends SparkUITab(StreamingTab.getSparkUI(ssc), "streaming") with Logging { import StreamingTab._ private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static" val parent = getSparkUI(ssc) val listener = ssc.progressListener ssc.addStreamingListener(listener) ssc.sc.addSparkListener(listener) attachPage(new StreamingPage(this)) attachPage(new BatchPage(this)) def attach() { getSparkUI(ssc).attachTab(this) getSparkUI(ssc).addStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming") } def detach() { getSparkUI(ssc).detachTab(this) getSparkUI(ssc).removeStaticHandler("/static/streaming") } } private object StreamingTab { def getSparkUI(ssc: StreamingContext): SparkUI = { ssc.sc.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 69
Source File: ThriftServerTab.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.thriftserver.HiveThriftServer2 import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} private[thriftserver] class ThriftServerTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" val parent = getSparkUI(sparkContext) val listener = HiveThriftServer2.listener attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 70
Source File: ThriftServerTab.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.ui import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.internal.Logging import org.apache.spark.sql.hive.thriftserver.monitor.ThriftServerMonitor import org.apache.spark.sql.hive.thriftserver.ui.ThriftServerTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} private[thriftserver] class ThriftServerTab(userName: String, sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "sqlserver") with Logging { override val name = "JDBC/ODBC Server" val parent = getSparkUI(sparkContext) // ThriftServerTab renders by different listener's content, identified by user. val listener = ThriftServerMonitor.getListener(userName) attachPage(new ThriftServerPage(this)) attachPage(new ThriftServerSessionPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[thriftserver] object ThriftServerTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 71
Source File: JobsTab.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") { val sc = parent.sc val killEnabled = parent.killEnabled val jobProgresslistener = parent.jobProgressListener val executorListener = parent.executorsListener val operationGraphListener = parent.operationGraphListener def isFairScheduler: Boolean = jobProgresslistener.schedulingMode == Some(SchedulingMode.FAIR) def getSparkUser: String = parent.getSparkUser attachPage(new AllJobsPage(this)) attachPage(new JobPage(this)) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val jobId = Option(request.getParameter("id")).map(_.toInt) jobId.foreach { id => if (jobProgresslistener.activeJobs.contains(id)) { sc.foreach(_.cancelJob(id)) // Do a quick pause here to give Spark time to kill the job so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } } } }
Example 72
Source File: StagesTab.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages") { val sc = parent.sc val conf = parent.conf val killEnabled = parent.killEnabled val progressListener = parent.jobProgressListener val operationGraphListener = parent.operationGraphListener val executorsListener = parent.executorsListener attachPage(new AllStagesPage(this)) attachPage(new StagePage(this)) attachPage(new PoolPage(this)) def isFairScheduler: Boolean = progressListener.schedulingMode == Some(SchedulingMode.FAIR) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val stageId = Option(request.getParameter("id")).map(_.toInt) stageId.foreach { id => if (progressListener.activeStages.contains(id)) { sc.foreach(_.cancelStage(id)) // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } } } }
Example 73
Source File: WorkerWebUI.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.deploy.worker.Worker import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr, worker.conf)) } } private[worker] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR val DEFAULT_RETAINED_DRIVERS = 1000 val DEFAULT_RETAINED_EXECUTORS = 1000 }
Example 74
Source File: MasterWebUI.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.master.ui import scala.collection.mutable.HashMap import org.eclipse.jetty.servlet.ServletContextHandler import org.apache.spark.deploy.master.Master import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ def initialize() { val masterPage = new MasterPage(this) attachPage(new ApplicationPage(this)) attachPage(masterPage) attachHandler(createStaticHandler(MasterWebUI.STATIC_RESOURCE_DIR, "/static")) attachHandler(createRedirectHandler( "/app/kill", "/", masterPage.handleAppKillRequest, httpMethods = Set("POST"))) attachHandler(createRedirectHandler( "/driver/kill", "/", masterPage.handleDriverKillRequest, httpMethods = Set("POST"))) } def addProxyTargets(id: String, target: String): Unit = { var endTarget = target.stripSuffix("/") val handler = createProxyHandler("/proxy/" + id, endTarget) attachHandler(handler) proxyHandlers(id) = handler } def removeProxyTargets(id: String): Unit = { proxyHandlers.remove(id).foreach(detachHandler) } } private[master] object MasterWebUI { private val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 75
Source File: ExecutorListResource.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class ExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. val storageStatusList = listener.activeStorageStatusList (0 until storageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = true) } } } }
Example 76
Source File: AllExecutorListResource.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.ui.SparkUI import org.apache.spark.ui.exec.ExecutorsPage @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllExecutorListResource(ui: SparkUI) { @GET def executorList(): Seq[ExecutorSummary] = { val listener = ui.executorsListener listener.synchronized { // The follow codes should be protected by `listener` to make sure no executors will be // removed before we query their status. See SPARK-12784. (0 until listener.activeStorageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = true) } ++ (0 until listener.deadStorageStatusList.size).map { statusId => ExecutorsPage.getExecInfo(listener, statusId, isActive = false) } } } }
Example 77
Source File: OneJobResource.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, PathParam, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class OneJobResource(ui: SparkUI) { @GET def oneJob(@PathParam("jobId") jobId: Int): JobData = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val jobOpt = statusToJobs.flatMap(_._2).find { jobInfo => jobInfo.jobId == jobId} jobOpt.map { job => AllJobsResource.convertJobData(job, ui.jobProgressListener, false) }.getOrElse { throw new NotFoundException("unknown job: " + jobId) } } }
Example 78
Source File: AllRDDResource.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import javax.ws.rs.{GET, Produces} import javax.ws.rs.core.MediaType import org.apache.spark.storage.{RDDInfo, StorageStatus, StorageUtils} import org.apache.spark.ui.SparkUI import org.apache.spark.ui.storage.StorageListener @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllRDDResource(ui: SparkUI) { @GET def rddList(): Seq[RDDStorageInfo] = { val storageStatusList = ui.storageListener.activeStorageStatusList val rddInfos = ui.storageListener.rddInfoList rddInfos.map{rddInfo => AllRDDResource.getRDDStorageInfo(rddInfo.id, rddInfo, storageStatusList, includeDetails = false) } } } private[spark] object AllRDDResource { def getRDDStorageInfo( rddId: Int, listener: StorageListener, includeDetails: Boolean): Option[RDDStorageInfo] = { val storageStatusList = listener.activeStorageStatusList listener.rddInfoList.find { _.id == rddId }.map { rddInfo => getRDDStorageInfo(rddId, rddInfo, storageStatusList, includeDetails) } } def getRDDStorageInfo( rddId: Int, rddInfo: RDDInfo, storageStatusList: Seq[StorageStatus], includeDetails: Boolean): RDDStorageInfo = { val workers = storageStatusList.map { (rddId, _) } val blockLocations = StorageUtils.getRddBlockLocations(rddId, storageStatusList) val blocks = storageStatusList .flatMap { _.rddBlocksById(rddId) } .sortWith { _._1.name < _._1.name } .map { case (blockId, status) => (blockId, status, blockLocations.getOrElse(blockId, Seq[String]("Unknown"))) } val dataDistribution = if (includeDetails) { Some(storageStatusList.map { status => new RDDDataDistribution( address = status.blockManagerId.hostPort, memoryUsed = status.memUsedByRdd(rddId), memoryRemaining = status.memRemaining, diskUsed = status.diskUsedByRdd(rddId) ) } ) } else { None } val partitions = if (includeDetails) { Some(blocks.map { case (id, block, locations) => new RDDPartitionInfo( blockName = id.name, storageLevel = block.storageLevel.description, memoryUsed = block.memSize, diskUsed = block.diskSize, executors = locations ) } ) } else { None } new RDDStorageInfo( id = rddId, name = rddInfo.name, numPartitions = rddInfo.numPartitions, numCachedPartitions = rddInfo.numCachedPartitions, storageLevel = rddInfo.storageLevel.description, memoryUsed = rddInfo.memSize, diskUsed = rddInfo.diskSize, dataDistribution = dataDistribution, partitions = partitions ) } }
Example 79
Source File: AllJobsResource.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.{Arrays, Date, List => JList} import javax.ws.rs._ import javax.ws.rs.core.MediaType import org.apache.spark.JobExecutionStatus import org.apache.spark.ui.SparkUI import org.apache.spark.ui.jobs.JobProgressListener import org.apache.spark.ui.jobs.UIData.JobUIData @Produces(Array(MediaType.APPLICATION_JSON)) private[v1] class AllJobsResource(ui: SparkUI) { @GET def jobsList(@QueryParam("status") statuses: JList[JobExecutionStatus]): Seq[JobData] = { val statusToJobs: Seq[(JobExecutionStatus, Seq[JobUIData])] = AllJobsResource.getStatusToJobs(ui) val adjStatuses: JList[JobExecutionStatus] = { if (statuses.isEmpty) { Arrays.asList(JobExecutionStatus.values(): _*) } else { statuses } } val jobInfos = for { (status, jobs) <- statusToJobs job <- jobs if adjStatuses.contains(status) } yield { AllJobsResource.convertJobData(job, ui.jobProgressListener, false) } jobInfos.sortBy{- _.jobId} } } private[v1] object AllJobsResource { def getStatusToJobs(ui: SparkUI): Seq[(JobExecutionStatus, Seq[JobUIData])] = { val statusToJobs = ui.jobProgressListener.synchronized { Seq( JobExecutionStatus.RUNNING -> ui.jobProgressListener.activeJobs.values.toSeq, JobExecutionStatus.SUCCEEDED -> ui.jobProgressListener.completedJobs.toSeq, JobExecutionStatus.FAILED -> ui.jobProgressListener.failedJobs.reverse.toSeq ) } statusToJobs } def convertJobData( job: JobUIData, listener: JobProgressListener, includeStageDetails: Boolean): JobData = { listener.synchronized { val lastStageInfo = if (job.stageIds.isEmpty) { None } else { listener.stageIdToInfo.get(job.stageIds.max) } val lastStageData = lastStageInfo.flatMap { s => listener.stageIdToData.get((s.stageId, s.attemptId)) } val lastStageName = lastStageInfo.map { _.name }.getOrElse("(Unknown Stage Name)") val lastStageDescription = lastStageData.flatMap { _.description } new JobData( jobId = job.jobId, name = lastStageName, description = lastStageDescription, submissionTime = job.submissionTime.map{new Date(_)}, completionTime = job.completionTime.map{new Date(_)}, stageIds = job.stageIds, jobGroup = job.jobGroup, status = job.status, numTasks = job.numTasks, numActiveTasks = job.numActiveTasks, numCompletedTasks = job.numCompletedTasks, numSkippedTasks = job.numSkippedTasks, numFailedTasks = job.numFailedTasks, numActiveStages = job.numActiveStages, numCompletedStages = job.completedStageIndices.size, numSkippedStages = job.numSkippedStages, numFailedStages = job.numFailedStages ) } } }
Example 80
Source File: StreamingTab.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.streaming.ui import org.apache.spark.SparkException import org.apache.spark.internal.Logging import org.apache.spark.streaming.StreamingContext import org.apache.spark.ui.{SparkUI, SparkUITab} private[spark] class StreamingTab(val ssc: StreamingContext) extends SparkUITab(StreamingTab.getSparkUI(ssc), "streaming") with Logging { import StreamingTab._ private val STATIC_RESOURCE_DIR = "org/apache/spark/streaming/ui/static" val parent = getSparkUI(ssc) val listener = ssc.progressListener ssc.addStreamingListener(listener) ssc.sc.addSparkListener(listener) attachPage(new StreamingPage(this)) attachPage(new BatchPage(this)) def attach() { getSparkUI(ssc).attachTab(this) getSparkUI(ssc).addStaticHandler(STATIC_RESOURCE_DIR, "/static/streaming") } def detach() { getSparkUI(ssc).detachTab(this) getSparkUI(ssc).removeStaticHandler("/static/streaming") } } private object StreamingTab { def getSparkUI(ssc: StreamingContext): SparkUI = { ssc.sc.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 81
Source File: MesosClusterUI.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.mesos.ui import org.apache.spark.{SecurityManager, SparkConf} import org.apache.spark.scheduler.cluster.mesos.MesosClusterScheduler import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ private[spark] class MesosClusterUI( securityManager: SecurityManager, port: Int, val conf: SparkConf, dispatcherPublicAddress: String, val scheduler: MesosClusterScheduler) extends WebUI(securityManager, securityManager.getSSLOptions("mesos"), port, conf) { initialize() def activeWebUiUrl: String = "http://" + dispatcherPublicAddress + ":" + boundPort override def initialize() { attachPage(new MesosClusterPage(this)) attachPage(new DriverPage(this)) attachHandler(createStaticHandler(MesosClusterUI.STATIC_RESOURCE_DIR, "/static")) } } private object MesosClusterUI { val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 82
Source File: MesosClusterUI.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.mesos.ui import org.apache.spark.{SecurityManager, SparkConf} import org.apache.spark.scheduler.cluster.mesos.MesosClusterScheduler import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ private[spark] class MesosClusterUI( securityManager: SecurityManager, port: Int, val conf: SparkConf, dispatcherPublicAddress: String, val scheduler: MesosClusterScheduler) extends WebUI(securityManager, securityManager.getSSLOptions("mesos"), port, conf) { initialize() def activeWebUiUrl: String = "http://" + dispatcherPublicAddress + ":" + boundPort override def initialize() { attachPage(new MesosClusterPage(this)) attachPage(new DriverPage(this)) attachHandler(createStaticHandler(MesosClusterUI.STATIC_RESOURCE_DIR, "/static")) } } private object MesosClusterUI { val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }
Example 83
Source File: DruidQueriesTab.scala From spark-druid-olap with Apache License 2.0 | 5 votes |
package org.apache.spark.sql.hive.thriftserver.sparklinedata.ui import org.apache.spark.sql.hive.thriftserver.sparklinedata.ui.DruidQueriesTab._ import org.apache.spark.ui.{SparkUI, SparkUITab} import org.apache.spark.{SparkContext, SparkException} import org.apache.spark.sql.SPLLogging private[thriftserver] class DruidQueriesTab(sparkContext: SparkContext) extends SparkUITab(getSparkUI(sparkContext), "druid") with SPLLogging { override val name = "Druid Query Details" val parent = getSparkUI(sparkContext) attachPage(new DruidQueriesPage(this)) parent.attachTab(this) def detach() { getSparkUI(sparkContext).detachTab(this) } } private[spark] object DruidQueriesTab { def getSparkUI(sparkContext: SparkContext): SparkUI = { sparkContext.ui.getOrElse { throw new SparkException("Parent SparkUI to attach this tab to not found!") } } }
Example 84
Source File: HistoryServerSuite.scala From SparkCore with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.history import javax.servlet.http.HttpServletRequest import scala.collection.mutable import org.apache.hadoop.fs.Path import org.mockito.Mockito.{when} import org.scalatest.FunSuite import org.scalatest.Matchers import org.scalatest.mock.MockitoSugar import org.apache.spark.ui.SparkUI class HistoryServerSuite extends FunSuite with Matchers with MockitoSugar { test("generate history page with relative links") { val historyServer = mock[HistoryServer] val request = mock[HttpServletRequest] val ui = mock[SparkUI] val link = "/history/app1" val info = new ApplicationHistoryInfo("app1", "app1", 0, 2, 1, "xxx", true) when(historyServer.getApplicationList()).thenReturn(Seq(info)) when(ui.basePath).thenReturn(link) when(historyServer.getProviderConfig()).thenReturn(Map[String, String]()) val page = new HistoryPage(historyServer) //when val response = page.render(request) //then val links = response \\ "a" val justHrefs = for { l <- links attrs <- l.attribute("href") } yield (attrs.toString) justHrefs should contain(link) } }
Example 85
Source File: StagesTab.scala From SparkCore with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages") { val sc = parent.sc val killEnabled = parent.killEnabled val listener = parent.jobProgressListener attachPage(new AllStagesPage(this)) attachPage(new StagePage(this)) attachPage(new PoolPage(this)) def isFairScheduler = listener.schedulingMode.exists(_ == SchedulingMode.FAIR) def handleKillRequest(request: HttpServletRequest) = { if ((killEnabled) && (parent.securityManager.checkModifyPermissions(request.getRemoteUser))) { val killFlag = Option(request.getParameter("terminate")).getOrElse("false").toBoolean val stageId = Option(request.getParameter("id")).getOrElse("-1").toInt if (stageId >= 0 && killFlag && listener.activeStages.contains(stageId)) { sc.get.cancelStage(stageId) } // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } }
Example 86
Source File: ExecutorsTab.scala From SparkCore with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.exec import scala.collection.mutable.HashMap import org.apache.spark.ExceptionFailure import org.apache.spark.annotation.DeveloperApi import org.apache.spark.scheduler._ import org.apache.spark.storage.StorageStatusListener import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class ExecutorsTab(parent: SparkUI) extends SparkUITab(parent, "executors") { val listener = parent.executorsListener val sc = parent.sc val threadDumpEnabled = sc.isDefined && parent.conf.getBoolean("spark.ui.threadDumpsEnabled", true) attachPage(new ExecutorsPage(this, threadDumpEnabled)) if (threadDumpEnabled) { attachPage(new ExecutorThreadDumpPage(this)) } } @DeveloperApi class ExecutorsListener(storageStatusListener: StorageStatusListener) extends SparkListener { val executorToTasksActive = HashMap[String, Int]() val executorToTasksComplete = HashMap[String, Int]() val executorToTasksFailed = HashMap[String, Int]() val executorToDuration = HashMap[String, Long]() val executorToInputBytes = HashMap[String, Long]() val executorToInputRecords = HashMap[String, Long]() val executorToOutputBytes = HashMap[String, Long]() val executorToOutputRecords = HashMap[String, Long]() val executorToShuffleRead = HashMap[String, Long]() val executorToShuffleWrite = HashMap[String, Long]() val executorToLogUrls = HashMap[String, Map[String, String]]() def storageStatusList = storageStatusListener.storageStatusList override def onExecutorAdded(executorAdded: SparkListenerExecutorAdded) = synchronized { val eid = executorAdded.executorId executorToLogUrls(eid) = executorAdded.executorInfo.logUrlMap } override def onTaskStart(taskStart: SparkListenerTaskStart) = synchronized { val eid = taskStart.taskInfo.executorId executorToTasksActive(eid) = executorToTasksActive.getOrElse(eid, 0) + 1 } override def onTaskEnd(taskEnd: SparkListenerTaskEnd) = synchronized { val info = taskEnd.taskInfo if (info != null) { val eid = info.executorId executorToTasksActive(eid) = executorToTasksActive.getOrElse(eid, 1) - 1 executorToDuration(eid) = executorToDuration.getOrElse(eid, 0L) + info.duration taskEnd.reason match { case e: ExceptionFailure => executorToTasksFailed(eid) = executorToTasksFailed.getOrElse(eid, 0) + 1 case _ => executorToTasksComplete(eid) = executorToTasksComplete.getOrElse(eid, 0) + 1 } // Update shuffle read/write val metrics = taskEnd.taskMetrics if (metrics != null) { metrics.inputMetrics.foreach { inputMetrics => executorToInputBytes(eid) = executorToInputBytes.getOrElse(eid, 0L) + inputMetrics.bytesRead executorToInputRecords(eid) = executorToInputRecords.getOrElse(eid, 0L) + inputMetrics.recordsRead } metrics.outputMetrics.foreach { outputMetrics => executorToOutputBytes(eid) = executorToOutputBytes.getOrElse(eid, 0L) + outputMetrics.bytesWritten executorToOutputRecords(eid) = executorToOutputRecords.getOrElse(eid, 0L) + outputMetrics.recordsWritten } metrics.shuffleReadMetrics.foreach { shuffleRead => executorToShuffleRead(eid) = executorToShuffleRead.getOrElse(eid, 0L) + shuffleRead.remoteBytesRead } metrics.shuffleWriteMetrics.foreach { shuffleWrite => executorToShuffleWrite(eid) = executorToShuffleWrite.getOrElse(eid, 0L) + shuffleWrite.shuffleBytesWritten } } } } }
Example 87
Source File: WorkerWebUI.scala From SparkCore with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.{Logging, SparkConf} import org.apache.spark.deploy.worker.Worker import org.apache.spark.deploy.worker.ui.WorkerWebUI._ import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.AkkaUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr)) } } private[spark] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR }
Example 88
Source File: JobsTab.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") { val sc = parent.sc val killEnabled = parent.killEnabled val jobProgresslistener = parent.jobProgressListener val executorListener = parent.executorsListener val operationGraphListener = parent.operationGraphListener val hdfsExecutorMetricsListener = parent.hDFSExecutorMetricsListener def isFairScheduler: Boolean = jobProgresslistener.schedulingMode == Some(SchedulingMode.FAIR) def getSparkUser: String = parent.getSparkUser attachPage(new AllJobsPage(this)) attachPage(new JobPage(this)) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val jobId = Option(request.getParameter("id")).map(_.toInt) jobId.foreach { id => if (jobProgresslistener.activeJobs.contains(id)) { sc.foreach(_.cancelJob(id)) // Do a quick pause here to give Spark time to kill the job so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } } } }
Example 89
Source File: StagesTab.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.ui.jobs import javax.servlet.http.HttpServletRequest import org.apache.spark.scheduler.SchedulingMode import org.apache.spark.ui.{SparkUI, SparkUITab} private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages") { val sc = parent.sc val conf = parent.conf val killEnabled = parent.killEnabled val progressListener = parent.jobProgressListener val operationGraphListener = parent.operationGraphListener val executorsListener = parent.executorsListener attachPage(new AllStagesPage(this)) attachPage(new StagePage(this)) attachPage(new PoolPage(this)) def isFairScheduler: Boolean = progressListener.schedulingMode == Some(SchedulingMode.FAIR) def handleKillRequest(request: HttpServletRequest): Unit = { if (killEnabled && parent.securityManager.checkModifyPermissions(request.getRemoteUser)) { val stageId = Option(request.getParameter("id")).map(_.toInt) stageId.foreach { id => if (progressListener.activeStages.contains(id)) { sc.foreach(_.cancelStage(id)) // Do a quick pause here to give Spark time to kill the stage so it shows up as // killed after the refresh. Note that this will block the serving thread so the // time should be limited in duration. Thread.sleep(100) } } } } }
Example 90
Source File: WorkerWebUI.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.worker.ui import java.io.File import javax.servlet.http.HttpServletRequest import org.apache.spark.deploy.worker.Worker import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ import org.apache.spark.util.RpcUtils def initialize() { val logPage = new LogPage(this) attachPage(logPage) attachPage(new WorkerPage(this)) attachHandler(createStaticHandler(WorkerWebUI.STATIC_RESOURCE_BASE, "/static")) attachHandler(createServletHandler("/log", (request: HttpServletRequest) => logPage.renderLog(request), worker.securityMgr, worker.conf)) } } private[worker] object WorkerWebUI { val STATIC_RESOURCE_BASE = SparkUI.STATIC_RESOURCE_DIR val DEFAULT_RETAINED_DRIVERS = 1000 val DEFAULT_RETAINED_EXECUTORS = 1000 }
Example 91
Source File: MasterWebUI.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.deploy.master.ui import scala.collection.mutable.HashMap import org.eclipse.jetty.servlet.ServletContextHandler import org.apache.spark.deploy.master.Master import org.apache.spark.internal.Logging import org.apache.spark.ui.{SparkUI, WebUI} import org.apache.spark.ui.JettyUtils._ def initialize() { val masterPage = new MasterPage(this) attachPage(new ApplicationPage(this)) attachPage(masterPage) attachHandler(createStaticHandler(MasterWebUI.STATIC_RESOURCE_DIR, "/static")) attachHandler(createRedirectHandler( "/app/kill", "/", masterPage.handleAppKillRequest, httpMethods = Set("POST"))) attachHandler(createRedirectHandler( "/driver/kill", "/", masterPage.handleDriverKillRequest, httpMethods = Set("POST"))) } def addProxyTargets(id: String, target: String): Unit = { var endTarget = target.stripSuffix("/") val handler = createProxyHandler("/proxy/" + id, endTarget) attachHandler(handler) proxyHandlers(id) = handler } def removeProxyTargets(id: String): Unit = { proxyHandlers.remove(id).foreach(detachHandler) } } private[master] object MasterWebUI { private val STATIC_RESOURCE_DIR = SparkUI.STATIC_RESOURCE_DIR }