當前位置: 首頁>>代碼示例>>Golang>>正文


Golang cgroups.PathExists函數代碼示例

本文整理匯總了Golang中github.com/docker/libcontainer/cgroups.PathExists函數的典型用法代碼示例。如果您正苦於以下問題:Golang PathExists函數的具體用法?Golang PathExists怎麽用?Golang PathExists使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了PathExists函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Freeze

// Freeze toggles the container's freezer cgroup depending on the state
// provided
func (m *Manager) Freeze(state configs.FreezerState) error {
	d, err := getCgroupData(m.Cgroups, 0)
	if err != nil {
		return err
	}

	dir, err := d.path("freezer")
	if err != nil {
		return err
	}
	if !cgroups.PathExists(dir) {
		return cgroups.NewNotFoundError("freezer")
	}

	prevState := m.Cgroups.Freezer
	m.Cgroups.Freezer = state

	freezer := subsystems["freezer"]
	err = freezer.Set(dir, m.Cgroups)
	if err != nil {
		m.Cgroups.Freezer = prevState
		return err
	}

	return nil
}
開發者ID:jaegerpicker,項目名稱:docker,代碼行數:28,代碼來源:apply_raw.go

示例2: Set

func (m *Manager) Set(container *configs.Config) error {
	for name, path := range m.Paths {
		sys, ok := subsystems[name]
		if !ok || !cgroups.PathExists(path) {
			continue
		}
		if err := sys.Set(path, container.Cgroups); err != nil {
			return err
		}
	}

	return nil
}
開發者ID:CNDonny,項目名稱:scope,代碼行數:13,代碼來源:apply_systemd.go

示例3: GetStats

func (m *Manager) GetStats() (*cgroups.Stats, error) {
	stats := cgroups.NewStats()
	for name, path := range m.Paths {
		sys, ok := subsystems[name]
		if !ok || !cgroups.PathExists(path) {
			continue
		}
		if err := sys.GetStats(path, stats); err != nil {
			return nil, err
		}
	}

	return stats, nil
}
開發者ID:jaegerpicker,項目名稱:docker,代碼行數:14,代碼來源:apply_raw.go

示例4: GetStats

func GetStats(systemPaths map[string]string) (*cgroups.Stats, error) {
	stats := cgroups.NewStats()
	for name, path := range systemPaths {
		sys, ok := subsystems[name]
		if !ok || !cgroups.PathExists(path) {
			continue
		}
		if err := sys.GetStats(path, stats); err != nil {
			return nil, err
		}
	}

	return stats, nil
}
開發者ID:bmanas,項目名稱:amazon-ecs-agent,代碼行數:14,代碼來源:apply_raw.go

示例5: GetPids

func (m *Manager) GetPids() ([]int, error) {
	d, err := getCgroupData(m.Cgroups, 0)
	if err != nil {
		return nil, err
	}

	dir, err := d.path("devices")
	if err != nil {
		return nil, err
	}
	if !cgroups.PathExists(dir) {
		return nil, cgroups.NewNotFoundError("devices")
	}

	return cgroups.ReadProcsFile(dir)
}
開發者ID:jaegerpicker,項目名稱:docker,代碼行數:16,代碼來源:apply_raw.go

示例6: Apply

func (m *Manager) Apply(pid int) error {
	if m.Cgroups == nil {
		return nil
	}

	d, err := getCgroupData(m.Cgroups, pid)
	if err != nil {
		return err
	}

	paths := make(map[string]string)
	defer func() {
		if err != nil {
			cgroups.RemovePaths(paths)
		}
	}()
	for name, sys := range subsystems {
		if err := sys.Apply(d); err != nil {
			return err
		}
		// TODO: Apply should, ideally, be reentrant or be broken up into a separate
		// create and join phase so that the cgroup hierarchy for a container can be
		// created then join consists of writing the process pids to cgroup.procs
		p, err := d.path(name)
		if err != nil {
			return err
		}
		if !cgroups.PathExists(p) {
			continue
		}

		paths[name] = p
	}
	m.Paths = paths

	return nil
}
開發者ID:jorik041,項目名稱:docker,代碼行數:37,代碼來源:apply_raw.go


注:本文中的github.com/docker/libcontainer/cgroups.PathExists函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。