-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-3454] separate json endpoints for data in the UI #4435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 114 commits
4b398d0
d1a8c92
b252e7a
e0356b6
bceb3a9
f0264a7
cba1ef6
4fdc39f
a4ab5aa
cd37845
b6a96a8
0c12b50
c7d884f
0dc3ea7
1b78cb7
017c755
56edce0
5598f19
18a8c45
b86e2b0
654cecf
d05f7a9
3377e61
00e9cc5
9c0c125
f7df095
56d2fc7
e91750a
b4c75ed
36e4062
84cd497
190c17a
dddbd29
0c96147
97d411f
73f1378
7fd156a
5f9df24
b86bcb0
dbfc7bf
fef6605
2382bef
0be5120
1f361c8
a066055
a61a43c
99764e1
9f28b7e
51eaedb
25cd894
eaf3bbb
e48ba32
a4b1397
aaba896
b2efcaf
ad27de8
63eb4a6
fdfc181
db61211
f5a5196
9922be0
674f8dc
1578a4a
2c8b7ee
b4a7863
1f53a66
e031719
b136e39
d2ef58d
101a698
f05ae89
d493b38
cf86175
9ea682c
c22b11f
f2e63ad
4c92af6
1ed0d07
0c6f968
a9c5cf1
a325563
7bd4d15
a157a2f
4a234d3
d2bde77
39ac29c
ba3d9d2
2e19be2
b2f8b91
31c79ce
52bbae8
f48a7b0
9d889d6
7bf1811
acb7ef6
dc8a7fe
f90680e
14ac3ed
befff0c
2af11e5
188762c
b87cd63
c9bae1c
9e51400
67008b4
7f3bc4e
56db31e
cbaf287
cc1febf
ec140a2
3347b72
f016182
5ae02ad
5e78b4f
da1e35f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,9 +17,15 @@ | |
|
|
||
| package org.apache.spark; | ||
|
|
||
| import org.apache.spark.util.EnumUtil; | ||
|
|
||
| public enum JobExecutionStatus { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be private? |
||
| RUNNING, | ||
| SUCCEEDED, | ||
| FAILED, | ||
| UNKNOWN | ||
| UNKNOWN; | ||
|
|
||
| public static JobExecutionStatus fromString(String str) { | ||
| return EnumUtil.parseIgnoreCase(JobExecutionStatus.class, str); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| /* | ||
| * 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.status.api.v1; | ||
|
|
||
| import org.apache.spark.util.EnumUtil; | ||
|
|
||
| public enum ApplicationStatus { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Private? |
||
| COMPLETED, | ||
| RUNNING; | ||
|
|
||
| public static ApplicationStatus fromString(String str) { | ||
| return EnumUtil.parseIgnoreCase(ApplicationStatus.class, str); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* | ||
| * 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.status.api.v1; | ||
|
|
||
| import org.apache.spark.util.EnumUtil; | ||
|
|
||
| public enum StageStatus { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Private? |
||
| ACTIVE, | ||
| COMPLETE, | ||
| FAILED, | ||
| PENDING; | ||
|
|
||
| public static StageStatus fromString(String str) { | ||
| return EnumUtil.parseIgnoreCase(StageStatus.class, str); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /* | ||
| * 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.status.api.v1; | ||
|
|
||
| import org.apache.spark.util.EnumUtil; | ||
|
|
||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| public enum TaskSorting { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These enums don't seem to be used outside of this package; could we get away with making them package-private, or will jackson/jersey complain? If that's not possible, we should probably tag them with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately jersey requires them to be public -- I'll tag w/
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually I think we need a new annotation here - we just want this to be totally private (@DeveloperAPI suggests we see a use case for end users). Mind adding a new @Private annotation?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we tag this one as Private? |
||
| ID, | ||
| INCREASING_RUNTIME("runtime"), | ||
| DECREASING_RUNTIME("-runtime"); | ||
|
|
||
| private final Set<String> alternateNames; | ||
| private TaskSorting(String... names) { | ||
| alternateNames = new HashSet<String>(); | ||
| for (String n: names) { | ||
| alternateNames.add(n); | ||
| } | ||
| } | ||
|
|
||
| public static TaskSorting fromString(String str) { | ||
| String lower = str.toLowerCase(); | ||
| for (TaskSorting t: values()) { | ||
| if (t.alternateNames.contains(lower)) { | ||
| return t; | ||
| } | ||
| } | ||
| return EnumUtil.parseIgnoreCase(TaskSorting.class, str); | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * 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.util; | ||
|
|
||
| import com.google.common.base.Joiner; | ||
| import org.apache.spark.annotation.Private; | ||
|
|
||
| @Private | ||
| public class EnumUtil { | ||
| public static <E extends Enum<E>> E parseIgnoreCase(Class<E> clz, String str) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this one is also just an internal API, if I'm understanding correctly. |
||
| E[] constants = clz.getEnumConstants(); | ||
| if (str == null) { | ||
| return null; | ||
| } | ||
| for (E e : constants) { | ||
| if (e.name().equalsIgnoreCase(str)) { | ||
| return e; | ||
| } | ||
| } | ||
| throw new IllegalArgumentException( | ||
| String.format("Illegal type='%s'. Supported type values: %s", | ||
| str, Joiner.on(", ").join(constants))); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * 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.annotation; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * A class that is considered private to the internals of Spark -- there is a high-likelihood | ||
| * they will be changed in future versions of Spark. | ||
| * | ||
| * This should be used only when the standard Scala / Java means of protecting classes are | ||
| * insufficient. In particular, Java has no equivalent of private[spark], so we use this annotation | ||
| * in its place. | ||
| * | ||
| * NOTE: If there exists a Scaladoc comment that immediately precedes this annotation, the first | ||
| * line of the comment must be ":: Private ::" with no trailing blank line. This is because | ||
| * of the known issue that Scaladoc displays only either the annotation or the comment, whichever | ||
| * comes first. | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, | ||
| ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE}) | ||
| public @interface Private {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ import org.eclipse.jetty.servlet.{ServletContextHandler, ServletHolder} | |
|
|
||
| import org.apache.spark.{Logging, SecurityManager, SparkConf} | ||
| import org.apache.spark.deploy.SparkHadoopUtil | ||
| import org.apache.spark.status.api.v1.{ApplicationInfo, ApplicationsListResource, JsonRootResource, UIRoot} | ||
| import org.apache.spark.ui.{SparkUI, UIUtils, WebUI} | ||
| import org.apache.spark.ui.JettyUtils._ | ||
| import org.apache.spark.util.{SignalLogger, Utils} | ||
|
|
@@ -45,7 +46,7 @@ class HistoryServer( | |
| provider: ApplicationHistoryProvider, | ||
| securityManager: SecurityManager, | ||
| port: Int) | ||
| extends WebUI(securityManager, port, conf) with Logging { | ||
| extends WebUI(securityManager, port, conf) with Logging with UIRoot { | ||
|
|
||
| // How many applications to retain | ||
| private val retainedApplications = conf.getInt("spark.history.retainedApplications", 50) | ||
|
|
@@ -56,7 +57,7 @@ class HistoryServer( | |
| require(parts.length == 1 || parts.length == 2, s"Invalid app key $key") | ||
| val ui = provider | ||
| .getAppUI(parts(0), if (parts.length > 1) Some(parts(1)) else None) | ||
| .getOrElse(throw new NoSuchElementException()) | ||
| .getOrElse(throw new NoSuchElementException(s"no app with key $key")) | ||
| attachSparkUI(ui) | ||
| ui | ||
| } | ||
|
|
@@ -113,6 +114,10 @@ class HistoryServer( | |
| } | ||
| } | ||
|
|
||
| def getSparkUI(appKey: String): Option[SparkUI] = { | ||
| Option(appCache.get(appKey)) | ||
| } | ||
|
|
||
| initialize() | ||
|
|
||
| /** | ||
|
|
@@ -123,6 +128,9 @@ class HistoryServer( | |
| */ | ||
| def initialize() { | ||
| attachPage(new HistoryPage(this)) | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: delete |
||
| attachHandler(JsonRootResource.getJsonServlet(this)) | ||
|
|
||
| attachHandler(createStaticHandler(SparkUI.STATIC_RESOURCE_DIR, "/static")) | ||
|
|
||
| val contextHandler = new ServletContextHandler | ||
|
|
@@ -160,7 +168,13 @@ class HistoryServer( | |
| * | ||
| * @return List of all known applications. | ||
| */ | ||
| def getApplicationList(): Iterable[ApplicationHistoryInfo] = provider.getListing() | ||
| def getApplicationList(): Iterable[ApplicationHistoryInfo] = { | ||
| provider.getListing() | ||
| } | ||
|
|
||
| def getApplicationInfoList: Iterator[ApplicationInfo] = { | ||
| getApplicationList().iterator.map(ApplicationsListResource.appHistoryInfoToPublicAppInfo) | ||
| } | ||
|
|
||
| /** | ||
| * Returns the provider configuration to show in the listing page. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this OK? or should the apache header go in the test resource files as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the header shouldn't go into those files