Skip to content
Snippets Groups Projects
Commit 7e8994ff authored by Felix Cheung's avatar Felix Cheung Committed by Felix Cheung
Browse files

[SPARK-18903][SPARKR] Add API to get SparkUI URL

## What changes were proposed in this pull request?

API for SparkUI URL from SparkContext

## How was this patch tested?

manual, unit tests

Author: Felix Cheung <felixcheung_m@hotmail.com>

Closes #16367 from felixcheung/rwebui.
parent b41ec997
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ export("sparkR.stop")
export("sparkR.session.stop")
export("sparkR.conf")
export("sparkR.version")
export("sparkR.uiWebUrl")
export("print.jobj")
export("sparkR.newJObject")
......
......@@ -410,6 +410,30 @@ sparkR.session <- function(
sparkSession
}
#' Get the URL of the SparkUI instance for the current active SparkSession
#'
#' Get the URL of the SparkUI instance for the current active SparkSession.
#'
#' @return the SparkUI URL, or NA if it is disabled, or not started.
#' @rdname sparkR.uiWebUrl
#' @name sparkR.uiWebUrl
#' @export
#' @examples
#'\dontrun{
#' sparkR.session()
#' url <- sparkR.uiWebUrl()
#' }
#' @note sparkR.uiWebUrl since 2.2.0
sparkR.uiWebUrl <- function() {
sc <- sparkR.callJMethod(getSparkContext(), "sc")
u <- callJMethod(sc, "uiWebUrl")
if (callJMethod(u, "isDefined")) {
callJMethod(u, "get")
} else {
NA
}
}
#' Assigns a group ID to all the jobs started by this thread until the group ID is set to a
#' different value or cleared.
#'
......
......@@ -2613,7 +2613,7 @@ test_that("randomSplit", {
expect_true(all(sapply(abs(counts / num - weights / sum(weights)), function(e) { e < 0.05 })))
})
test_that("Setting and getting config on SparkSession", {
test_that("Setting and getting config on SparkSession, sparkR.conf(), sparkR.uiWebUrl()", {
# first, set it to a random but known value
conf <- callJMethod(sparkSession, "conf")
property <- paste0("spark.testing.", as.character(runif(1)))
......@@ -2637,6 +2637,9 @@ test_that("Setting and getting config on SparkSession", {
expect_equal(appNameValue, "sparkSession test")
expect_equal(testValue, value)
expect_error(sparkR.conf("completely.dummy"), "Config 'completely.dummy' is not set")
url <- sparkR.uiWebUrl()
expect_equal(substr(url, 1, 7), "http://")
})
test_that("enableHiveSupport on SparkSession", {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment