Docker Swarm Code Analysis Note (--strategy)

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Docker Swarm manageThe option of the command is flStrategy used to specify the scheduler filtered item of the schedule strategy , and its variable is defined as follows ( cli/flags.go ):

flStrategy = cli.StringFlag{    Name:  "strategy",    Usage: "placement strategy to use [" + strings.Join(strategy.List(), ", ") + "]",    Value: strategy.List()[0],}

strategyThe default value is SpreadPlacementStrategy .

strategyThe actual definition in the code is PlacementStrategy , one interface :

// PlacementStrategy is the interface for a container placement strategy.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)}

RankAndSortit returns a list that matches the criteria node ( Docker Engine that is), and the elements in the list are sorted by the matching degree.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.