本文整理汇总了Golang中github.com/docker/swarm/scheduler/node.AddContainer函数的典型用法代码示例。如果您正苦于以下问题:Golang AddContainer函数的具体用法?Golang AddContainer怎么用?Golang AddContainer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddContainer函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestSpreadPlaceContainerHuge
func TestSpreadPlaceContainerHuge(t *testing.T) {
s := &SpreadPlacementStrategy{}
nodes := []*node.Node{}
for i := 0; i < 100; i++ {
nodes = append(nodes, createNode(fmt.Sprintf("node-%d", i), 1, 1))
}
// add 100 container 1CPU
for i := 0; i < 100; i++ {
node := selectTopNode(t, s, createConfig(0, 1), nodes)
assert.NoError(t, node.AddContainer(createContainer(fmt.Sprintf("c%d", i), createConfig(0, 1))))
}
// try to add another container 1CPU
_, err := s.RankAndSort(createConfig(0, 1), nodes)
assert.Error(t, err)
// add 100 container 1G
for i := 100; i < 200; i++ {
node := selectTopNode(t, s, createConfig(1, 0), nodes)
assert.NoError(t, node.AddContainer(createContainer(fmt.Sprintf("c%d", i), createConfig(1, 0))))
}
// try to add another container 1G
_, err = s.RankAndSort(createConfig(1, 0), nodes)
assert.Error(t, err)
}
开发者ID:nishanttotla,项目名称:swarm,代码行数:28,代码来源:spread_test.go
示例2: TestSpreadPlaceEqualWeight
func TestSpreadPlaceEqualWeight(t *testing.T) {
s := &SpreadPlacementStrategy{}
nodes := []*node.Node{}
for i := 0; i < 2; i++ {
nodes = append(nodes, createNode(fmt.Sprintf("node-%d", i), 4, 0))
}
// add 1 container 2G on node1
config := createConfig(2, 0)
assert.NoError(t, nodes[0].AddContainer(createContainer("c1", config)))
assert.Equal(t, nodes[0].UsedMemory, int64(2*1024*1024*1024))
// add 2 containers 1G on node2
config = createConfig(1, 0)
assert.NoError(t, nodes[1].AddContainer(createContainer("c2", config)))
assert.NoError(t, nodes[1].AddContainer(createContainer("c3", config)))
assert.Equal(t, nodes[1].UsedMemory, int64(2*1024*1024*1024))
// add another container 1G
config = createConfig(1, 0)
node := selectTopNode(t, s, config, nodes)
assert.NoError(t, node.AddContainer(createContainer("c4", config)))
assert.Equal(t, node.UsedMemory, int64(3*1024*1024*1024))
// check that the last container ended on the node with the lowest number of containers
assert.Equal(t, node.ID, nodes[0].ID)
assert.Equal(t, len(nodes[0].Containers), len(nodes[1].Containers))
}
开发者ID:nishanttotla,项目名称:swarm,代码行数:30,代码来源:spread_test.go
示例3: listNodes
// listNodes returns all validated engines in the cluster, excluding pendingEngines.
func (c *Cluster) listNodes() []*node.Node {
c.RLock()
defer c.RUnlock()
out := make([]*node.Node, 0, len(c.engines))
for _, e := range c.engines {
node := node.NewNode(e)
for _, c := range c.pendingContainers {
if c.Engine.ID == e.ID && node.Container(c.Config.SwarmID()) == nil {
node.AddContainer(c.ToContainer())
}
}
out = append(out, node)
}
return out
}
开发者ID:kingsmiler,项目名称:swarm,代码行数:18,代码来源:cluster.go
示例4: TestSpreadPlaceDifferentNodeSizeCPUs
func TestSpreadPlaceDifferentNodeSizeCPUs(t *testing.T) {
s := &SpreadPlacementStrategy{}
nodes := []*node.Node{
createNode(fmt.Sprintf("node-0"), 64, 21),
createNode(fmt.Sprintf("node-1"), 128, 42),
}
// add 60 containers 1CPU
for i := 0; i < 60; i++ {
config := createConfig(0, 1)
node := selectTopNode(t, s, config, nodes)
assert.NoError(t, node.AddContainer(createContainer(fmt.Sprintf("c%d", i), config)))
}
assert.Equal(t, len(nodes[0].Containers), 20)
assert.Equal(t, len(nodes[1].Containers), 40)
}
开发者ID:nishanttotla,项目名称:swarm,代码行数:18,代码来源:spread_test.go
注:本文中的github.com/docker/swarm/scheduler/node.AddContainer函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论