Skip to content

Commit 811b1c5

Browse files
committed
Revert "SPARK-1236 - Upgrade Jetty to 9.1.3.v20140225."
This reverts commit ca4bf8c.
1 parent 796977a commit 811b1c5

File tree

4 files changed

+46
-49
lines changed

4 files changed

+46
-49
lines changed

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import java.io.File
2121

2222
import org.eclipse.jetty.util.security.{Constraint, Password}
2323
import org.eclipse.jetty.security.authentication.DigestAuthenticator
24-
import org.eclipse.jetty.security.{ConstraintMapping, ConstraintSecurityHandler, HashLoginService}
24+
import org.eclipse.jetty.security.{ConstraintMapping, ConstraintSecurityHandler, HashLoginService, SecurityHandler}
2525

26-
import org.eclipse.jetty.server.{Server, ServerConnector}
26+
import org.eclipse.jetty.server.Server
27+
import org.eclipse.jetty.server.bio.SocketConnector
2728
import org.eclipse.jetty.server.handler.{DefaultHandler, HandlerList, ResourceHandler}
2829
import org.eclipse.jetty.util.thread.QueuedThreadPool
2930

@@ -42,24 +43,24 @@ private[spark] class ServerStateException(message: String) extends Exception(mes
4243
*/
4344
private[spark] class HttpServer(resourceBase: File, securityManager: SecurityManager)
4445
extends Logging {
45-
private var server: Server = _
46+
private var server: Server = null
4647
private var port: Int = -1
4748

4849
def start() {
4950
if (server != null) {
5051
throw new ServerStateException("Server is already started")
5152
} else {
5253
logInfo("Starting HTTP Server")
53-
val threadPool = new QueuedThreadPool
54-
threadPool.setDaemon(true)
55-
56-
server = new Server(threadPool)
57-
val connector = new ServerConnector(server)
58-
connector.setIdleTimeout(60 * 1000)
54+
server = new Server()
55+
val connector = new SocketConnector
56+
connector.setMaxIdleTime(60*1000)
5957
connector.setSoLingerTime(-1)
6058
connector.setPort(0)
6159
server.addConnector(connector)
6260

61+
val threadPool = new QueuedThreadPool
62+
threadPool.setDaemon(true)
63+
server.setThreadPool(threadPool)
6364
val resHandler = new ResourceHandler
6465
resHandler.setResourceBase(resourceBase.getAbsolutePath)
6566

@@ -78,7 +79,7 @@ private[spark] class HttpServer(resourceBase: File, securityManager: SecurityMan
7879
}
7980

8081
server.start()
81-
port = connector.getLocalPort
82+
port = server.getConnectors()(0).getLocalPort()
8283
}
8384
}
8485

core/src/main/scala/org/apache/spark/ui/JettyUtils.scala

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package org.apache.spark.ui
1919

2020
import java.net.InetSocketAddress
2121
import java.net.URL
22-
import javax.servlet.DispatcherType
2322
import javax.servlet.http.{HttpServlet, HttpServletResponse, HttpServletRequest}
2423

2524
import scala.annotation.tailrec
@@ -29,7 +28,7 @@ import scala.xml.Node
2928
import org.json4s.JValue
3029
import org.json4s.jackson.JsonMethods.{pretty, render}
3130

32-
import org.eclipse.jetty.server.{NetworkConnector, Server}
31+
import org.eclipse.jetty.server.{DispatcherType, Server}
3332
import org.eclipse.jetty.server.handler.HandlerList
3433
import org.eclipse.jetty.servlet.{DefaultServlet, FilterHolder, ServletContextHandler, ServletHolder}
3534
import org.eclipse.jetty.util.thread.QueuedThreadPool
@@ -61,7 +60,8 @@ private[spark] object JettyUtils extends Logging {
6160
def createServlet[T <% AnyRef](servletParams: ServletParams[T],
6261
securityMgr: SecurityManager): HttpServlet = {
6362
new HttpServlet {
64-
override def doGet(request: HttpServletRequest, response: HttpServletResponse) {
63+
override def doGet(request: HttpServletRequest,
64+
response: HttpServletResponse) {
6565
if (securityMgr.checkUIViewPermissions(request.getRemoteUser())) {
6666
response.setContentType("%s;charset=utf-8".format(servletParams.contentType))
6767
response.setStatus(HttpServletResponse.SC_OK)
@@ -72,7 +72,7 @@ private[spark] object JettyUtils extends Logging {
7272
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED)
7373
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate")
7474
response.sendError(HttpServletResponse.SC_UNAUTHORIZED,
75-
"User is not authorized to access this page.")
75+
"User is not authorized to access this page.");
7676
}
7777
}
7878
}
@@ -120,25 +120,26 @@ private[spark] object JettyUtils extends Logging {
120120

121121
private def addFilters(handlers: Seq[ServletContextHandler], conf: SparkConf) {
122122
val filters: Array[String] = conf.get("spark.ui.filters", "").split(',').map(_.trim())
123-
filters.foreach { filter =>
124-
if (!filter.isEmpty) {
125-
logInfo("Adding filter: " + filter)
126-
val holder : FilterHolder = new FilterHolder()
127-
holder.setClassName(filter)
128-
// get any parameters for each filter
129-
val paramName = "spark." + filter + ".params"
130-
val params = conf.get(paramName, "").split(',').map(_.trim()).toSet
131-
params.foreach {
132-
case param : String =>
133-
if (!param.isEmpty) {
134-
val parts = param.split("=")
135-
if (parts.length == 2) holder.setInitParameter(parts(0), parts(1))
136-
}
123+
filters.foreach {
124+
case filter : String =>
125+
if (!filter.isEmpty) {
126+
logInfo("Adding filter: " + filter)
127+
val holder : FilterHolder = new FilterHolder()
128+
holder.setClassName(filter)
129+
// get any parameters for each filter
130+
val paramName = "spark." + filter + ".params"
131+
val params = conf.get(paramName, "").split(',').map(_.trim()).toSet
132+
params.foreach {
133+
case param : String =>
134+
if (!param.isEmpty) {
135+
val parts = param.split("=")
136+
if (parts.length == 2) holder.setInitParameter(parts(0), parts(1))
137+
}
138+
}
139+
val enumDispatcher = java.util.EnumSet.of(DispatcherType.ASYNC, DispatcherType.ERROR,
140+
DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST)
141+
handlers.foreach { case(handler) => handler.addFilter(holder, "/*", enumDispatcher) }
137142
}
138-
val enumDispatcher = java.util.EnumSet.of(DispatcherType.ASYNC, DispatcherType.ERROR,
139-
DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST)
140-
handlers.foreach { handler => handler.addFilter(holder, "/*", enumDispatcher) }
141-
}
142143
}
143144
}
144145

@@ -149,10 +150,7 @@ private[spark] object JettyUtils extends Logging {
149150
* If the desired port number is contented, continues incrementing ports until a free port is
150151
* found. Returns the chosen port and the jetty Server object.
151152
*/
152-
def startJettyServer(
153-
hostName: String,
154-
port: Int,
155-
handlers: Seq[ServletContextHandler],
153+
def startJettyServer(hostName: String, port: Int, handlers: Seq[ServletContextHandler],
156154
conf: SparkConf): (Server, Int) = {
157155

158156
addFilters(handlers, conf)
@@ -162,18 +160,16 @@ private[spark] object JettyUtils extends Logging {
162160
@tailrec
163161
def connect(currentPort: Int): (Server, Int) = {
164162
val server = new Server(new InetSocketAddress(hostName, currentPort))
165-
// Unfortunately Jetty 9 doesn't allow us to set both the thread pool and the port number in
166-
// constructor. But fortunately the pool allocated by Jetty is always a QueuedThreadPool.
167-
val pool = server.getThreadPool.asInstanceOf[QueuedThreadPool]
163+
val pool = new QueuedThreadPool
168164
pool.setDaemon(true)
169-
165+
server.setThreadPool(pool)
170166
server.setHandler(handlerList)
171167

172168
Try {
173169
server.start()
174170
} match {
175171
case s: Success[_] =>
176-
(server, server.getConnectors.head.asInstanceOf[NetworkConnector].getLocalPort)
172+
(server, server.getConnectors.head.getLocalPort)
177173
case f: Failure[_] =>
178174
server.stop()
179175
logInfo("Failed to create UI at port, %s. Trying again.".format(currentPort))

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,22 @@
186186
<dependency>
187187
<groupId>org.eclipse.jetty</groupId>
188188
<artifactId>jetty-util</artifactId>
189-
<version>9.1.3.v20140225</version>
189+
<version>7.6.8.v20121106</version>
190190
</dependency>
191191
<dependency>
192192
<groupId>org.eclipse.jetty</groupId>
193193
<artifactId>jetty-security</artifactId>
194-
<version>9.1.3.v20140225</version>
194+
<version>7.6.8.v20121106</version>
195195
</dependency>
196196
<dependency>
197197
<groupId>org.eclipse.jetty</groupId>
198198
<artifactId>jetty-plus</artifactId>
199-
<version>9.1.3.v20140225</version>
199+
<version>7.6.8.v20121106</version>
200200
</dependency>
201201
<dependency>
202202
<groupId>org.eclipse.jetty</groupId>
203203
<artifactId>jetty-server</artifactId>
204-
<version>9.1.3.v20140225</version>
204+
<version>7.6.8.v20121106</version>
205205
</dependency>
206206
<dependency>
207207
<groupId>com.google.guava</groupId>

project/SparkBuild.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ object SparkBuild extends Build {
238238

239239
libraryDependencies ++= Seq(
240240
"io.netty" % "netty-all" % "4.0.17.Final",
241-
"org.eclipse.jetty" % "jetty-server" % "9.1.3.v20140225",
242-
"org.eclipse.jetty" % "jetty-util" % "9.1.3.v20140225",
243-
"org.eclipse.jetty" % "jetty-plus" % "9.1.3.v20140225",
244-
"org.eclipse.jetty" % "jetty-security" % "9.1.3.v20140225",
241+
"org.eclipse.jetty" % "jetty-server" % "7.6.8.v20121106",
242+
"org.eclipse.jetty" % "jetty-util" % "7.6.8.v20121106",
243+
"org.eclipse.jetty" % "jetty-plus" % "7.6.8.v20121106",
244+
"org.eclipse.jetty" % "jetty-security" % "7.6.8.v20121106",
245245
/** Workaround for SPARK-959. Dependency used by org.eclipse.jetty. Fixed in ivy 2.3.0. */
246246
"org.eclipse.jetty.orbit" % "javax.servlet" % "2.5.0.v201103041518" artifacts Artifact("javax.servlet", "jar", "jar"),
247247
"org.scalatest" %% "scalatest" % "1.9.1" % "test",

0 commit comments

Comments
 (0)