Skip to content

Commit 359baa8

Browse files
squitojeanlyn
authored andcommitted
[SPARK-3454] separate json endpoints for data in the UI
Exposes data available in the UI as json over http. Key points: * new endpoints, handled independently of existing XyzPage classes. Root entrypoint is `JsonRootResource` * Uses jersey + jackson for routing & converting POJOs into json * tests against known results in `HistoryServerSuite` * also fixes some minor issues w/ the UI -- synchronizing on access to `StorageListener` & `StorageStatusListener`, and fixing some inconsistencies w/ the way we handle retained jobs & stages. Author: Imran Rashid <[email protected]> Closes apache#5940 from squito/SPARK-3454_better_test_files and squashes the following commits: 1a72ed6 [Imran Rashid] rats 85fdb3e [Imran Rashid] Merge branch 'no_php' into SPARK-3454 1fc65b0 [Imran Rashid] Revert "Revert "[SPARK-3454] separate json endpoints for data in the UI"" 1276900 [Imran Rashid] get rid of giant event file, replace w/ smaller one; check both shuffle read & shuffle write 4e12013 [Imran Rashid] just use test case name for expectation file name 863ef64 [Imran Rashid] rename json files to avoid strange file names and not look like php
1 parent 60ec267 commit 359baa8

File tree

100 files changed

+8608
-172
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+8608
-172
lines changed

