Skip to contents

This class contains the information required to start a backend. An instance of this class is used by the start method of the Service interface.

Active bindings

cores

The number of nodes to use in the cluster creation.

type

The type of cluster to create.

types

The supported cluster types.

Methods


Method set_cores()

Set the number of nodes to use in the cluster.

Usage

Specification$set_cores(cores)

Arguments

cores

The number of nodes to use in the cluster.

Details

This method also performs a validation of the requested number of cores, ensuring that the the value lies between 2 and parallel::detectCores() - 1.


Method set_type()

Set the type of cluster to create.

Usage

Specification$set_type(type)

Arguments

type

The type of cluster to create. Possible values are "fork" and "psock". Defaults to "psock".

Details

If no type is explicitly requested (i.e., type = NULL), the type is determined based on the operating system. On Unix-like systems, the type is set to "fork", while on Windows systems, the type is set to "psock". If an unknown type is requested, a warning is issued and the type is set to "psock".


Method clone()

The objects of this class are cloneable with this method.

Usage

Specification$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

# Create a specification object.
specification <- Specification$new()

# Set the number of cores.
specification$set_cores(cores = 4)
#> Warning: Argument `cores` cannot be larger than 3. Setting to 3.

# Set the cluster type.
specification$set_type(type = "psock")

# Get the number of cores.
specification$cores
#> [1] 3

# Get the cluster type.
specification$type
#> [1] "PSOCK"

# Attempt to set too many cores.
specification$set_cores(cores = 100)
#> Warning: Argument `cores` cannot be larger than 3. Setting to 3.

# Check that the cores were reasonably set.
specification$cores
#> [1] 3

# Allow the object to determine the adequate cluster type.
specification$set_type(type = NULL)

# Check the type determined.
specification$type
#>   unix 
#> "FORK" 

# Attempt to set an invalid cluster type.
specification$set_type(type = "invalid")
#> Warning: Argument `type` must be 'fork' or 'psock'. Defaulting to 'psock'.

# Check that the type was set to `psock`.
specification$type
#> windows 
#> "PSOCK"