Github user zjffdu commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14666#discussion_r75050631
  
    --- Diff: R/pkg/R/sparkR.R ---
    @@ -159,55 +159,81 @@ sparkR.sparkContext <- function(
           warning(paste("sparkPackages has no effect when using spark-submit 
or sparkR shell",
                         " please use the --packages commandline instead", sep 
= ","))
         }
    +    host <- "localhost"
         backendPort <- existingPort
       } else {
    -    path <- tempfile(pattern = "backend_port")
    -    submitOps <- getClientModeSparkSubmitOpts(
    +
    +    if (!nzchar(master) || is_master_local(master)) {
    +      path <- tempfile(pattern = "backend_port")
    +      submitOps <- getClientModeSparkSubmitOpts(
             Sys.getenv("SPARKR_SUBMIT_ARGS", "sparkr-shell"),
             sparkEnvirMap)
    -    launchBackend(
    +      launchBackend(
             args = path,
             sparkHome = sparkHome,
             jars = jars,
             sparkSubmitOpts = submitOps,
             packages = packages)
    -    # wait atmost 100 seconds for JVM to launch
    -    wait <- 0.1
    -    for (i in 1:25) {
    -      Sys.sleep(wait)
    -      if (file.exists(path)) {
    -        break
    +      # wait atmost 100 seconds for JVM to launch
    +      wait <- 0.1
    +      for (i in 1:25) {
    +        Sys.sleep(wait)
    +        if (file.exists(path)) {
    +          break
    +        }
    +        wait <- wait * 1.25
           }
    -      wait <- wait * 1.25
    -    }
    -    if (!file.exists(path)) {
    -      stop("JVM is not ready after 10 seconds")
    -    }
    -    f <- file(path, open = "rb")
    -    backendPort <- readInt(f)
    -    monitorPort <- readInt(f)
    -    rLibPath <- readString(f)
    -    close(f)
    -    file.remove(path)
    -    if (length(backendPort) == 0 || backendPort == 0 ||
    -        length(monitorPort) == 0 || monitorPort == 0 ||
    -        length(rLibPath) != 1) {
    -      stop("JVM failed to launch")
    +      if (!file.exists(path)) {
    +        stop("JVM is not ready after 10 seconds")
    +      }
    +      f <- file(path, open = "rb")
    +      backendPort <- readInt(f)
    +      monitorPort <- readInt(f)
    +      rLibPath <- readString(f)
    +      close(f)
    +      file.remove(path)
    +      if (length(backendPort) == 0 || backendPort == 0 ||
    +          length(monitorPort) == 0 || monitorPort == 0 ||
    +          length(rLibPath) != 1) {
    +        stop("JVM failed to launch")
    +      }
    +      if (rLibPath != "") {
    +        assign(".libPath", rLibPath, envir = .sparkREnv)
    +        .libPaths(c(rLibPath, .libPaths()))
    +      }
    +      host <- "localhost"
    +    } else {
    +      backendPort <- if (!is.null(sparkEnvirMap[["backend.port"]])) {
    +        sparkEnvirMap[["backend.port"]]
    --- End diff --
    
    How is backend.port passed to R process ? I don't see how this environment 
variable is set. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to