.rat-excludes

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,12 @@ logs
7474
.*scalastyle-output.xml
7575
.*dependency-reduced-pom.xml
7676
known_translations
77+
json_expectation
78+
local-1422981759269/*
79+
local-1422981780767/*
80+
local-1425081759269/*
81+
local-1426533911241/*
82+
local-1426633911242/*
83+
local-1430917381534/*
7784
DESCRIPTION
7885
NAMESPACE

core/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,14 @@
228228
<artifactId>json4s-jackson_${scala.binary.version}</artifactId>
229229
<version>3.2.10</version>
230230
</dependency>
231+
<dependency>
232+
<groupId>com.sun.jersey</groupId>
233+
<artifactId>jersey-server</artifactId>
234+
</dependency>
235+
<dependency>
236+
<groupId>com.sun.jersey</groupId>
237+
<artifactId>jersey-core</artifactId>
238+
</dependency>
231239
<dependency>
232240
<groupId>org.apache.mesos</groupId>
233241
<artifactId>mesos</artifactId>

core/src/main/java/org/apache/spark/JobExecutionStatus.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717

1818
package org.apache.spark;
1919

20+
import org.apache.spark.util.EnumUtil;
21+
2022
public enum JobExecutionStatus {
2123
RUNNING,
2224
SUCCEEDED,
2325
FAILED,
24-
UNKNOWN
26+
UNKNOWN;
27+
28+
public static JobExecutionStatus fromString(String str) {
29+
return EnumUtil.parseIgnoreCase(JobExecutionStatus.class, str);
30+
}
2531
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.status.api.v1;
19+
20+
import org.apache.spark.util.EnumUtil;
21+
22+
public enum ApplicationStatus {
23+
COMPLETED,
24+
RUNNING;
25+
26+
public static ApplicationStatus fromString(String str) {
27+
return EnumUtil.parseIgnoreCase(ApplicationStatus.class, str);
28+
}
29+
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.status.api.v1;
19+
20+
import org.apache.spark.util.EnumUtil;
21+
22+
public enum StageStatus {
23+
ACTIVE,
24+
COMPLETE,
25+
FAILED,
26+
PENDING;
27+
28+
public static StageStatus fromString(String str) {
29+
return EnumUtil.parseIgnoreCase(StageStatus.class, str);
30+
}
31+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.status.api.v1;
19+
20+
import org.apache.spark.util.EnumUtil;
21+
22+
import java.util.HashSet;
23+
import java.util.Set;
24+
25+
public enum TaskSorting {
26+
ID,
27+
INCREASING_RUNTIME("runtime"),
28+
DECREASING_RUNTIME("-runtime");
29+
30+
private final Set<String> alternateNames;
31+
private TaskSorting(String... names) {
32+
alternateNames = new HashSet<String>();
33+
for (String n: names) {
34+
alternateNames.add(n);
35+
}
36+
}
37+
38+
public static TaskSorting fromString(String str) {
39+
String lower = str.toLowerCase();
40+
for (TaskSorting t: values()) {
41+
if (t.alternateNames.contains(lower)) {
42+
return t;
43+
}
44+
}
45+
return EnumUtil.parseIgnoreCase(TaskSorting.class, str);
46+
}
47+
48+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.spark.util;
18+
19+
import com.google.common.base.Joiner;
20+
import org.apache.spark.annotation.Private;
21+
22+
@Private
23+
public class EnumUtil {
24+
public static <E extends Enum<E>> E parseIgnoreCase(Class<E> clz, String str) {
25+
E[] constants = clz.getEnumConstants();
26+
if (str == null) {
27+
return null;
28+
}
29+
for (E e : constants) {
30+
if (e.name().equalsIgnoreCase(str)) {
31+
return e;
32+
}
33+
}
34+
throw new IllegalArgumentException(
35+
String.format("Illegal type='%s'. Supported type values: %s",
36+
str, Joiner.on(", ").join(constants)));
37+
}
38+
}

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
430430
_ui =
431431
if (conf.getBoolean("spark.ui.enabled", true)) {
432432
Some(SparkUI.createLiveUI(this, _conf, listenerBus, _jobProgressListener,
433-
_env.securityManager,appName))
433+
_env.securityManager,appName, startTime = startTime))
434434
} else {
435435
// For tests, do not enable the UI
436436
None

core/src/main/scala/org/apache/spark/deploy/history/ApplicationHistoryProvider.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ package org.apache.spark.deploy.history
1919

2020
import org.apache.spark.ui.SparkUI
2121

22-
private[history] case class ApplicationAttemptInfo(
22+
private[spark] case class ApplicationAttemptInfo(
2323
attemptId: Option[String],
2424
startTime: Long,
2525
endTime: Long,
2626
lastUpdated: Long,
2727
sparkUser: String,
2828
completed: Boolean = false)
2929

30-
private[history] case class ApplicationHistoryInfo(
30+
private[spark] case class ApplicationHistoryInfo(
3131
id: String,
3232
name: String,
3333
attempts: List[ApplicationAttemptInfo])

core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,21 @@
1717

1818
package org.apache.spark.deploy.history
1919

20-
import java.io.{IOException, BufferedInputStream, FileNotFoundException, InputStream}
20+
import java.io.{BufferedInputStream, FileNotFoundException, IOException, InputStream}
2121
import java.util.concurrent.{ExecutorService, Executors, TimeUnit}
2222

2323
import scala.collection.mutable
24-
import scala.concurrent.duration.Duration
2524

26-
import com.google.common.util.concurrent.ThreadFactoryBuilder
27-
28-
import com.google.common.util.concurrent.MoreExecutors
29-
import org.apache.hadoop.fs.permission.AccessControlException
25+
import com.google.common.util.concurrent.{MoreExecutors, ThreadFactoryBuilder}
3026
import org.apache.hadoop.fs.{FileStatus, Path}
27+
import org.apache.hadoop.fs.permission.AccessControlException
28+
29+
import org.apache.spark.{Logging, SecurityManager, SparkConf}
3130
import org.apache.spark.deploy.SparkHadoopUtil
3231
import org.apache.spark.io.CompressionCodec
3332
import org.apache.spark.scheduler._
3433
import org.apache.spark.ui.SparkUI
3534
import org.apache.spark.util.{Clock, SystemClock, ThreadUtils, Utils}
36-
import org.apache.spark.{Logging, SecurityManager, SparkConf}
3735

3836
/**
3937
* A class that provides application history from event logs stored in the file system.
@@ -151,7 +149,7 @@ private[history] class FsHistoryProvider(conf: SparkConf, clock: Clock)
151149
val conf = this.conf.clone()
152150
val appSecManager = new SecurityManager(conf)
153151
SparkUI.createHistoryUI(conf, replayBus, appSecManager, appId,
154-
HistoryServer.getAttemptURI(appId, attempt.attemptId))
152+
HistoryServer.getAttemptURI(appId, attempt.attemptId), attempt.startTime)
155153
// Do not call ui.bind() to avoid creating a new server for each application
156154
}
157155

0 commit comments

Comments
 (0)