本文整理汇总了Golang中github.com/coreos/fleet/job.Job.TargetMachineID方法的典型用法代码示例。如果您正苦于以下问题:Golang Job.TargetMachineID方法的具体用法?Golang Job.TargetMachineID怎么用?Golang Job.TargetMachineID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/fleet/job.Job
的用法示例。
在下文中一共展示了Job.TargetMachineID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newClusterState
func newClusterState(units []job.Unit, sUnits []job.ScheduledUnit, machines []machine.MachineState) *clusterState {
sUnitMap := make(map[string]*job.ScheduledUnit)
for _, sUnit := range sUnits {
sUnit := sUnit
sUnitMap[sUnit.Name] = &sUnit
}
jMap := make(map[string]*job.Job)
guMap := make(map[string]*job.Unit)
for _, u := range units {
if u.IsGlobal() {
u := u
guMap[u.Name] = &u
} else {
j := job.Job{
Name: u.Name,
Unit: u.Unit,
TargetState: u.TargetState,
}
if sUnit, ok := sUnitMap[u.Name]; ok {
j.TargetMachineID = sUnit.TargetMachineID
j.State = sUnit.State
}
jMap[j.Name] = &j
}
}
mMap := make(map[string]*machine.MachineState, len(machines))
for _, ms := range machines {
ms := ms
mMap[ms.ID] = &ms
}
return &clusterState{
jobs: jMap,
gUnits: guMap,
machines: mMap,
}
}
示例2: 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
}