scheduler

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUsedResourcesByHost added in v0.8.0

func GetUsedResourcesByHost(client metadata.Client) (map[string]map[string]int64, error)

func ParsePort added in v0.8.0

func ParsePort(port string) (string, int64, string, bool)

ParsePort parse port info in a string format. Expect ip:public:private, return ip and public

func PortRelease added in v0.6.0

func PortRelease(pool *PortResourcePool, request PortBindingResourceRequest)

func PortReserve added in v0.6.0

func PortReserve(pool *PortResourcePool, request PortBindingResourceRequest) (map[string]interface{}, error)

func SetPortBinding added in v0.8.0

func SetPortBinding(bindings map[string]map[int64]string, ghostBindings map[string]map[int64]string, ip string,
	port int64, container metadata.Container)

Types

type AmountBasedResourceRequest added in v0.6.0

type AmountBasedResourceRequest struct {
	Resource string
	Amount   int64
}

func (AmountBasedResourceRequest) GetResourceType added in v0.6.0

func (c AmountBasedResourceRequest) GetResourceType() string

type BaseResourceRequest added in v0.6.0

type BaseResourceRequest struct {
	Resource string
	Type     string
}

func (BaseResourceRequest) GetResourceType added in v0.6.0

func (b BaseResourceRequest) GetResourceType() string

type ComputeFilter added in v0.8.0

type ComputeFilter struct {
}

ComputeFilter define a filter based on cpu, memory and instance number

func (ComputeFilter) Filter added in v0.8.0

func (c ComputeFilter) Filter(scheduler *Scheduler, resourceRequests []ResourceRequest, context Context, hosts []string) []string

type ComputeReleaseAction added in v0.8.0

type ComputeReleaseAction struct{}

ComputeReleaseAction is a release action to release cpu, memory, instance counts and other compute resources

func (ComputeReleaseAction) Release added in v0.8.0

func (c ComputeReleaseAction) Release(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host)

type ComputeReserveAction added in v0.8.0

type ComputeReserveAction struct {
	// contains filtered or unexported fields
}

ComputeReserveAction is a reserve action for cpu, memory, instance count and other compute resource.

func (*ComputeReserveAction) Reserve added in v0.8.0

func (c *ComputeReserveAction) Reserve(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host, force bool, data map[string]interface{}) error

func (*ComputeReserveAction) RollBack added in v0.8.0

func (c *ComputeReserveAction) RollBack(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host)

type ComputeResourcePool added in v0.6.0

type ComputeResourcePool struct {
	Resource  string
	Total     int64
	Used      int64
	UpdateAll bool
}

func (*ComputeResourcePool) Create added in v0.8.0

func (c *ComputeResourcePool) Create(host *host)

func (*ComputeResourcePool) GetPoolResourceType added in v0.6.0

func (c *ComputeResourcePool) GetPoolResourceType() string

func (*ComputeResourcePool) GetPoolType added in v0.6.0

func (c *ComputeResourcePool) GetPoolType() string

func (*ComputeResourcePool) Update added in v0.8.0

func (c *ComputeResourcePool) Update(host *host)

type Constraints added in v0.7.0

type Constraints interface {
	Match(string, *Scheduler, Context) bool
}

type Context added in v0.7.0

type Context []contextStruct

type Filter added in v0.8.0

type Filter interface {
	Filter(scheduler *Scheduler, resourceRequest []ResourceRequest, context Context, hosts []string) []string
}

Filter is an interface to prioritize and filter the hosts

type LabelFilter added in v0.8.0

type LabelFilter struct {
}

LabelFilter define a filter based on label constraints. For example, require_any label constraints

func (LabelFilter) Filter added in v0.8.0

func (l LabelFilter) Filter(scheduler *Scheduler, resourceRequest []ResourceRequest, context Context, hosts []string) []string

type LabelPool added in v0.7.0

type LabelPool struct {
	Resource string
	Labels   map[string]string
}

func (*LabelPool) Create added in v0.8.0

func (p *LabelPool) Create(host *host)

func (*LabelPool) GetPoolResourceType added in v0.7.0

func (p *LabelPool) GetPoolResourceType() string

func (*LabelPool) GetPoolType added in v0.7.0

func (p *LabelPool) GetPoolType() string

func (*LabelPool) Update added in v0.8.0

func (p *LabelPool) Update(host *host)

type OverReserveError

type OverReserveError struct {
	// contains filtered or unexported fields
}

func (OverReserveError) Error

func (e OverReserveError) Error() string

type PortBindingResourceRequest added in v0.6.0

type PortBindingResourceRequest struct {
	Resource     string
	InstanceID   string
	ResourceUUID string
	PortRequests []PortSpec
}

func (PortBindingResourceRequest) GetResourceType added in v0.6.0

func (p PortBindingResourceRequest) GetResourceType() string

type PortFilter added in v0.8.0

type PortFilter struct {
}

PortFilter define a filter based on ports conflicts

func (PortFilter) Filter added in v0.8.0

func (c PortFilter) Filter(scheduler *Scheduler, resourceRequests []ResourceRequest, context Context, hosts []string) []string

type PortReleaseAction added in v0.8.0

type PortReleaseAction struct{}

PortReleaseAction is a release action to release ports resources

func (PortReleaseAction) Release added in v0.8.0

func (p PortReleaseAction) Release(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host)

type PortReserveAction added in v0.8.0

type PortReserveAction struct {
	// contains filtered or unexported fields
}

PortReserveAction is a reserve action for ports

func (*PortReserveAction) Reserve added in v0.8.0

