supplier

package
v0.0.0-...-10b4495 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2021 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterOffersStrategy

func RegisterOffersStrategy(strategyName string, factory ManageOffersFactory)

RegisterOffersStrategy can be used to register a new strategy in order to be available.

Types

type ManageOffersFactory

type ManageOffersFactory func(node common.Node, config *configuration.Configuration) (OfferingStrategy, error)

ManageOffersFactory represents a method that creates a new offers manager.

type OfferingStrategy

type OfferingStrategy interface {
	// Init initializes the offers manager structure with the necessary objects, resourcesMap the GUID<->Resource map,
	// overlay the communication node overlay and the remoteClient that allows to communicate with other CARAVELA's nodes.
	Init(supp *Supplier, resourcesMap *resources.Mapping, overlay overlay.Overlay, remoteClient external.Caravela)

	// FindOffers searches in the system (with help of the overlay) for node's that have offers that offer at least the
	// same resources as targetResources.
	FindOffers(ctx context.Context, targetResources resources.Resources) []types.AvailableOffer

	// CreateOffer creates a new offer in the system given the current local's available resources.
	UpdateOffers(ctx context.Context, availableResources, usedResources resources.Resources)
}

OfferingStrategy is an interface that can be implemented in an object in order to perform the actions of managing the resources offering in the system ina different way. This is the fundamental for our initial work, because it is the way to test/compare several approaches.

func CreateOffersStrategy

func CreateOffersStrategy(node common.Node, config *configuration.Configuration) OfferingStrategy

CreateOffersStrategy is used to obtain an offers manager based on the configurations.

type Supplier

type Supplier struct {
	nodeCommon.NodeComponent // Base component
	// contains filtered or unexported fields
}

Supplier handles all the logic of managing the node own resources, advertising them into the system.

func NewSupplier

func NewSupplier(node nodeCommon.Node, config *configuration.Configuration, overlay overlay.Overlay, client external.Caravela,
	resourcesMap *resources.Mapping, maxResources resources.Resources) *Supplier

NewSupplier creates a new supplier component, that manages the local resources.

func (*Supplier) AvailableResources

func (s *Supplier) AvailableResources() types.Resources

Simulation

func (*Supplier) DebugSizeBytes

func (s *Supplier) DebugSizeBytes() int

func (*Supplier) FindOffers

func (s *Supplier) FindOffers(ctx context.Context, targetResources resources.Resources) []types.AvailableOffer

Find a list active Offers that best suit the target resources given.

func (*Supplier) IsWorking

func (s *Supplier) IsWorking() bool

func (*Supplier) MaximumResources

func (s *Supplier) MaximumResources() types.Resources

Simulation

func (*Supplier) NumActiveOffers

func (s *Supplier) NumActiveOffers() int

Simulation

func (*Supplier) ObtainResources

func (s *Supplier) ObtainResources(offerID int64, resourcesNecessary resources.Resources, numContainersToRun int) bool

Tries to obtain a subset of the resources represented by the given offer in order to deploy a container. It updates the respective trader that manages the offer.

func (*Supplier) RefreshOffer

func (s *Supplier) RefreshOffer(fromTrader *types.Node, refreshOffer *types.Offer) bool

Tries refresh an offer. Called when a refresh message was received.

func (*Supplier) ReturnResources

func (s *Supplier) ReturnResources(releasedResources resources.Resources, numContainersStopped int)

Release resources of an used offer into the supplier again in order to offer them again into the system.

func (*Supplier) Start

func (s *Supplier) Start()

func (*Supplier) Stop

func (s *Supplier) Stop()

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL