[SPARK-30300][SQL][WEB-UI] Fix updating the UI max value string when driver updates the same metric id as the tasks

### What changes were proposed in this pull request?

In this PR, For a given metrics id we are checking if the driver side accumulator's value is greater than max of all stages value. If it's true, then we are removing that entry from the Hashmap. By doing this, for this metrics, "driver" would be displayed on the UI(As the driver would have the maximum value)

### Why are the changes needed?

This PR fixes https://issues.apache.org/jira/browse/SPARK-30300. Currently driver's metric value is not compared while caluculating the max.

### Does this PR introduce any user-facing change?

For the metrics where driver's value is greater than max of all stages, this is the change.
Previous : (min, median, max (stageId 0( attemptId 1): taskId 2))
Now:   (min, median, max (driver))

### How was this patch tested?

Ran unit tests.

Closes #26941 from nartal1/SPARK-30300.

Authored-by: Niranjan Artal <nartal@nvidia.com>
Signed-off-by: Thomas Graves <tgraves@apache.org>
This commit is contained in:
Niranjan Artal 2019-12-20 07:29:28 -06:00 committed by Thomas Graves
parent 12249fcdc7
commit 0d2ef3ae2b

View file

@ -237,6 +237,12 @@ class SQLAppStatusListener(
if (metricTypes.contains(id)) {
val prev = allMetrics.getOrElse(id, null)
val updated = if (prev != null) {
// If the driver updates same metrics as tasks and has higher value then remove
// that entry from maxMetricsFromAllStage. This would make stringValue function default
// to "driver" that would be displayed on UI.
if (maxMetricsFromAllStages.contains(id) && value > maxMetricsFromAllStages(id)(0)) {
maxMetricsFromAllStages.remove(id)
}
val _copy = Arrays.copyOf(prev, prev.length + 1)
_copy(prev.length) = value
_copy