scheduler

package
v0.0.0-...-88aa921 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2015 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Copyright 2014 The Serviced Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

PriorityQueue implementation take from golang std library container/heap documentation example

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lead

func Lead(shutdown <-chan interface{}, conn coordclient.Connection, cpClient dao.ControlPlane, poolID string, snapshotTTL int)

Lead is executed by the "leader" of the control center cluster to handle its management responsibilities of:

services
snapshots
virtual IPs

func NewScheduler

func NewScheduler(poolID string, instance_id string, storageServer *storage.Server, cpDao dao.ControlPlane, facade *facade.Facade, snapshotTTL int) (*scheduler, error)

NewScheduler creates a new scheduler master

Types

type DAOHostInfo

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

func (*DAOHostInfo) AvailableRAM

func (hi *DAOHostInfo) AvailableRAM(host *host.Host, result chan *hostitem, done <-chan bool)

AvailableRAM computes the amount of RAM available on a given host by subtracting the sum of the RAM commitments of each of its running services from its total memory.

func (*DAOHostInfo) PrioritizeByMemory

func (hi *DAOHostInfo) PrioritizeByMemory(hosts []*host.Host) ([]*host.Host, error)

func (*DAOHostInfo) ServicesOnHost

func (hi *DAOHostInfo) ServicesOnHost(h *host.Host) []dao.RunningService

type HostInfo

type HostInfo interface {
	AvailableRAM(*host.Host, chan *hostitem, <-chan bool)
	PrioritizeByMemory([]*host.Host) ([]*host.Host, error)
	ServicesOnHost(*host.Host) []dao.RunningService
}

HostInfo provides methods for getting host information from the dao or otherwise. It's a separate interface for the sake of testing.

type PriorityQueue

type PriorityQueue []*hostitem

PriorityQueue implements the heap.Interface and holds hostitems

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

Len is the number of elements in the collection.

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

Less reports whether the element with index i should sort before the element with index j.

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

Pop removes the minimum element (according to Less) from the heap and returns it.

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

Push pushes the hostitem onto the heap.

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

Swap swaps the elements with indexes i and j.

type ServiceHostPolicy

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

ServiceHostPolicy wraps a service and provides several policy implementations for choosing hosts on which to run instances of that service.

func NewServiceHostPolicy

func NewServiceHostPolicy(s *service.Service, cp dao.ControlPlane) *ServiceHostPolicy

ServiceHostPolicy returns a new ServiceHostPolicy.

func (*ServiceHostPolicy) SelectHost

func (sp *ServiceHostPolicy) SelectHost(hosts []*host.Host) (*host.Host, error)

Jump to

Keyboard shortcuts

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