• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang job.ParseJobState函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/coreos/fleet/job.ParseJobState函数的典型用法代码示例。如果您正苦于以下问题:Golang ParseJobState函数的具体用法?Golang ParseJobState怎么用?Golang ParseJobState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ParseJobState函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: dirToUnit

// dirToUnit takes a Node containing a Job's constituent objects (in child
// nodes) and returns a *job.Unit, or any error encountered
func (r *EtcdRegistry) dirToUnit(dir *etcd.Node, unitHashLookupFunc func(unit.Hash) *unit.UnitFile) (*job.Unit, error) {
	objKey := path.Join(dir.Key, "object")
	var objNode *etcd.Node
	for _, node := range dir.Nodes {
		node := node
		if node.Key == objKey {
			objNode = node
		}
	}
	if objNode == nil {
		return nil, nil
	}
	u, err := r.getUnitFromObjectNode(objNode, unitHashLookupFunc)
	if err != nil {
		return nil, err
	}
	if u == nil {
		return nil, fmt.Errorf("unable to parse Unit in Registry at key %s", objKey)
	}
	if tgtstate := dirToTargetState(dir); tgtstate != "" {
		ts, err := job.ParseJobState(tgtstate)
		if err != nil {
			return nil, fmt.Errorf("failed to parse Unit(%s) target-state: %v", u.Name, err)
		}
		u.TargetState = ts
	}

	return u, nil
}
开发者ID:jmartin127,项目名称:heapster,代码行数:31,代码来源:job.go


示例2: GetJobTargetState

func (r *EtcdRegistry) GetJobTargetState(jobName string) (*job.JobState, error) {
	key := r.jobTargetStatePath(jobName)
	resp, err := r.etcd.Get(key, false, false)
	if err != nil {
		if err.(*goetcd.EtcdError).ErrorCode != etcd.EcodeNodeExist {
			log.Errorf("Unable to determine target-state of Job(%s): %v", jobName, err)
		}
		return nil, err
	}

	return job.ParseJobState(resp.Node.Value), nil
}
开发者ID:johnmontero,项目名称:fleet,代码行数:12,代码来源:job.go


示例3: filterJobTargetStateChanges

func (es *EventStream) filterJobTargetStateChanges(resp *etcd.Result) *event.Event {
	if resp.Action != "set" {
		return nil
	}

	dir, baseName := path.Split(resp.Node.Key)
	if baseName != "target-state" {
		return nil
	}

	dir = strings.TrimSuffix(dir, "/")
	jobName := path.Base(dir)

	ts := job.ParseJobState(resp.Node.Value)
	if ts == nil {
		return nil
	}

	cs := es.registry.determineJobState(jobName)
	if *cs == *ts {
		return nil
	}

	var cType string
	switch *cs {
	case job.JobStateInactive:
		cType = "CommandLoadJob"
	case job.JobStateLoaded:
		if *ts == job.JobStateInactive {
			cType = "CommandUnloadJob"
		} else if *ts == job.JobStateLaunched {
			cType = "CommandStartJob"
		}
	case job.JobStateLaunched:
		if *ts == job.JobStateLoaded {
			cType = "CommandStopJob"
		} else if *ts == job.JobStateInactive {
			cType = "CommandUnloadJob"
		}
	}

	if cType == "" {
		return nil
	}

	agent, err := es.registry.jobTargetMachine(jobName)
	if err != nil {
		log.Errorf("Failed to look up target of Job(%s): %v", jobName, err)
		return nil
	}

	return &event.Event{cType, jobName, agent}
}
开发者ID:Jitendrakry,项目名称:fleet,代码行数:53,代码来源:job.go


示例4: jobTargetState

func (r *EtcdRegistry) jobTargetState(jobName string) (job.JobState, error) {
	req := etcd.Get{
		Key: r.jobTargetStatePath(jobName),
	}
	resp, err := r.etcd.Do(&req)
	if err != nil {
		if isKeyNotFound(err) {
			err = nil
		}
		return job.JobStateInactive, err
	}

	return job.ParseJobState(resp.Node.Value)
}
开发者ID:JuanCarlosM,项目名称:fleet,代码行数:14,代码来源:job.go


示例5: filterJobTargetStateChanges

func (es *EventStream) filterJobTargetStateChanges(resp *goetcd.Response) *event.Event {
	if resp.Action != "set" {
		return nil
	}

	dir, baseName := path.Split(resp.Node.Key)
	if baseName != "target-state" {
		return nil
	}

	dir = strings.TrimSuffix(dir, "/")
	jobName := path.Base(dir)

	ts := job.ParseJobState(resp.Node.Value)
	if ts == nil {
		return nil
	}

	cs := es.registry.determineJobState(jobName)
	if *cs == *ts {
		return nil
	}

	var cType string
	switch *cs {
	case job.JobStateInactive:
		cType = "CommandLoadJob"
	case job.JobStateLoaded:
		if *ts == job.JobStateInactive {
			cType = "CommandUnloadJob"
		} else if *ts == job.JobStateLaunched {
			cType = "CommandStartJob"
		}
	case job.JobStateLaunched:
		if *ts == job.JobStateLoaded {
			cType = "CommandStopJob"
		} else if *ts == job.JobStateInactive {
			cType = "CommandUnloadJob"
		}
	}

	if cType == "" {
		return nil
	}

	agent, _ := es.registry.GetJobTarget(jobName)
	return &event.Event{cType, jobName, agent}
}
开发者ID:johnmontero,项目名称:fleet,代码行数:48,代码来源:job.go


示例6: CreateUnit

func (rc *RegistryClient) CreateUnit(u *schema.Unit) error {
	rUnit := job.Unit{
		Name:        u.Name,
		Unit:        *schema.MapSchemaUnitOptionsToUnitFile(u.Options),
		TargetState: job.JobStateInactive,
	}

	if len(u.DesiredState) > 0 {
		ts, err := job.ParseJobState(u.DesiredState)
		if err != nil {
			return err
		}

		rUnit.TargetState = ts
	}

	return rc.Registry.CreateUnit(&rUnit)
}
开发者ID:MohamedFAhmed,项目名称:heapster,代码行数:18,代码来源:registry.go


示例7: parseJobDir

func (r *EtcdRegistry) parseJobDir(j *job.Job, dir *etcd.Node) (err error) {
	var heartbeat string
	for _, node := range dir.Nodes {
		switch node.Key {
		case r.jobTargetStatePath(j.Name):
			j.TargetState, err = job.ParseJobState(node.Value)
			if err != nil {
				return
			}
		case r.jobTargetAgentPath(j.Name):
			j.TargetMachineID = node.Value
		case r.jobHeartbeatPath(j.Name):
			heartbeat = node.Value
		}
	}

	j.UnitState = r.getUnitState(j.Name)

	js := determineJobState(j, heartbeat)
	j.State = &js

	return
}
开发者ID:BillTheBest,项目名称:fleet,代码行数:23,代码来源:job.go



注:本文中的github.com/coreos/fleet/job.ParseJobState函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang job.Job类代码示例发布时间:2022-05-23
下一篇:
Golang job.NewJob函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap