Title: | Providing the Kubernetes-Like Functions for the Non-Kubernetes Cloud Service |
---|---|
Description: | Providing the kubernetes-like class 'ManagedCloudProvider' as a child class of the 'CloudProvider' class in the 'DockerParallel' package. The class is able to manage the cloud instance made by the non-kubernetes cloud service. For creating a provider for the non-kubernetes cloud service, the developer needs to define a reference class inherited from 'ManagedCloudProvider' and define the method for the generics runDockerWorkerContainers(), getDockerWorkerStatus() and killDockerWorkerContainers(). For more information, please see the vignette in this package and <https://CRAN.R-project.org/package=DockerParallel> |
Authors: | Jiefei Wang [aut, cre] |
Maintainer: | Jiefei Wang <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-14 03:13:26 UTC |
Source: | https://github.com/jiefei-wang/managedcloudprovider |
Add or get the worker container handles to the managed cloud provider. The handles can be duplicated if multiple workers share the same container
addManagedWorkerHandles(provider, handles) getManagedWorkerHandles(provider)
addManagedWorkerHandles(provider, handles) getManagedWorkerHandles(provider)
provider |
A |
handles |
the worker container handles |
addManagedWorkerHandles: No return value getManagedWorkerHandles: A character vector of the worker handles
## make a dummy provider DummyProvider <- setRefClass("DummyProvider", contains = "ManagedCloudProvider") provider <- DummyProvider() ## No worker handle in the provider getManagedWorkerHandles(provider) ## Add worker handles addManagedWorkerHandles(provider, c("a", "b")) getManagedWorkerHandles(provider) ## It is possible to add the same handle ## if multiple workers share the same container addManagedWorkerHandles(provider, c("a")) getManagedWorkerHandles(provider)
## make a dummy provider DummyProvider <- setRefClass("DummyProvider", contains = "ManagedCloudProvider") provider <- DummyProvider() ## No worker handle in the provider getManagedWorkerHandles(provider) ## Add worker handles addManagedWorkerHandles(provider, c("a", "b")) getManagedWorkerHandles(provider) ## It is possible to add the same handle ## if multiple workers share the same container addManagedWorkerHandles(provider, c("a")) getManagedWorkerHandles(provider)
The developer should define runDockerWorkerContainers
, getDockerWorkerStatus
and killDockerWorkerContainers
instead.
## S4 method for signature 'ManagedCloudProvider' getDockerWorkerNumbers(provider, cluster, verbose)
## S4 method for signature 'ManagedCloudProvider' getDockerWorkerNumbers(provider, cluster, verbose)
provider |
S4 |
cluster |
S4 |
verbose |
Integer. The verbose level, default 1. |
A list with initializing
and running
integer elements
Get the worker status. Unless you have a faster implementation, you only need to
define getDockerWorkerStatus
. The function should return a character vector with
each element corresponding to a worker in workerHandles
.
Each element must be one of three possible characters "initializing"
, "running"
or
"stopped"
. There is no default method for getDockerWorkerStatus
.
getDockerWorkerStatus(provider, cluster, workerHandles, verbose) IsDockerWorkerInitializing(provider, cluster, workerHandles, verbose) IsDockerWorkerRunning(provider, cluster, workerHandles, verbose) IsDockerWorkerStopped(provider, cluster, workerHandles, verbose) ## S4 method for signature 'DummyManagedProvider' getDockerWorkerStatus(provider, cluster, workerHandles, verbose) ## S4 method for signature 'ANY' IsDockerWorkerInitializing(provider, cluster, workerHandles, verbose = 0L) ## S4 method for signature 'ANY' IsDockerWorkerRunning(provider, cluster, workerHandles, verbose = 0L) ## S4 method for signature 'ANY' IsDockerWorkerStopped(provider, cluster, workerHandles, verbose = 0L)
getDockerWorkerStatus(provider, cluster, workerHandles, verbose) IsDockerWorkerInitializing(provider, cluster, workerHandles, verbose) IsDockerWorkerRunning(provider, cluster, workerHandles, verbose) IsDockerWorkerStopped(provider, cluster, workerHandles, verbose) ## S4 method for signature 'DummyManagedProvider' getDockerWorkerStatus(provider, cluster, workerHandles, verbose) ## S4 method for signature 'ANY' IsDockerWorkerInitializing(provider, cluster, workerHandles, verbose = 0L) ## S4 method for signature 'ANY' IsDockerWorkerRunning(provider, cluster, workerHandles, verbose = 0L) ## S4 method for signature 'ANY' IsDockerWorkerStopped(provider, cluster, workerHandles, verbose = 0L)
provider |
S4 |
cluster |
S4 |
workerHandles |
Character(n). A character vector of unique instance handles. |
verbose |
Integer. The verbose level, default 1. |
getDockerWorkerStatus
: A character vector with each element corresponding
to an instance in workerHandles
. Each element must be one of three possible characters
"initializing"
, "running"
or "stopped"
IsDockerWorkerInitializing
, IsDockerWorkerRunning
, IsDockerWorkerStopped
:
A logical vector with each element corresponding to the status of each instance
getDockerWorkerStatus,DummyManagedProvider-method
: The method for the dummy managed provider
Kill the worker container. The worker handles are unique. If multiple workers share the same instance, all workers in the same container should be killed. There is no default method for this generic.
killDockerWorkerContainers(provider, cluster, workerHandles, verbose) ## S4 method for signature 'DummyManagedProvider' killDockerWorkerContainers(provider, cluster, workerHandles, verbose)
killDockerWorkerContainers(provider, cluster, workerHandles, verbose) ## S4 method for signature 'DummyManagedProvider' killDockerWorkerContainers(provider, cluster, workerHandles, verbose)
provider |
S4 |
cluster |
S4 |
workerHandles |
Character(n). A character vector of unique instance handles. |
verbose |
Integer. The verbose level, default 1. |
A logical vector indicating whether the killing operation is successful for each instance
killDockerWorkerContainers,DummyManagedProvider-method
: The method for the dummy managed provider
The root class for the managed cloud provider
serverHandle
Character(1), the server handle that can be recognized by the cloud provider.
workerHandles
Character(n), a list object for internal use only.
Please call .getWorkerHandles(cluster)
to access the worker handles
workerPerHandle
An internal counter. Please call .getWorkerHandles(cluster)
to access the worker handles
Run the workers and return a character vector of the worker handles. Each handle must correspond to a container. The handle can be duplicated if multiple workers share the same container. There is no default method for this generic.
runDockerWorkerContainers( provider, cluster, container, hardware, workerNumber, verbose ) ## S4 method for signature 'DummyManagedProvider' runDockerWorkerContainers( provider, cluster, container, hardware, workerNumber, verbose )
runDockerWorkerContainers( provider, cluster, container, hardware, workerNumber, verbose ) ## S4 method for signature 'DummyManagedProvider' runDockerWorkerContainers( provider, cluster, container, hardware, workerNumber, verbose )
provider |
S4 |
cluster |
S4 |
container |
S4 |
hardware |
S4 |
workerNumber |
Integer. The number of workers needs to be run. |
verbose |
Integer. The verbose level, default 1. |
A character vector with each element corresponding to a worker container.
The length must be equal to workerNumber
runDockerWorkerContainers,DummyManagedProvider-method
: The method for the dummy managed provider
The developer should define runDockerWorkerContainers
, getDockerWorkerStatus
and killDockerWorkerContainers
instead.
## S4 method for signature 'ManagedCloudProvider' setDockerWorkerNumber( provider, cluster, container, hardware, workerNumber, verbose )
## S4 method for signature 'ManagedCloudProvider' setDockerWorkerNumber( provider, cluster, container, hardware, workerNumber, verbose )
provider |
S4 |
cluster |
S4 |
container |
S4 |
hardware |
S4 |
workerNumber |
Integer(1), the worker number to be set |
verbose |
Integer. The verbose level, default 1. |
No return value