From 970c2f52295f934ec1131767c933af1ac8f8a21e Mon Sep 17 00:00:00 2001 From: Zhen Li Date: Tue, 15 Sep 2020 00:13:09 -0700 Subject: [PATCH 1/4] fix 'undefined' link in event timeline view --- .../org/apache/spark/ui/static/timeline-view.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js index 5be8cffd1f8db..a78082fba49df 100644 --- a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js +++ b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js @@ -50,9 +50,18 @@ function drawApplicationTimeline(groupArray, eventObjArray, startTime, offset) { return "#job-" + jobId; }; + var getPathForJobEntry = function(baseElem) { + var jobIdText = $($(baseElem).find(".application-timeline-content")[0]).text(); + var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1]; + return window.location.pathname.replace(/\/$/, '') + "/job/?id=" + jobId; + }; + $(this).click(function() { var jobPagePath = $(getSelectorForJobEntry(this)).find("a.name-link").attr("href"); - window.location.href = jobPagePath + if (jobPagePath == undefined) { + jobPagePath = getPathForJobEntry(this) + } + window.location.href = jobPagePath }); $(this).hover( From 00f5c60f9406723e2fcaa5ce52f44d47771c95e9 Mon Sep 17 00:00:00 2001 From: Zhen Li Date: Tue, 15 Sep 2020 02:03:47 -0700 Subject: [PATCH 2/4] minor change --- .../main/resources/org/apache/spark/ui/static/timeline-view.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js index a78082fba49df..a7fc4201e3459 100644 --- a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js +++ b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js @@ -53,7 +53,7 @@ function drawApplicationTimeline(groupArray, eventObjArray, startTime, offset) { var getPathForJobEntry = function(baseElem) { var jobIdText = $($(baseElem).find(".application-timeline-content")[0]).text(); var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1]; - return window.location.pathname.replace(/\/$/, '') + "/job/?id=" + jobId; + return "job/?id=" + jobId; }; $(this).click(function() { From b243dc3b02c7902ca7c78685e90971c485e20d2c Mon Sep 17 00:00:00 2001 From: Zhen Li Date: Tue, 15 Sep 2020 16:53:50 -0700 Subject: [PATCH 3/4] address comments --- .../apache/spark/ui/static/timeline-view.js | 64 ++++++++++--------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js index a7fc4201e3459..13e6fe38010f8 100644 --- a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js +++ b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js @@ -42,35 +42,32 @@ function drawApplicationTimeline(groupArray, eventObjArray, startTime, offset) { setupZoomable("#application-timeline-zoom-lock", applicationTimeline); setupExecutorEventAction(); + function getIdForJobEntry(baseElem) { + var jobIdText = $($(baseElem).find(".application-timeline-content")[0]).text(); + var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1]; + return jobId; + }; + + function getSelectorForJobEntry(jobId) { + return "#job-" + jobId; + }; + function setupJobEventAction() { $(".vis-item.vis-range.job.application-timeline-object").each(function() { - var getSelectorForJobEntry = function(baseElem) { - var jobIdText = $($(baseElem).find(".application-timeline-content")[0]).text(); - var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1]; - return "#job-" + jobId; - }; - - var getPathForJobEntry = function(baseElem) { - var jobIdText = $($(baseElem).find(".application-timeline-content")[0]).text(); - var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1]; - return "job/?id=" + jobId; - }; - $(this).click(function() { - var jobPagePath = $(getSelectorForJobEntry(this)).find("a.name-link").attr("href"); - if (jobPagePath == undefined) { - jobPagePath = getPathForJobEntry(this) - } - window.location.href = jobPagePath + var jobId = getIdForJobEntry(this); + // trim last '/' if exists and append '/job/' segment and id + var jobPagePath = window.location.pathname.replace(/\/$/, "/job/?id=" + jobId); + window.location.href = jobPagePath; }); $(this).hover( function() { - $(getSelectorForJobEntry(this)).addClass("corresponding-item-hover"); + $(getSelectorForJobEntry(getIdForJobEntry(this))).addClass("corresponding-item-hover"); $($(this).find("div.application-timeline-content")[0]).tooltip("show"); }, function() { - $(getSelectorForJobEntry(this)).removeClass("corresponding-item-hover"); + $(getSelectorForJobEntry(getIdForJobEntry(this))).removeClass("corresponding-item-hover"); $($(this).find("div.application-timeline-content")[0]).tooltip("hide"); } ); @@ -134,26 +131,35 @@ function drawJobTimeline(groupArray, eventObjArray, startTime, offset) { setupZoomable("#job-timeline-zoom-lock", jobTimeline); setupExecutorEventAction(); + function getStageIdAndAttemptForStageEntry(baseElem) { + var stageIdText = $($(baseElem).find(".job-timeline-content")[0]).text(); + var stageIdAndAttempt = stageIdText.match("\\(Stage (\\d+\\.\\d+)\\)$")[1].split("."); + return stageIdAndAttempt; + }; + + function getSelectorForStageEntry(stageIdAndAttempt) { + return "#stage-" + stageIdAndAttempt[0] + "-" + stageIdAndAttempt[1]; + }; + function setupStageEventAction() { $(".vis-item.vis-range.stage.job-timeline-object").each(function() { - var getSelectorForStageEntry = function(baseElem) { - var stageIdText = $($(baseElem).find(".job-timeline-content")[0]).text(); - var stageIdAndAttempt = stageIdText.match("\\(Stage (\\d+\\.\\d+)\\)$")[1].split("."); - return "#stage-" + stageIdAndAttempt[0] + "-" + stageIdAndAttempt[1]; - }; - $(this).click(function() { - var stagePagePath = $(getSelectorForStageEntry(this)).find("a.name-link").attr("href") - window.location.href = stagePagePath + var stageIdAndAttempt = getStageIdAndAttemptForStageEntry(this); + var stagePagePath = window.location.pathname.replace( + /\/jobs\/job(.*)/g, + "/stages/stage/?id=" + stageIdAndAttempt[0] + "&attempt=" + stageIdAndAttempt[1]); + window.location.href = stagePagePath; }); $(this).hover( function() { - $(getSelectorForStageEntry(this)).addClass("corresponding-item-hover"); + $(getSelectorForStageEntry(getStageIdAndAttemptForStageEntry(this))) + .addClass("corresponding-item-hover"); $($(this).find("div.job-timeline-content")[0]).tooltip("show"); }, function() { - $(getSelectorForStageEntry(this)).removeClass("corresponding-item-hover"); + $(getSelectorForStageEntry(getStageIdAndAttemptForStageEntry(this))) + .removeClass("corresponding-item-hover"); $($(this).find("div.job-timeline-content")[0]).tooltip("hide"); } ); From 40d94f651706b466bd7b5026d9b0400d02d57577 Mon Sep 17 00:00:00 2001 From: Zhen Li Date: Thu, 17 Sep 2020 19:32:14 -0700 Subject: [PATCH 4/4] minor change --- .../org/apache/spark/ui/static/timeline-view.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js index 13e6fe38010f8..220b76a0f1b27 100644 --- a/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js +++ b/core/src/main/resources/org/apache/spark/ui/static/timeline-view.js @@ -46,18 +46,17 @@ function drawApplicationTimeline(groupArray, eventObjArray, startTime, offset) { var jobIdText = $($(baseElem).find(".application-timeline-content")[0]).text(); var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1]; return jobId; - }; + } function getSelectorForJobEntry(jobId) { return "#job-" + jobId; - }; + } function setupJobEventAction() { $(".vis-item.vis-range.job.application-timeline-object").each(function() { $(this).click(function() { var jobId = getIdForJobEntry(this); - // trim last '/' if exists and append '/job/' segment and id - var jobPagePath = window.location.pathname.replace(/\/$/, "/job/?id=" + jobId); + var jobPagePath = uiRoot + appBasePath + "/jobs/job/?id=" + jobId; window.location.href = jobPagePath; }); @@ -135,19 +134,18 @@ function drawJobTimeline(groupArray, eventObjArray, startTime, offset) { var stageIdText = $($(baseElem).find(".job-timeline-content")[0]).text(); var stageIdAndAttempt = stageIdText.match("\\(Stage (\\d+\\.\\d+)\\)$")[1].split("."); return stageIdAndAttempt; - }; + } function getSelectorForStageEntry(stageIdAndAttempt) { return "#stage-" + stageIdAndAttempt[0] + "-" + stageIdAndAttempt[1]; - }; + } function setupStageEventAction() { $(".vis-item.vis-range.stage.job-timeline-object").each(function() { $(this).click(function() { var stageIdAndAttempt = getStageIdAndAttemptForStageEntry(this); - var stagePagePath = window.location.pathname.replace( - /\/jobs\/job(.*)/g, - "/stages/stage/?id=" + stageIdAndAttempt[0] + "&attempt=" + stageIdAndAttempt[1]); + var stagePagePath = uiRoot + appBasePath + + "/stages/stage/?id=" + stageIdAndAttempt[0] + "&attempt=" + stageIdAndAttempt[1]; window.location.href = stagePagePath; });