make_cluster creates a cluster of type 'miraiCluster', which may be used as
a cluster object for any function in the parallel base package such as
parallel::clusterApply() or parallel::parLapply().
stop_cluster stops a cluster created by make_cluster.
make_cluster(n, url = NULL, remote = NULL, ...)stop_cluster(cl)
For make_cluster: An object of class 'miraiCluster' and
'cluster'. Each 'miraiCluster' has an automatically assigned ID and n
nodes of class 'miraiNode'. If url is supplied but not remote, the
shell commands for deployment of nodes on remote resources are printed to
the console.
For stop_cluster: invisible NULL.
(integer) number of nodes. Launched locally unless url is
supplied.
(character) host URL for remote nodes to dial into, e.g. 'tcp://10.75.37.40:5555'. Use 'tls+tcp://' for secure TLS.
(configuration) for launching remote nodes, generated by
ssh_config(), cluster_config(), or remote_config().
(daemons arguments) passed to daemons().
(miraiCluster) cluster to stop.
Specify url and n to set up a host connection for remote nodes to dial
into. n defaults to one if not specified.
Also specify remote to launch the nodes using a configuration generated by
remote_config() or ssh_config(). In this case, the number of nodes is
inferred from the configuration provided and n is disregarded.
If remote is not supplied, the shell commands for deploying nodes manually
on remote resources are automatically printed to the console.
launch_remote() may be called at any time on a 'miraiCluster' to return the
shell commands for deployment of all nodes, or on a 'miraiNode' to return the
command for a single node.
Errors are thrown by the parallel package mechanism if one or more nodes failed (quit unexpectedly). The returned 'errorValue' is 19 (Connection reset). Other types of error, e.g. in evaluation, result in the usual 'miraiError' being returned.
For R version 4.5 or newer, parallel::makeCluster() specifying
type = "MIRAI" is equivalent to this function.
if (FALSE) { # interactive()
cl <- make_cluster(2)
cl
cl[[1L]]
Sys.sleep(0.5)
status(cl)
stop_cluster(cl)
}
Run the code above in your browser using DataLab