Skip to content

Commit

Permalink
retry backend connection
Browse files Browse the repository at this point in the history
  • Loading branch information
lythesia committed Feb 19, 2015
1 parent 0981dff commit 4cd7d3f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/R/sparkR.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,19 @@ sparkR.init <- function(
mainClass = "edu.berkeley.cs.amplab.sparkr.SparkRBackend",
args = as.character(sparkRBackendPort),
javaOpts = paste("-Xmx", sparkMem, sep = ""))
Sys.sleep(2) # Wait for backend to come up

cat("Waiting JVM bring up ...\n")
while(TRUE) {
if(!connExists(.sparkREnv)) {
Sys.sleep(1)
cat(".")
connectBackend("localhost", sparkRBackendPort) # Connect to it
} else {
cat(" ok.\n")
break
}
}
.sparkREnv$sparkRBackendPort <- sparkRBackendPort
connectBackend("localhost", sparkRBackendPort) # Connect to it

if (nchar(sparkHome) != 0) {
sparkHome <- normalizePath(sparkHome)
Expand Down

0 comments on commit 4cd7d3f

Please sign in to comment.