wrench::ServerlessComputeNode
-
class ServerlessComputeNode
A class that stores the state of a serverless compute node.
Public Functions
-
ServerlessComputeNode(std::string h, unsigned int num_cores, ServerlessComputeService *service)
Constructor.
- Parameters:
h – hostname
num_cores – number of cores
service – the ServerlessComputeService that owns this compute node
Method to see if there is an appropriate idle container.
- Parameters:
registered_function – the target function
excluded_container – set containers to ignore
- Returns:
A container, if found, or nullptr
Method to identify which idle containers to terminate to create at least some free RAM space. It returns the smallest set possible in terms of number of containers to terminate, trying to free up as little memory as possible (it’s not optimal in this regard however, as finding the smallest set with the smallest sum is NP-hard, and would require dynamic programming, etc.) This is a really a super-generic method that is implementing an algorithm, and it’s not Container-specific.
- Parameters:
needed_free_ram_space – The RAM space needed in bytes
needed_free_disk_space – The Disk space needed in bytes
to_terminate – The set of containers to terminate (reference, will be updated)
- Returns:
a set of idle containers that could be terminated to reach free space
-
std::shared_ptr<SimpleStorageService> getDiskStorage() const
Get the compute node’s disk storage.
- Returns:
A storage service
-
sg_size_t getFreeDiskSpace() const
Get the compute node’s free disk space.
- Returns:
a number of bytes
-
sg_size_t getFreeRAMSpace() const
Get the compute node’s free RAM space.
- Returns:
a number of bytes
-
std::set<std::shared_ptr<Container>> getIdleContainers() const
Retrieve the set of idle container.
- Returns:
A set of containers
-
std::set<std::shared_ptr<Image>> getImagesBeingCopied() const
Get the set of images being copied to (the disk of) the compute node.
- Returns:
A set of images
-
std::set<std::shared_ptr<Image>> getImagesBeingLoaded() const
Get the set of images being loaded to (the RAM of) the compute node.
- Returns:
A set of images
-
std::shared_ptr<SimpleStorageService> getMemoryStorage() const
Get the compute node’s RAM storage.
- Returns:
A storage service
-
unsigned int getNumCores() const
Get the compute node’s number of cores.
- Returns:
a number of cores
-
unsigned int getNumIdleCores() const
Get the compute node’s number of idle cores.
- Returns:
a number of cores
Is an image in the process of being copied to (the disk of) the compute node?
- Parameters:
image – an image file
- Returns:
True if the image is being copied
Is an image in the process of being loaded to (the RAM of) the compute node?
- Parameters:
image – an image file
- Returns:
True if the image is being loaded
Is an image in RAM?
- Parameters:
image – an image file
- Returns:
True if the image is in RAM
Is an image on disk?
- Parameters:
image – an image
- Returns:
True if the image is on disk
Helper method to ensure that an invocation can be dispatched.
- Parameters:
invocation – the invocation to start
target_container – the target container (nullptr if none)
- Returns:
true if the invocation can be dispatched, false otherwise
Make a container busy.
- Parameters:
container – a container
Make a container idle.
- Parameters:
container – a container
Shutdown a container.
- Parameters:
container – a container
-
std::shared_ptr<Container> spawnContainer(const RegisteredFunction *registered_function)
Spawn a container (and try to kill idle containers if it helps)
- Parameters:
registered_function – a registered function
- Returns:
A container
Public Members
-
const std::string hostname
The hostname of the compute node.
-
ServerlessComputeNode(std::string h, unsigned int num_cores, ServerlessComputeService *service)