func (p *PortReserveAction) Reserve(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host, force bool, data map[string]interface{}) error

func (*PortReserveAction) RollBack added in v0.8.0

func (p *PortReserveAction) RollBack(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host)

type PortResourcePool added in v0.6.0

type PortResourcePool struct {
	Resource          string
	PortBindingMapTCP map[string]map[int64]string
	PortBindingMapUDP map[string]map[int64]string
	GhostMapTCP       map[string]map[int64]string
	GhostMapUDP       map[string]map[int64]string
	ShouldUpdate      bool
}

func GetPortPoolFromHost added in v0.8.0

func GetPortPoolFromHost(h metadata.Host, client metadata.Client) (*PortResourcePool, error)

func (*PortResourcePool) ArePortsAvailable added in v0.6.0

func (p *PortResourcePool) ArePortsAvailable(ports []PortSpec) bool

func (*PortResourcePool) Create added in v0.8.0

func (p *PortResourcePool) Create(host *host)

func (*PortResourcePool) GetPoolResourceType added in v0.6.0

func (p *PortResourcePool) GetPoolResourceType() string

func (*PortResourcePool) GetPoolType added in v0.6.0

func (p *PortResourcePool) GetPoolType() string

func (*PortResourcePool) IsIPQualifiedForRequests added in v0.6.0

func (p *PortResourcePool) IsIPQualifiedForRequests(ip, uuid string, specs []PortSpec) bool

func (*PortResourcePool) ReleasePort added in v0.6.0

func (p *PortResourcePool) ReleasePort(ip string, port int64, protocol string, uuid string)

func (*PortResourcePool) ReserveIPPort added in v0.6.0

func (p *PortResourcePool) ReserveIPPort(ip string, port int64, protocol string, instanceUUID string) error

ReserveIPPort reserve an ip and port from a port pool if the ip is not in the default map, then reserve on the ghost map.

case 1: reserve default map 0.0.0.0, ip 192.168.1.1. Check if port is used by 0.0.0.0, if not then reserve on ghost map
case 2: reserve default map 192.168.1.1, 192.168.1.2, ip 192.168.1.3. Check if port is used by 0.0.0.0(ghost map), then reserve.
case 3: ip 0.0.0.0, reserve every ip in ghost map and default map.

if the ip is in the default map and it is 0.0.0.0, then do a check on ghost map to see if port is used

func (*PortResourcePool) Update added in v0.8.0

func (p *PortResourcePool) Update(host *host)

type PortSpec added in v0.6.0

type PortSpec struct {
	PrivatePort int64
	IPAddress   string
	PublicPort  int64
	Protocol    string
}

type ReleaseAction added in v0.8.0

type ReleaseAction interface {
	Release(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host)
}

ReleaseAction is an interface to provide a way to release a resource in scheduler

type RequireAnyLabelContraints added in v0.7.0

type RequireAnyLabelContraints struct{}

func (RequireAnyLabelContraints) Match added in v0.7.0

func (c RequireAnyLabelContraints) Match(host string, s *Scheduler, context Context) bool

type ReserveAction added in v0.8.0

type ReserveAction interface {
	Reserve(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host, force bool, data map[string]interface{}) error
	RollBack(scheduler *Scheduler, requests []ResourceRequest, context Context, host *host)
}

ReserveAction is an interface to provide a way to reserve a resource in scheduler

type ResourcePool added in v0.6.0

type ResourcePool interface {
	GetPoolResourceType() string
	GetPoolType() string
	Create(host *host)
	Update(host *host)
}

type ResourceRequest

type ResourceRequest interface {
	GetResourceType() string
}

type ResourceUpdater

type ResourceUpdater interface {
	CreateResourcePool(hostUUID string, pool ResourcePool) error
	UpdateResourcePool(hostUUID string, pool ResourcePool) bool
	RemoveHost(hostUUID string)
	CompareHostLabels(hosts []metadata.Host) bool
	UpdateWithMetadata(force bool) (bool, error)
	GetMetadataClient() metadata.Client
	SetMetadataClient(client metadata.Client)
}

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

func NewScheduler

func NewScheduler(sleepTime int) *Scheduler

func (*Scheduler) CompareHostLabels added in v0.7.2

func (s *Scheduler) CompareHostLabels(hosts []metadata.Host) bool

func (*Scheduler) CreateResourcePool

func (s *Scheduler) CreateResourcePool(hostUUID string, pool ResourcePool) error

func (*Scheduler) GetMetadataClient added in v0.8.0

func (s *Scheduler) GetMetadataClient() metadata.Client

func (*Scheduler) PrioritizeCandidates

func (s *Scheduler) PrioritizeCandidates(resourceRequests []ResourceRequest, context Context) ([]string, error)

func (*Scheduler) ReleaseResources

func (s *Scheduler) ReleaseResources(hostID string, resourceRequests []ResourceRequest) error

func (*Scheduler) RemoveHost

func (s *Scheduler) RemoveHost(hostUUID string)

func (*Scheduler) ReserveResources

func (s *Scheduler) ReserveResources(hostID string, force bool, resourceRequests []ResourceRequest) (map[string]interface{}, error)

func (*Scheduler) SetMetadataClient added in v0.8.0

func (s *Scheduler) SetMetadataClient(client metadata.Client)

func (*Scheduler) UpdateResourcePool

func (s *Scheduler) UpdateResourcePool(hostUUID string, pool ResourcePool) bool

func (*Scheduler) UpdateWithMetadata added in v0.8.0

func (s *Scheduler) UpdateWithMetadata(force bool) (bool, error)

Jump to

Keyboard shortcuts

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