Skip to content

Commit c81ef85

Browse files
authored
[#1805] feat(spark): Support Spark 4 in client-spark/extension (#2749)
Spark 4 switched the UI servlet API from javax.servlet (Jetty 9) to jakarta.servlet (Jetty 11+). WebUIPage.render must override its parent signature exactly, so the same .scala file cannot serve both. Route extension through a ServletCompat type alias backed by two version-specific source roots (scala-javax / scala-jakarta). The build-helper-maven-plugin picks one via ${extension.servlet.source.dir}, switched by a spark4 profile in this module's pom that merges with the root pom's spark4 profile. Other changes: - Add client-spark/extension to the root pom's spark4 profile modules. - Add rss-client-spark-ui dependency to client-spark/spark4/pom.xml, mirroring client-spark/spark3/pom.xml. - Bump build-helper-maven-plugin 1.10 -> 3.6.0. - Contributor notes document new-variant and new-spark-version steps, IDE re-import on profile switch, and ~/.m2 hygiene. Verified: extension compiles cleanly under spark3 / spark3.0 / spark3.2 / spark3.2.0 / spark3.3 / spark3.4 / spark3.5 / spark4 profiles.
1 parent c18774d commit c81ef85

6 files changed

Lines changed: 113 additions & 2 deletions

File tree

client-spark/extension/pom.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,31 @@
3333
<packaging>jar</packaging>
3434
<name>Apache Uniffle Client spark ui</name>
3535

36+
<!--
37+
WebUIPage.render's request parameter uses javax.servlet in Spark 3
38+
and jakarta.servlet in Spark 4. A single ShufflePage.scala cannot
39+
override both signatures, so the module ships two source roots
40+
(src/main/scala-javax and src/main/scala-jakarta), each with its
41+
own ServletCompat aliasing HttpServletRequest to the matching
42+
package. build-helper-maven-plugin picks one via
43+
${extension.servlet.source.dir}; the javax variant is the default
44+
and the spark4 profile at the bottom of this pom overrides it.
45+
46+
To add another servlet flavor, create src/main/scala-<flavor>/
47+
with a mirrored ServletCompat (same aliases), then point a new
48+
profile at it. Keep aliases in lock-step across every variant.
49+
50+
rss-client-spark-ui is published under a single Maven coordinate,
51+
but different profiles produce incompatible bytecode (servlet +
52+
Scala binary). Run `mvn clean` between profiles locally; shipping
53+
multiple profile builds to the same remote coordinate is out of
54+
scope for this module.
55+
-->
56+
<properties>
57+
<!-- Overridden by the spark4 profile below. -->
58+
<extension.servlet.source.dir>src/main/scala-javax</extension.servlet.source.dir>
59+
</properties>
60+
3661
<dependencies>
3762
<dependency>
3863
<groupId>org.apache.uniffle</groupId>
@@ -72,6 +97,24 @@
7297

7398
<build>
7499
<plugins>
100+
<plugin>
101+
<groupId>org.codehaus.mojo</groupId>
102+
<artifactId>build-helper-maven-plugin</artifactId>
103+
<executions>
104+
<execution>
105+
<id>add-servlet-compat-source</id>
106+
<phase>generate-sources</phase>
107+
<goals>
108+
<goal>add-source</goal>
109+
</goals>
110+
<configuration>
111+
<sources>
112+
<source>${extension.servlet.source.dir}</source>
113+
</sources>
114+
</configuration>
115+
</execution>
116+
</executions>
117+
</plugin>
75118
<plugin>
76119
<groupId>net.alchim31.maven</groupId>
77120
<artifactId>scala-maven-plugin</artifactId>
@@ -90,4 +133,14 @@
90133
</plugin>
91134
</plugins>
92135
</build>
136+
137+
<profiles>
138+
<profile>
139+
<!-- Merged with the root pom's spark4 profile by shared id. -->
140+
<id>spark4</id>
141+
<properties>
142+
<extension.servlet.source.dir>src/main/scala-jakarta</extension.servlet.source.dir>
143+
</properties>
144+
</profile>
145+
</profiles>
93146
</project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.ui
19+
20+
// jakarta.servlet variant of ServletCompat, picked up by the spark4
21+
// profile (see client-spark/extension/pom.xml). Every alias here must
22+
// also exist in the scala-javax/ variant — only the underlying servlet
23+
// package may differ.
24+
private[ui] object ServletCompat {
25+
type HttpServletRequest = jakarta.servlet.http.HttpServletRequest
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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.ui
19+
20+
// javax.servlet variant of ServletCompat, picked up by the default
21+
// ${extension.servlet.source.dir} (see client-spark/extension/pom.xml).
22+
// Every alias here must also exist in the scala-jakarta/ variant —
23+
// only the underlying servlet package may differ.
24+
private[ui] object ServletCompat {
25+
type HttpServletRequest = javax.servlet.http.HttpServletRequest
26+
}

client-spark/extension/src/main/scala/org/apache/spark/ui/ShufflePage.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
package org.apache.spark.ui
1919

2020
import org.apache.spark.internal.Logging
21+
import org.apache.spark.ui.ServletCompat.HttpServletRequest
2122
import org.apache.spark.util.Utils
2223
import org.apache.spark.{AggregatedShuffleMetric, AggregatedShuffleReadMetric, AggregatedShuffleWriteMetric, AggregatedTaskInfoUIData, ShuffleType}
2324

2425
import java.util.concurrent.ConcurrentHashMap
25-
import javax.servlet.http.HttpServletRequest
2626
import scala.collection.JavaConverters.{collectionAsScalaIterableConverter, mapAsScalaMapConverter}
2727
import scala.xml.{Node, NodeSeq}
2828

client-spark/spark4/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
<artifactId>rss-client-spark-common</artifactId>
6060
<version>${project.version}</version>
6161
</dependency>
62+
<dependency>
63+
<groupId>org.apache.uniffle</groupId>
64+
<artifactId>rss-client-spark-ui</artifactId>
65+
<version>${project.version}</version>
66+
</dependency>
6267
<dependency>
6368
<groupId>io.netty</groupId>
6469
<artifactId>netty-all</artifactId>

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@
945945
<plugin>
946946
<groupId>org.codehaus.mojo</groupId>
947947
<artifactId>build-helper-maven-plugin</artifactId>
948-
<version>1.10</version>
948+
<version>3.6.0</version>
949949
</plugin>
950950
<plugin>
951951
<groupId>org.codehaus.mojo</groupId>
@@ -2008,6 +2008,7 @@
20082008
<module>client-spark/spark4-shaded</module>
20092009
<module>integration-test/spark-common</module>
20102010
<module>integration-test/spark4</module>
2011+
<module>client-spark/extension</module>
20112012
</modules>
20122013
<dependencyManagement>
20132014
<dependencies>

0 commit comments

Comments
 (0)