Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions core/src/main/resources/org/apache/spark/ui/static/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,24 @@ function formatLogsCells(execLogs, type) {
}

function getStandAloneAppId(cb) {
var words = getBaseURI().split('/');
var ind = words.indexOf("proxy");
var appId;
if (ind > 0) {
appId = words[ind + 1];
cb(appId);
return;
}
ind = words.indexOf("history");
if (ind > 0) {
appId = words[ind + 1];
cb(appId);
return;
let proxyWords = reverseProxyURL.split('/');
// If the configured proxy base URL doesn't contain "proxy" or "history", we can get the APP id
// from the current base URI.
if (proxyWords.indexOf("proxy") < 0 && proxyWords.indexOf("history") < 0) {
var words = getBaseURI().split('/');
var ind = words.indexOf("proxy");
var appId;
if (ind > 0) {
appId = words[ind + 1];
cb(appId);
return;
}
ind = words.indexOf("history");
if (ind > 0) {
appId = words[ind + 1];
cb(appId);
return;
}
}
// Looks like Web UI is running in standalone mode
// Let's get application-id using REST End Point
Expand Down Expand Up @@ -149,13 +154,7 @@ function ConvertDurationString(data) {

function createTemplateURI(appId, templateName) {
var words = getBaseURI().split('/');
var ind = words.indexOf("proxy");
var baseURI;
if (ind > 0) {
baseURI = words.slice(0, ind + 1).join('/') + '/' + appId + '/static/' + templateName + '-template.html';
return baseURI;
}
ind = words.indexOf("history");
ind = words.lastIndexOf("history");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the reverse proxy URL contains "history", there is still bug.

if(ind > 0) {
baseURI = words.slice(0, ind).join('/') + '/static/' + templateName + '-template.html';
return baseURI;
Expand Down Expand Up @@ -184,14 +183,7 @@ function formatDate(date) {

function createRESTEndPointForExecutorsPage(appId) {
var words = getBaseURI().split('/');
var ind = words.indexOf("proxy");
var newBaseURI;
if (ind > 0) {
appId = words[ind + 1];
newBaseURI = words.slice(0, ind + 2).join('/');
return newBaseURI + "/api/v1/applications/" + appId + "/allexecutors";
}
ind = words.indexOf("history");
ind = words.lastIndexOf("history");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the reverse proxy URL contains "history", there is still bug.

if (ind > 0) {
appId = words[ind + 1];
var attemptId = words[ind + 2];
Expand Down Expand Up @@ -231,4 +223,4 @@ function createRESTEndPointForMiscellaneousProcess(appId) {
function getBaseURI() {
return document.baseURI || document.URL;
}
/* eslint-enable no-unused-vars */
/* eslint-enable no-unused-vars */
6 changes: 6 additions & 0 deletions core/src/main/resources/org/apache/spark/ui/static/webui.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
/* eslint-disable no-unused-vars */
var uiRoot = "";
var appBasePath = "";
var reverseProxyURL = "";

function setUIRoot(val) {
uiRoot = val;
Expand All @@ -27,6 +28,11 @@ function setUIRoot(val) {
function setAppBasePath(path) {
appBasePath = path;
}

function setReverseProxyURL(base) {
reverseProxyURL = base;
}

/* eslint-enable no-unused-vars */

function collapseTablePageLoad(name, table){
Expand Down
5 changes: 3 additions & 2 deletions core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,10 @@ class SparkContext(config: SparkConf) extends Logging {
_env.blockManager.blockStoreClient.setAppAttemptId(attemptId)
}
if (_conf.get(UI_REVERSE_PROXY)) {
val proxyUrl = _conf.get(UI_REVERSE_PROXY_URL.key, "").stripSuffix("/") +
"/proxy/" + _applicationId
val reverseProxyURL = _conf.get(UI_REVERSE_PROXY_URL.key, "").stripSuffix("/")
val proxyUrl = reverseProxyURL + "/proxy/" + _applicationId
System.setProperty("spark.ui.proxyBase", proxyUrl)
System.setProperty("spark.ui.reverseProxyURL", reverseProxyURL)
}
_ui.foreach(_.setAppId(_applicationId))
_env.blockManager.initialize(_applicationId)
Expand Down
1 change: 1 addition & 0 deletions core/src/main/scala/org/apache/spark/ui/UIUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ private[spark] object UIUtils extends Logging {
<script src={prependBaseUri(request, "/static/log-view.js")}></script>
<script src={prependBaseUri(request, "/static/webui.js")}></script>
<script>setUIRoot('{UIUtils.uiRoot(request)}')</script>
<script>setReverseProxyURL('{sys.props.getOrElse("spark.ui.reverseProxyURL", "")}')</script>
}

def vizHeaderNodes(request: HttpServletRequest): Seq[Node] = {
Expand Down