forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose UI data as json in new endpoints
- Loading branch information
Showing
64 changed files
with
2,401 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
core/src/main/java/org/apache/spark/status/api/StageStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.apache.spark.status.api;/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
public enum StageStatus { | ||
Active, | ||
Complete, | ||
Failed, | ||
Pending | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/main/scala/org/apache/spark/deploy/history/AllApplicationsJsonRoute.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.history | ||
|
||
import javax.servlet.http.HttpServletRequest | ||
|
||
import org.apache.spark.status.{UIRoot, StatusJsonRoute} | ||
import org.apache.spark.status.api.ApplicationInfo | ||
import org.apache.spark.deploy.master.{ApplicationInfo => InternalApplicationInfo} | ||
|
||
class AllApplicationsJsonRoute(val uiRoot: UIRoot) extends StatusJsonRoute[Seq[ApplicationInfo]] { | ||
|
||
override def renderJson(request: HttpServletRequest): Seq[ApplicationInfo] = { | ||
//TODO filter on some query params, eg. completed, minStartTime, etc | ||
uiRoot.getApplicationInfoList | ||
} | ||
|
||
} | ||
|
||
object AllApplicationsJsonRoute { | ||
def appHistoryInfoToPublicAppInfo(app: ApplicationHistoryInfo): ApplicationInfo = { | ||
ApplicationInfo( | ||
id = app.id, | ||
name = app.name, | ||
startTime = app.startTime, | ||
endTime = app.endTime, | ||
sparkUser = app.sparkUser, | ||
completed = app.completed | ||
) | ||
} | ||
|
||
def convertApplicationInfo(internal: InternalApplicationInfo, completed: Boolean): ApplicationInfo = { | ||
ApplicationInfo( | ||
id = internal.id, | ||
name = internal.desc.name, | ||
startTime = internal.startTime, | ||
endTime = internal.endTime, | ||
sparkUser = internal.desc.user, | ||
completed = completed | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
core/src/main/scala/org/apache/spark/deploy/history/OneApplicationJsonRoute.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.history | ||
|
||
import javax.servlet.http.HttpServletRequest | ||
|
||
import org.apache.spark.status.{UIRoot, JsonRequestHandler, StatusJsonRoute} | ||
import org.apache.spark.status.api.ApplicationInfo | ||
|
||
class OneApplicationJsonRoute(val uiRoot: UIRoot) extends StatusJsonRoute[ApplicationInfo] { | ||
override def renderJson(request: HttpServletRequest): ApplicationInfo = { | ||
val appIdOpt = JsonRequestHandler.extractAppId(request.getPathInfo) | ||
appIdOpt.map{ appId => | ||
val apps = uiRoot.getApplicationInfoList.find{_.id == appId} | ||
apps.getOrElse(throw new IllegalArgumentException("unknown app: " + appId)) | ||
}.getOrElse{ | ||
throw new IllegalArgumentException("no application id specified") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
core/src/main/scala/org/apache/spark/deploy/master/ui/MasterApplicationJsonRoute.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.deploy.master.ui | ||
|
||
import javax.servlet.http.HttpServletRequest | ||
|
||
import akka.pattern.ask | ||
|
||
import org.apache.spark.deploy.DeployMessages.{RequestMasterState, MasterStateResponse} | ||
import org.apache.spark.status.StatusJsonRoute | ||
import org.apache.spark.status.api.ApplicationInfo | ||
|
||
import scala.concurrent.Await | ||
|
||
class MasterApplicationJsonRoute(val parent: MasterWebUI) extends StatusJsonRoute[ApplicationInfo] { | ||
private val master = parent.masterActorRef | ||
private val timeout = parent.timeout | ||
|
||
|
||
override def renderJson(request: HttpServletRequest): ApplicationInfo = { | ||
//TODO not really the app id | ||
val appId = request.getPathInfo() | ||
println("pathInfo = " + request.getPathInfo()) | ||
val stateFuture = (master ? RequestMasterState)(timeout).mapTo[MasterStateResponse] | ||
val state = Await.result(stateFuture, timeout) | ||
state.activeApps.find(_.id == appId).orElse({ | ||
state.completedApps.find(_.id == appId) | ||
}).map{MasterJsonRoute.masterAppInfoToPublicAppInfo}.getOrElse(null) | ||
} | ||
} |
Oops, something went wrong.