Learn R Programming

pbdRPC (version 0.1-1)

rpc_cs_example: Example Functions of RPC Related to pbdCS

Description

Example functions of RPC related to pbdCS

Usage

check_cs(exec.type = .pbd_env$RPC.LI$exec.type, args = .pbd_env$RPC.LI$args, pport = .pbd_env$RPC.LI$pport, user = .pbd_env$RPC.LI$user, hostname = .pbd_env$RPC.LI$hostname, priv.key = .pbd_env$RPC.LI$priv.key, priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk, cmd = .pbd_env$RPC.CS$check)
kill_cs(exec.type = .pbd_env$RPC.LI$exec.type, args = .pbd_env$RPC.LI$args, pport = .pbd_env$RPC.LI$pport, user = .pbd_env$RPC.LI$user, hostname = .pbd_env$RPC.LI$hostname, priv.key = .pbd_env$RPC.LI$priv.key, priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk, cmd = .pbd_env$RPC.CS$kill)
start_cs(exec.type = .pbd_env$RPC.LI$exec.type, args = .pbd_env$RPC.LI$args, pport = .pbd_env$RPC.LI$pport, user = .pbd_env$RPC.LI$user, hostname = .pbd_env$RPC.LI$hostname, priv.key = .pbd_env$RPC.LI$priv.key, priv.key.ppk = .pbd_env$RPC.LI$priv.key.ppk, preload = .pbd_env$RPC.CS$preload, cmd = .pbd_env$RPC.CS$start)

Arguments

exec.type
either "ssh" or "plink" in character. Windows will force to use "plink".
args
further arguments to "ssh" or "plink" for connecting to the server in addition to port, user id, and host name.
pport
ssh port opened on the server.
user
user id for logging to the server.
hostname
the server ip or host name.
priv.key, priv.key.ppk
location of the private key for user authentication, the file will be checked first then -i priv.key will be added to args when the file exists. priv.key.ppk is only used when plink is called.
cmd
the main command to be executed on the server.
preload
further commands preloaded before the main command is executed.

Value

Mainly the message received at the command line will be printed, but may not be captured by R.

Details

Using either ssh or plink to launch a pbdCS R cluster.

NO further input from stdin is expected. Outputs or errors may not be captured by R.

start_cs() starts a pbdCS R cluster on remote servers. Typical commands to launch a pbdCS R cluster is given in the example. The linux/unix commands are as the following:

  • 1)nohup is for the non-stop call after disconnection.
  • 2)mpiexec -np 4 is for launching 4 MPI instances.
  • 3)Rscript -e 'pbdCS::pbdserver()' is for R to start the pbdCS R cluster within MPI in batch.
  • 4)> .rrlog is to direct the stdout to a file .rrlog
  • 5)2>&1 is to turn stderr to stdout which is the file .cslog.
  • 6)< /dev/null is to get stdin from /dev/null which is nothing happen.
  • 7)& is to put the batch command for the pbdCS R cluster in background.

check_cs() checks if there is a pbdCS R cluster on a remote server. Lunix/unix commands ps and grep are used.

kill_cs() kills the pbdCS R cluster if found. Lunix/unix commands ps, grep, awk, and kill are used.

Examples

Run this code
## Not run: 
# library(pbdRPC, quietly = TRUE)
# rpcopt_set(user = "snoweye", hostname = "192.168.56.101")
# 
# check_cs()    # pid 2857 (may differ)
# kill_cs()     # all pbdCS pids are killed
# check_cs()    # make sure no pbdCS R cluster is running
# 
# ### use "; " to bypass multiple commands
# preload <- "source ~/work-my/00_set_devel_R; "
# 
# ### start a new pbdCS R cluster
# start_cs(preload = preload)
# check_cs()
# kill_cs()
# 
# ### Example: for module load on supercomputers
# preload <- "module load r; "    # e.g. via module load r
# start_cs(preload = preload)
# check_cs()
# kill_cs()
# ## End(Not run)


Run the code above in your browser using DataLab