-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-8691][WebUI]Enable GZip by default for Web UI #7072
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 all commits
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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ import scala.xml.Node | |
| import org.eclipse.jetty.server.Server | ||
| import org.eclipse.jetty.server.handler._ | ||
| import org.eclipse.jetty.servlet._ | ||
| import org.eclipse.jetty.servlets.GzipFilter | ||
| import org.eclipse.jetty.util.thread.QueuedThreadPool | ||
| import org.json4s.JValue | ||
| import org.json4s.jackson.JsonMethods.{pretty, render} | ||
|
|
@@ -166,8 +167,26 @@ private[spark] object JettyUtils extends Logging { | |
| contextHandler | ||
| } | ||
|
|
||
| private def addDefaultFilters(handlers: Seq[ServletContextHandler], conf: SparkConf): Unit = { | ||
| val compression = conf.getBoolean("spark.ui.compression", true) | ||
|
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. Is there a reason to make this configurable? When would a user not want this?
Member
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. Since Spark supports the user to add custom Filters, I'm concerned that they may add a Filter that conflicts with |
||
| if (compression) { | ||
| // Enable gzip for Web UI | ||
| logInfo("Adding filter: GzipFilter") | ||
| val holder = new FilterHolder() | ||
| holder.setClassName(classOf[GzipFilter].getName()) | ||
| holder.setInitParameter("methods", "GET,POST") | ||
| holder.setInitParameter("mimeTypes", "text/html,text/xml,text/plain,text/css," + | ||
| "text/javascript,text/json,application/x-javascript,application/javascript," + | ||
| "application/json,application/xml,application/xml+xhtml,image/svg+xml") | ||
| val enumDispatcher = java.util.EnumSet.of(DispatcherType.ASYNC, DispatcherType.ERROR, | ||
| DispatcherType.FORWARD, DispatcherType.INCLUDE, DispatcherType.REQUEST) | ||
| handlers.foreach { case (handler) => handler.addFilter(holder, "/*", enumDispatcher) } | ||
| } | ||
| } | ||
|
|
||
| /** Add filters, if any, to the given list of ServletContextHandlers */ | ||
| def addFilters(handlers: Seq[ServletContextHandler], conf: SparkConf) { | ||
| addDefaultFilters(handlers, conf) | ||
| val filters: Array[String] = conf.get("spark.ui.filters", "").split(',').map(_.trim()) | ||
| filters.foreach { | ||
| case filter : String => | ||
|
|
||
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.
Surely Jetty/netty already handle this internally? this is a hacky approach to supporting compression and I am all but certain modern containers (can be configured to) do this for you. Tomcat does.
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 problem is we don't have a configuration file for Jetty. So to enable it, we need to set it in the code. Here is an example provided by Jetty: https://github.com/jetty-project/jetty-plugin-support/blob/378f5f691fc24c3f223e7239fc56b3568b6f816e/jetty-servlets/src/test/java/org/eclipse/jetty/servlets/GzipWithPipeliningTest.java#L58