rename Set to Apply

The name `Set` would be used to do dymanic changes of resource configs
in the future. For now, `Apply` also makes more sense.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2015-02-09 13:46:30 +08:00
parent 025e6be6c5
commit 12a63757db
10 changed files with 15 additions and 15 deletions

View File

@ -31,7 +31,7 @@ type subsystem interface {
// Removes the cgroup represented by 'data'.
Remove(*data) error
// Creates and joins the cgroup represented by data.
Set(*data) error
Apply(*data) error
}
type Manager struct {
@ -91,7 +91,7 @@ func (m *Manager) Apply(pid int) error {
}
}()
for name, sys := range subsystems {
if err := sys.Set(d); err != nil {
if err := sys.Apply(d); err != nil {
return err
}
// TODO: Apply should, ideally, be reentrant or be broken up into a separate
@ -129,7 +129,7 @@ func ApplyDevices(c *configs.Cgroup, pid int) error {
devices := subsystems["devices"]
return devices.Set(d)
return devices.Apply(d)
}
func (m *Manager) GetStats() (*cgroups.Stats, error) {
@ -159,7 +159,7 @@ func (m *Manager) Freeze(state configs.FreezerState) error {
m.Cgroups.Freezer = state
freezer := subsystems["freezer"]
err = freezer.Set(d)
err = freezer.Apply(d)
if err != nil {
m.Cgroups.Freezer = prevState
return err

View File

@ -14,7 +14,7 @@ import (
type BlkioGroup struct {
}
func (s *BlkioGroup) Set(d *data) error {
func (s *BlkioGroup) Apply(d *data) error {
dir, err := d.join("blkio")
if err != nil && !cgroups.IsNotFound(err) {
return err

View File

@ -12,7 +12,7 @@ import (
type CpuGroup struct {
}
func (s *CpuGroup) Set(d *data) error {
func (s *CpuGroup) Apply(d *data) error {
// We always want to join the cpu group, to allow fair cpu scheduling
// on a container basis
dir, err := d.join("cpu")

View File

@ -21,7 +21,7 @@ var clockTicks = uint64(system.GetClockTicks())
type CpuacctGroup struct {
}
func (s *CpuacctGroup) Set(d *data) error {
func (s *CpuacctGroup) Apply(d *data) error {
// we just want to join this group even though we don't set anything
if _, err := d.join("cpuacct"); err != nil && !cgroups.IsNotFound(err) {
return err

View File

@ -13,12 +13,12 @@ import (
type CpusetGroup struct {
}
func (s *CpusetGroup) Set(d *data) error {
func (s *CpusetGroup) Apply(d *data) error {
dir, err := d.path("cpuset")
if err != nil {
return err
}
return s.SetDir(dir, d.c.CpusetCpus, d.c.CpusetMems, d.pid)
return s.ApplyDir(dir, d.c.CpusetCpus, d.c.CpusetMems, d.pid)
}
func (s *CpusetGroup) Remove(d *data) error {
@ -29,7 +29,7 @@ func (s *CpusetGroup) GetStats(path string, stats *cgroups.Stats) error {
return nil
}
func (s *CpusetGroup) SetDir(dir, cpus string, mems string, pid int) error {
func (s *CpusetGroup) ApplyDir(dir, cpus string, mems string, pid int) error {
if err := s.ensureParent(dir); err != nil {
return err
}

View File

@ -5,7 +5,7 @@ import "github.com/docker/libcontainer/cgroups"
type DevicesGroup struct {
}
func (s *DevicesGroup) Set(d *data) error {
func (s *DevicesGroup) Apply(d *data) error {
dir, err := d.join("devices")
if err != nil {
return err

View File

@ -11,7 +11,7 @@ import (
type FreezerGroup struct {
}
func (s *FreezerGroup) Set(d *data) error {
func (s *FreezerGroup) Apply(d *data) error {
switch d.c.Freezer {
case configs.Frozen, configs.Thawed:
dir, err := d.path("freezer")

View File

@ -13,7 +13,7 @@ import (
type MemoryGroup struct {
}
func (s *MemoryGroup) Set(d *data) error {
func (s *MemoryGroup) Apply(d *data) error {
dir, err := d.join("memory")
// only return an error for memory if it was specified
if err != nil && (d.c.Memory != 0 || d.c.MemoryReservation != 0 || d.c.MemorySwap != 0) {

View File

@ -7,7 +7,7 @@ import (
type PerfEventGroup struct {
}
func (s *PerfEventGroup) Set(d *data) error {
func (s *PerfEventGroup) Apply(d *data) error {
// we just want to join this group even though we don't set anything
if _, err := d.join("perf_event"); err != nil && !cgroups.IsNotFound(err) {
return err

View File

@ -398,5 +398,5 @@ func joinCpuset(c *configs.Cgroup, pid int) error {
s := &fs.CpusetGroup{}
return s.SetDir(path, c.CpusetCpus, c.CpusetMems, pid)
return s.ApplyDir(path, c.CpusetCpus, c.CpusetMems, pid)
}