1source("incl/start.R") 2stopCluster <- parallel::stopCluster 3 4message("*** cluster operations ...") 5 6local({ 7 cl0 <- makeClusterPSOCK(1L) 8 on.exit(stopCluster(cl0)) 9 cl <- cl0 10 print(cl) 11 12 message("*** cluster operations - as.cluster() ...") 13 cl1 <- as.cluster(cl) 14 print(cl1) 15 stopifnot(inherits(cl1, "cluster"), identical(cl1, cl)) 16 17 node <- cl[[1]] 18 print(node) 19 cl2 <- as.cluster(node) 20 stopifnot(inherits(cl2, "cluster"), length(cl2) == 1L, 21 identical(cl2[[1]], node)) 22 23 node <- cl[[1]] 24 print(node) 25 stopifnot(inherits(node, if (useXDR) "SOCKnode" else "SOCK0node")) 26 nodes <- list(node, node) 27 cl3 <- as.cluster(node) 28 print(cl3) 29 stopifnot(inherits(cl3, "cluster"), length(cl3) == 1L, 30 identical(cl3[[1]], node)) 31 32 cl4 <- as.cluster(nodes) 33 print(cl4) 34 stopifnot(inherits(cl4, "cluster"), length(cl4) == 2L, 35 identical(cl4[[1]], node), identical(cl4[[2]], node)) 36 37 message("*** cluster operations - as.cluster() ... DONE") 38 39 message("*** cluster operations - c(...) ...") 40 cl2 <- makeClusterPSOCK("localhost") 41 on.exit(stopCluster(cl2), add = TRUE) 42 print(cl2) 43 44 cl <- c(cl1, cl2) 45 print(cl) 46 47 stopifnot(inherits(cl, "cluster"), length(cl) == 2L) 48 stopifnot(identical(cl[1], cl1), 49 identical(cl[2], cl2[1])) 50 message("*** cluster operations - c(...) ... DONE") 51}) 52 53 54message("*** cluster operations - makeClusterPSOCK(remotes) ...") 55 56remotes <- Sys.getenv("R_PARALLELLY_TESTS_REMOTES", "") 57remotes <- gsub(" ", "", unlist(strsplit(remotes, split = ","))) 58remotes <- remotes[nzchar(remotes)] 59if (length(remotes) > 0) { 60 message("Remotes: ", paste(sQuote(remotes), collapse = ", ")) 61 local({ 62 cl <- makeClusterPSOCK(remotes, verbose = TRUE) 63 on.exit(stopCluster(cl)) 64 print(cl) 65 }) 66} 67 68message("*** cluster operations - makeClusterPSOCK(remotes) ... DONE") 69 70message("*** cluster operations ... DONE") 71 72source("incl/end.R") 73