int -> int64

This commit is contained in:
Victor Vieux 2014-11-20 01:37:15 +00:00
parent 582bd6cc0e
commit 9bf438ec64
3 changed files with 8 additions and 8 deletions

View File

@ -34,7 +34,7 @@ type Node struct {
ID string
IP string
Addr string
Cpus int
Cpus int64
Memory int64
Labels map[string]string
@ -204,7 +204,7 @@ func (n *Node) refreshLoop() {
func (n *Node) ReservedMemory() int64 {
var r int64 = 0
for _, c := range n.containers {
r += int64(c.Info.Config.Memory)
r += c.Info.Config.Memory
}
return r
}
@ -218,13 +218,13 @@ func (n *Node) AvailableMemory() int64 {
func (n *Node) ReservedCpus() int64 {
var r int64 = 0
for _, c := range n.containers {
r += int64(c.Info.Config.CpuShares)
r += c.Info.Config.CpuShares
}
return r
}
func (n *Node) AvailalbleCpus() int64 {
return int64(n.Cpus) - n.ReservedCpus()
return n.Cpus - n.ReservedCpus()
}
func (n *Node) Create(config *dockerclient.ContainerConfig, name string, pullImage bool) (*Container, error) {

View File

@ -30,10 +30,10 @@ func (p *BinPackingPlacementStrategy) PlaceContainer(config *dockerclient.Contai
)
if config.CpuShares > 0 {
cpuScore = (node.ReservedCpus() + int64(config.CpuShares)) * 100 / int64(node.Cpus)
cpuScore = (node.ReservedCpus() + config.CpuShares) * 100 / node.Cpus
}
if config.Memory > 0 {
memoryScore = (node.ReservedMemory() + int64(config.Memory)) * 100 / node.Memory
memoryScore = (node.ReservedMemory() + config.Memory) * 100 / node.Memory
}
var total = ((cpuScore + memoryScore) / 200) * 100

View File

@ -9,14 +9,14 @@ import (
"github.com/stretchr/testify/assert"
)
func createNode(ID string, memory int64, cpus int) *cluster.Node {
func createNode(ID string, memory int64, cpus int64) *cluster.Node {
node := cluster.NewNode(ID, "")
node.Memory = memory * 1024 * 1024 * 1024
node.Cpus = cpus
return node
}
func createConfig(memory int, cpus int) *dockerclient.ContainerConfig {
func createConfig(memory int64, cpus int64) *dockerclient.ContainerConfig {
return &dockerclient.ContainerConfig{Memory: memory * 1024 * 1024 * 1024, CpuShares: cpus}
}