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:
std::shared_ptr<Container> findIdleContainer(const RegisteredFunction *registered_function, const std::set<std::shared_ptr<Container>> &excluded_container) const

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

bool findIdleContainersToTerminate(sg_size_t needed_free_ram_space, sg_size_t needed_free_disk_space, std::set<std::shared_ptr<Container>> &to_terminate) const

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

bool isImageBeingCopied(const std::shared_ptr<Image> &image) const

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

bool isImageBeingLoaded(const std::shared_ptr<Image> &image) const

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

bool isImageInRAM(const std::shared_ptr<Image> &image) const

Is an image in RAM?

Parameters:

image – an image file

Returns:

True if the image is in RAM

bool isImageOnDisk(const std::shared_ptr<Image> &image) const

Is an image on disk?

Parameters:

image – an image

Returns:

True if the image is on disk

bool isInvocationFeasible(const std::shared_ptr<Invocation> &invocation, const std::shared_ptr<Container> &target_container) const

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

void makeContainerBusy(const std::shared_ptr<Container> &container)

Make a container busy.

Parameters:

container – a container

void makeContainerIdle(const std::shared_ptr<Container> &container)

Make a container idle.

Parameters:

container – a container

void shutdownContainer(const std::shared_ptr<Container> &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.