package strategy
import "github.com/docker/swarm/scheduler/strategy"
Index ¶
- Variables
- func List() []string
- type BinpackPlacementStrategy
- func (p *BinpackPlacementStrategy) Initialize() error
- func (p *BinpackPlacementStrategy) Name() string
- func (p *BinpackPlacementStrategy) RankAndSort(config *cluster.ContainerConfig, nodes []*node.Node) ([]*node.Node, error)
- type PlacementStrategy
- type RandomPlacementStrategy
- func (p *RandomPlacementStrategy) Initialize() error
- func (p *RandomPlacementStrategy) Name() string
- func (p *RandomPlacementStrategy) RankAndSort(config *cluster.ContainerConfig, nodes []*node.Node) ([]*node.Node, error)
- type SpreadPlacementStrategy
Variables ¶
var ( // ErrNotSupported is the error returned when a strategy name does not match // any supported placement strategy. ErrNotSupported = errors.New("strategy not supported") // ErrNoResourcesAvailable is the error returned when there are no resources // available to schedule a container. This can occur if there are no nodes in // the cluster or if no node contains sufficient resources for the container. ErrNoResourcesAvailable = errors.New("no resources available to schedule container") )
Functions ¶
func List ¶
func List() []string
List returns the names of all the available strategies.
Types ¶
type BinpackPlacementStrategy ¶
type BinpackPlacementStrategy struct { }
BinpackPlacementStrategy places a container onto the most packed node in the cluster.
func (*BinpackPlacementStrategy) Initialize ¶
func (p *BinpackPlacementStrategy) Initialize() error
Initialize a BinpackPlacementStrategy.
func (*BinpackPlacementStrategy) Name ¶
func (p *BinpackPlacementStrategy) Name() string
Name returns the name of the strategy.
func (*BinpackPlacementStrategy) RankAndSort ¶
func (p *BinpackPlacementStrategy) RankAndSort(config *cluster.ContainerConfig, nodes []*node.Node) ([]*node.Node, error)
RankAndSort sorts nodes based on the binpack strategy applied to the container config.
type PlacementStrategy ¶
type PlacementStrategy interface { // Name of the strategy Name() string // Initialize performs any initial configuration required by the strategy and returns // an error if one is encountered. // If no initial configuration is needed, this may be a no-op and return a nil error. Initialize() error // RankAndSort applies the strategy to a list of nodes and ranks them based // on the best fit given the container configuration. It returns a sorted // list of nodes (based on their ranks) or an error if there is no // available node on which to schedule the container. RankAndSort(config *cluster.ContainerConfig, nodes []*node.Node) ([]*node.Node, error) }
PlacementStrategy is the interface for a container placement strategy.
func New ¶
func New(name string) (PlacementStrategy, error)
New creates a new PlacementStrategy for the given strategy name.
type RandomPlacementStrategy ¶
type RandomPlacementStrategy struct {
// contains filtered or unexported fields
}
RandomPlacementStrategy randomly places the container into the cluster.
func (*RandomPlacementStrategy) Initialize ¶
func (p *RandomPlacementStrategy) Initialize() error
Initialize a RandomPlacementStrategy.
func (*RandomPlacementStrategy) Name ¶
func (p *RandomPlacementStrategy) Name() string
Name returns the name of the strategy.
func (*RandomPlacementStrategy) RankAndSort ¶
func (p *RandomPlacementStrategy) RankAndSort(config *cluster.ContainerConfig, nodes []*node.Node) ([]*node.Node, error)
RankAndSort randomly sorts the list of nodes.
type SpreadPlacementStrategy ¶
type SpreadPlacementStrategy struct { }
SpreadPlacementStrategy places a container on the node with the fewest running containers.
func (*SpreadPlacementStrategy) Initialize ¶
func (p *SpreadPlacementStrategy) Initialize() error
Initialize a SpreadPlacementStrategy.
func (*SpreadPlacementStrategy) Name ¶
func (p *SpreadPlacementStrategy) Name() string
Name returns the name of the strategy.
func (*SpreadPlacementStrategy) RankAndSort ¶
func (p *SpreadPlacementStrategy) RankAndSort(config *cluster.ContainerConfig, nodes []*node.Node) ([]*node.Node, error)
RankAndSort sorts nodes based on the spread strategy applied to the container config.
Source Files ¶
binpack.go random.go spread.go strategy.go weighted_node.go
- Version
- v1.2.9 (latest)
- Published
- Jun 1, 2018
- Platform
- linux/amd64
- Imports
- 7 packages
- Last checked
- 3 weeks ago –
Tools for package owners.