GitHub user JoshRosen opened a pull request:
https://github.com/apache/spark/pull/2852
[WIP] Add WebUITableBuilder to simplify table-building code
This work-in-progress commit illustrates a weekend hack project that I came
up with for significantly simplifying the web UI's table rendering code. See
the huge block comment in `WebUITableBuilder` for more details. This isn't
ready to merge yet; I wanted to get some feedback before converting the rest of
the table construction code to use this (I know that I should open a JIRA for
this, too; I'll do it tomorrow).
Essentially, this commit adds a small builder class for constructing
objects that know how to render web UI tables. This builder helps us to avoid
several sources of errors / maintenance headaches, such as
duplicate/boilerplate markup, inconsistent formatting of columns in different
tables (e.g. durations or memory being displayed differently), separation of
column names from column data values, etc. This is best illustrated by some
sample code; this new framework lets you write
```scala
private val appTable: UITable[ApplicationInfo] = {
val builder = new UITableBuilder[ApplicationInfo]()
import builder._
customCol("ID") { app =>
<a href={"app?appId=" + app.id}>{app.id}</a>
}
col("Name") { _.id }
intCol("Cores") { _.coresGranted }
memCol("Memory per Node") { _.desc.memoryPerSlave }
dateCol("Submitted Time") { _.submitDate }
col("User") { _.desc.user }
col("State") { _.state.toString }
durationCol("Duration") { _.duration }
build
}
```
to render the "applications" table in the standalone Master UI. I find
this significantly easier to understand and maintain than the old code. For
example, this makes it trivial to re-order columns.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/JoshRosen/spark webui-table-builder
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/spark/pull/2852.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2852
----
commit c0aca09d676ce750496451f3691c5f9e861103bd
Author: Josh Rosen <[email protected]>
Date: 2014-10-20T06:02:29Z
Add WebUITableBuilder to clean up table building code.
This significantly simplifies / abstracts the web UI's table construction
code, which seems to account for the majority of the UI code. I haven't
converted all tables to use this yet; this commit just provides the basic
framework and a few example usages in the master web UI.
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]