Skip to content

Commit 904e376

Browse files
committed
init
0 parents  commit 904e376

File tree

161 files changed

+63829
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+63829
-0
lines changed

.Rbuildignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
^\.travis\.yml$

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*~
2+
*.pdf
3+
*.html
4+
*.swp
5+
6+
7+
src/*.o
8+
src/*.so
9+

.travis.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: R
2+
sudo: required
3+
warnings_are_errors: true
4+
5+
env:
6+
global:
7+
- CRAN: https://cran.rstudio.com
8+
9+
r_check_args: --no-build-vignettes --no-manual
10+

COPYING

+374
Large diffs are not rendered by default.

ChangeLog

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
======================= Log Before Release =====================================
2+
2016-11-26: Ver. 0.1-1
3+
* Add more vignettes.
4+
5+
2016-11-24: Ver. 0.1-1
6+
* Add RPC.CS for pbdCS commands.
7+
* Add remoter and pbdCS applications to vignettes.
8+
* Adjust for Solaris and Mac OSX.
9+
10+
2016-11-19: Ver. 0.1-1
11+
* Move rpcopt and use .pbd_env$RPC.* in arguments.
12+
* Add RPC.RR for remoter commands.
13+
* Fix plink authentication problems.
14+
15+
2016-11-13: Ver. 0.1-1
16+
* Improve rpcopt.
17+
18+
2016-10-15: Ver. 0.1-1
19+
* Add controls and login design to .pbd_env for default.
20+
21+
2016-10-14:
22+
* Try Win32-OpenSSH, but it needs more external dependences.
23+
24+
2016-10-08: Ver. 0.1-1
25+
* Add low/raw level functions, such as ssh(), plink(), run_rpc(), ...
26+
27+
2016-07-27: Ver. 0.1-1
28+
* Add RPC calls.
29+
* Add start_remoter(), check_remoter(), and kill_remoter().
30+
31+
2016-07-21: Ver. 0.1-0
32+
* Initial the package and convert from pbdTERM.
33+
* Test on xubuntu, windows, and Solaris.
34+
* Fix windows 64bits.
35+
* Add ssh.
36+
37+
2015-xx-xx:
38+
* Initial pbdTERM.

DESCRIPTION

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Package: pbdRPC
2+
Version: 0.1-1
3+
Date: 2016-11-19
4+
Title: Programming with Big Data -- Remote Procedure Call
5+
Authors@R: c(person("Wei-Chen", "Chen", role = c("aut", "cre"), email =
6+
7+
Depends: R (>= 3.0.0)
8+
Enhances: pbdZMQ, remoter
9+
LazyLoad: yes
10+
LazyData: yes
11+
Copyright: See pbdRPC/inst/putty_LICENCE for files in src/putty/.
12+
Description: A very light yet secure implementation for remote procedure calls
13+
via ssh (OpenSSH) or plink/plink.exe (PuTTY).
14+
SystemRequirements: ssh (OpenSSH) on Solaris, Linux, and Mac.
15+
License: Mozilla Public License 2.0
16+
URL: http://r-pbd.org/
17+
BugReports: http://group.r-pbd.org/
18+
MailingList: Please send questions and comments regarding pbdR to
19+
20+
RoxygenNote: 5.0.1
21+
NeedsCompilation: yes
22+
Maintainer: Wei-Chen Chen <[email protected]>

INSTALL

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
0. download and extract 'pbdRPC'
2+
3+
1. Default Installation:
4+
This should work with most platforms.
5+
6+
> R CMD INSTALL pbdRPC_0.1-1.tar.gz

NAMESPACE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(.rpcopt_init)
4+
export(RPC.CT)
5+
export(RPC.LI)
6+
export(RPC.RR)
7+
export(check_cs)
8+
export(check_exec)
9+
export(check_rr)
10+
export(find_plink)
11+
export(kill_cs)
12+
export(kill_rr)
13+
export(plink)
14+
export(rpc)
15+
export(rpcopt_get)
16+
export(rpcopt_set)
17+
export(run_args)
18+
export(ssh)
19+
export(start_cs)
20+
export(start_rr)

R/000_globalVariables.r

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
### Do not delete this file and file name!!
2+
### This file should be loaded before all other *.r files.
3+
4+
### This is to avoid the false positive messages from R CMD check.
5+
### "no visible binding for global variable"
6+
### Suggested by Prof Brian Ripley
7+
### ?globalVariables
8+
9+
if(getRversion() >= "2.15.1"){
10+
utils::globalVariables(c(".pbd_env"))
11+
}

R/111_control.r

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#' Sets of controls in pbdRPC.
2+
#'
3+
#' These sets of controls are used to provide default values in pbdRPC package.
4+
#'
5+
#' @param verbose,wait,check.exec,use.shell.exec,pause
6+
#' RPC control for \code{system}, \code{shell.exec}, and so on.
7+
#' \code{wait = FALSE} allows asynchronous commands which need more test.
8+
#' e.g. continuously port forwarding without sending commands to background.
9+
#'
10+
#' @param exec.type,args,pport,user,hostname,priv.key,priv.key.ppk
11+
#' RPC login information used by \code{\link{rpc}()}, \code{\link{ssh}()}, or
12+
#' \code{\link{plink}()}.
13+
#'
14+
# #' @param unix,macos,windows
15+
#'
16+
#' @param check,kill,start,preload
17+
#' RPC remoter commands used by \code{\link{check_rr}()},
18+
#' \code{\link{kill_rr}()}, or \code{\link{start_rr}()}.
19+
#' RPC pbdCS commands used by \code{\link{check_cs}()},
20+
#' \code{\link{kill_cs}()}, or \code{\link{start_cs}()}.
21+
#'
22+
#' @author Wei-Chen Chen \email{wccsnow@@gmail.com}.
23+
#'
24+
#' Programming with Big Data in R Website: \url{http://r-pbd.org/}
25+
#'
26+
#' @keywords global variables
27+
#' @seealso \code{\link{.pbd_env}}.
28+
#' @name RPC Control Functions
29+
#' @rdname zz_rpc_control
30+
NULL
31+
32+
33+
### For RPC control.
34+
#' @export
35+
#' @rdname zz_rpc_control
36+
RPC.CT <- function(
37+
verbose = FALSE,
38+
wait = TRUE,
39+
check.exec = FALSE,
40+
use.shell.exec = TRUE,
41+
pause = TRUE
42+
){
43+
list(
44+
verbose = verbose,
45+
wait = wait,
46+
check.exec = check.exec,
47+
use.shell.exec = use.shell.exec,
48+
pause = pause
49+
)
50+
}
51+
52+
53+
### For RPC login information.
54+
#' @export
55+
#' @rdname zz_rpc_control
56+
RPC.LI <- function(
57+
exec.type = "ssh",
58+
args = "",
59+
pport = "22",
60+
user = "snoweye",
61+
hostname = "192.168.56.101",
62+
priv.key = "~/.ssh/id_rsa",
63+
priv.key.ppk = "./id_rsa.ppk"
64+
){
65+
list(
66+
exec.type = exec.type,
67+
args = args,
68+
pport = pport,
69+
user = user,
70+
hostname = hostname,
71+
priv.key = priv.key,
72+
priv.key.ppk = priv.key.ppk
73+
)
74+
}
75+
76+
77+
### For RPC searching order. TODO: further automation and detection.
78+
# #' @export
79+
# #' @rdname zz_rpc_control
80+
# RPC.SO <- function(
81+
# unix = c("ssh", "plink", "pbdRPC/libs/plink"),
82+
# macos = c("ssh", "plink", "pbdRPC/libs/plink"),
83+
# windows = c("ssh",
84+
# "C:/Program Files/OpenSSH/ssh",
85+
# "C:/Program Files (x86)/OpenSSH/ssh",
86+
# "plink",
87+
# "C:/Program Files/PuTTY/plink.exe",
88+
# "C:/Program Files (x86)/PuTTY/plink.exe",
89+
# "pbdRPC/libs/i386/plink.exe",
90+
# "pbdRPC/libs/x64/plink.exe")
91+
# ){
92+
# list(
93+
# unix = unix,
94+
# macos = macos,
95+
# windows = windows
96+
# )
97+
# }
98+
99+
100+
### For RPC remoter commands.
101+
#' @export
102+
#' @rdname zz_rpc_control
103+
RPC.RR <- function(
104+
check = "ps ax|grep '[r]emoter::server'",
105+
kill = "kill -9 $(ps ax|grep '[r]emoter::server'|awk '{print $1}')",
106+
start = "nohup Rscript -e 'remoter::server()' > .rrlog 2>&1 < /dev/null &",
107+
preload = "source ~/work-my/00_set_devel_R; "
108+
){
109+
list(
110+
check = check,
111+
kill = kill,
112+
start = start,
113+
preload = preload
114+
)
115+
}
116+
117+
### For RPC pbdCS commands.
118+
# #' @export
119+
# #' @rdname zz_rpc_control
120+
RPC.CS <- function(
121+
check = "ps ax|grep '[p]bdCS::pbdserver'",
122+
kill = "kill -9 $(ps ax|grep '[p]bdCS::pbdserver'|awk '{print $1}')",
123+
start = "nohup mpiexec -np 4 Rscript -e 'pbdCS::pbdserver()' > .cslog 2>&1 < /dev/null &",
124+
preload = "source ~/work-my/00_set_devel_R; "
125+
){
126+
list(
127+
check = check,
128+
kill = kill,
129+
start = start,
130+
preload = preload
131+
)
132+
}
133+

R/222_export_env.r

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#' Sets of controls in pbdRPC.
2+
#'
3+
#' These sets of controls are used to provide default values in this package.
4+
#'
5+
#' The elements of \code{.pbd_env$RPC.CT} are default values for looking RPC
6+
#' control files.
7+
#'
8+
#' The elements of \code{.pbd_env$RPC.LI} are default values for RPC defult
9+
#' login information.
10+
#'
11+
#' @name RPC Control Environment
12+
#' @aliases .pbd_env
13+
#' @docType data
14+
#' @format Objects contain several parameters for communicators and methods.
15+
#' @author Wei-Chen Chen \email{wccsnow@@gmail.com}.
16+
#'
17+
#' Programming with Big Data in R Website: \url{http://r-pbd.org/}
18+
#' @keywords global variables
19+
#' @seealso \code{\link{.rpcopt_init}()}.
20+
#' @rdname a0_b_control
21+
NULL
22+
23+
### These are fake. These only be here for reference and to fool
24+
### ``R CMD check''.
25+
### The real one ``in practicee and runtime'' is initialed by the
26+
### .rpcopt_init() which is always called by .OnLoad() in "zzz.r" to avoid
27+
### overloaded and can be really accessed by users instead of sealed by R
28+
### after loaded.
29+
###
30+
### WCC: DO ``NOT'' remark ``NOR'' use the next.
31+
# .pbd_env <- new.env()
32+
# .pbd_env$RPC.CT <- RPC.CT()
33+
# .pbd_env$RPC.LI <- RPC.LI()
34+
# .pbd_env$RPC.RR <- RPC.RR()
35+
# .pbd_env$RPC.CS <- RPC.CS()
36+

R/222_export_opt.r

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#' Initial controls in pbdRPC
2+
#'
3+
#' Initial control functions
4+
#'
5+
#' \code{.rpcopt_init()} initials default RPC controls.
6+
#'
7+
#' @param envir
8+
#' an environment where RPC controls locate
9+
#'
10+
#' @return
11+
#' \code{.rpcopt_init()} initial the RPC control
12+
#' at \code{envir}.
13+
#'
14+
#' @author Wei-Chen Chen \email{wccsnow@@gmail.com}.
15+
#'
16+
#' @references ZeroMQ/4.1.0 API Reference:
17+
#' \url{http://api.zeromq.org/4-1:_start}
18+
#'
19+
#' Programming with Big Data in R Website: \url{http://r-pbd.org/}
20+
#'
21+
#' @examples
22+
#' \dontrun{
23+
#' library(pbdRPC, quietly = TRUE)
24+
#' rpcopt_set(user = "snoweye", hostname = "192.168.56.101")
25+
#'
26+
#' ls(.pbd_env)
27+
#' rm(.pbd_env)
28+
#' .rpcopt_init()
29+
#' ls(.pbd_env)
30+
#'
31+
#' .pbd_env$RPC.LI
32+
#' }
33+
#'
34+
#' @keywords programming
35+
#' @seealso \code{.pbd_env}.
36+
#' @rdname a0_c_options
37+
#' @name Initial Control Functions
38+
39+
40+
### Initial RPC options.
41+
#' @export
42+
#' @rdname a0_c_options
43+
.rpcopt_init <- function(envir = .GlobalEnv){
44+
if(!exists(".pbd_env", envir = envir)){
45+
envir$.pbd_env <- new.env()
46+
}
47+
envir$.pbd_env$RPC.CT <- RPC.CT()
48+
envir$.pbd_env$RPC.LI <- RPC.LI()
49+
# envir$.pbd_env$RPC.SO <- RPC.SO()
50+
envir$.pbd_env$RPC.RR <- RPC.RR()
51+
envir$.pbd_env$RPC.CS <- RPC.CS()
52+
53+
invisible()
54+
} # End of .rpcopt_init().
55+

R/find_plink.r

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#' Find plink
2+
#'
3+
#' Find the plink internal compiled with pbdRPC package.
4+
#'
5+
#' @details
6+
#' The function returns a full path to the \code{plink} or \code{plink.exe}
7+
#' command if found.
8+
#'
9+
#' @return
10+
#' A full path a full path to the \code{plink} or \code{plink.exe}
11+
#' command if found. Otherwise, "plink" is returned.
12+
#'
13+
#' @examples
14+
#' \dontrun{
15+
#' library(pbdRPC, quietly = TRUE)
16+
#'
17+
#' find_plink()
18+
#' }
19+
#'
20+
#' @export
21+
find_plink <- function()
22+
{
23+
PACKAGE <- "pbdRPC"
24+
ret <- "plink"
25+
26+
pkg.path <- find.package(PACKAGE, quiet = TRUE)[1]
27+
if (length(pkg.path) == 1)
28+
{
29+
if (.Platform$OS.type == "windows")
30+
fn <- paste(pkg.path, "/libs", Sys.getenv("R_ARCH"),
31+
"/plink.exe", sep = "")
32+
else
33+
fn <- paste(pkg.path, "/libs", Sys.getenv("R_ARCH"), "/plink", sep = "")
34+
35+
if (file.exists(fn))
36+
ret <- fn
37+
}
38+
39+
return(ret)
40+
}
41+

0 commit comments

Comments
 (0)