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

[SPARK-20541][SPARKR][SS] support awaitTermination without timeout

## What changes were proposed in this pull request?

Add without param for timeout - will need this to submit a job that runs until stopped
Need this for 2.2

## How was this patch tested?

manually, unit test

Author: Felix Cheung <felixcheung_m@hotmail.com>

Closes #17815 from felixcheung/rssawaitinfinite.
parent 80e9cf1b
No related branches found
No related tags found
No related merge requests found
...@@ -1518,7 +1518,7 @@ setGeneric("write.ml", function(object, path, ...) { standardGeneric("write.ml") ...@@ -1518,7 +1518,7 @@ setGeneric("write.ml", function(object, path, ...) { standardGeneric("write.ml")
#' @rdname awaitTermination #' @rdname awaitTermination
#' @export #' @export
setGeneric("awaitTermination", function(x, timeout) { standardGeneric("awaitTermination") }) setGeneric("awaitTermination", function(x, timeout = NULL) { standardGeneric("awaitTermination") })
#' @rdname isActive #' @rdname isActive
#' @export #' @export
......
...@@ -169,8 +169,10 @@ setMethod("isActive", ...@@ -169,8 +169,10 @@ setMethod("isActive",
#' immediately. #' immediately.
#' #'
#' @param x a StreamingQuery. #' @param x a StreamingQuery.
#' @param timeout time to wait in milliseconds #' @param timeout time to wait in milliseconds, if omitted, wait indefinitely until \code{stopQuery}
#' @return TRUE if query has terminated within the timeout period. #' is called or an error has occured.
#' @return TRUE if query has terminated within the timeout period; nothing if timeout is not
#' specified.
#' @rdname awaitTermination #' @rdname awaitTermination
#' @name awaitTermination #' @name awaitTermination
#' @aliases awaitTermination,StreamingQuery-method #' @aliases awaitTermination,StreamingQuery-method
...@@ -182,8 +184,12 @@ setMethod("isActive", ...@@ -182,8 +184,12 @@ setMethod("isActive",
#' @note experimental #' @note experimental
setMethod("awaitTermination", setMethod("awaitTermination",
signature(x = "StreamingQuery"), signature(x = "StreamingQuery"),
function(x, timeout) { function(x, timeout = NULL) {
handledCallJMethod(x@ssq, "awaitTermination", as.integer(timeout)) if (is.null(timeout)) {
invisible(handledCallJMethod(x@ssq, "awaitTermination"))
} else {
handledCallJMethod(x@ssq, "awaitTermination", as.integer(timeout))
}
}) })
#' stopQuery #' stopQuery
......
...@@ -61,6 +61,7 @@ test_that("read.stream, write.stream, awaitTermination, stopQuery", { ...@@ -61,6 +61,7 @@ test_that("read.stream, write.stream, awaitTermination, stopQuery", {
stopQuery(q) stopQuery(q)
expect_true(awaitTermination(q, 1)) expect_true(awaitTermination(q, 1))
expect_error(awaitTermination(q), NA)
}) })
test_that("print from explain, lastProgress, status, isActive", { test_that("print from explain, lastProgress, status, isActive", {
......
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