Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1566)

Delta Between Two Patch Sets: state/machine.go

Issue 6257072: state: add Machine.String() (Closed)
Left Patch Set: state: add Machine.String() Created 11 years, 10 months ago
Right Patch Set: state: add Machine.String() Created 11 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // launchpad.net/juju/state 1 // launchpad.net/juju/state
2 // 2 //
3 // Copyright (c) 2011-2012 Canonical Ltd. 3 // Copyright (c) 2011-2012 Canonical Ltd.
4 4
5 package state 5 package state
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "launchpad.net/juju/go/state/presence" 9 "launchpad.net/juju/go/state/presence"
10 "path" 10 "path"
(...skipping 17 matching lines...) Expand all
28 28
29 // AgentAlive returns whether the respective remote agent is alive. 29 // AgentAlive returns whether the respective remote agent is alive.
30 func (m *Machine) AgentAlive() (bool, error) { 30 func (m *Machine) AgentAlive() (bool, error) {
31 return presence.Alive(m.st.zk, m.zkAgentPath()) 31 return presence.Alive(m.st.zk, m.zkAgentPath())
32 } 32 }
33 33
34 // WaitAgentAlive blocks until the respective agent is alive. 34 // WaitAgentAlive blocks until the respective agent is alive.
35 func (m *Machine) WaitAgentAlive(timeout time.Duration) error { 35 func (m *Machine) WaitAgentAlive(timeout time.Duration) error {
36 err := presence.WaitAlive(m.st.zk, m.zkAgentPath(), timeout) 36 err := presence.WaitAlive(m.st.zk, m.zkAgentPath(), timeout)
37 if err != nil { 37 if err != nil {
38 » » return fmt.Errorf("state: waiting for agent of %s: %v", m, err) 38 » » return fmt.Errorf("state: waiting for agent of machine %s: %v", m, err)
niemeyer 2012/06/05 18:45:15 s/state:// s/of /of machine/
dfc 2012/06/05 22:55:55 Done.
39 } 39 }
40 return nil 40 return nil
41 } 41 }
42 42
43 // SetAgentAlive signals that the agent for machine m is alive 43 // SetAgentAlive signals that the agent for machine m is alive
44 // by starting a pinger on its presence node. It returns the 44 // by starting a pinger on its presence node. It returns the
45 // started pinger. 45 // started pinger.
46 func (m *Machine) SetAgentAlive() (*presence.Pinger, error) { 46 func (m *Machine) SetAgentAlive() (*presence.Pinger, error) {
47 return presence.StartPinger(m.st.zk, m.zkAgentPath(), agentPingerPeriod) 47 return presence.StartPinger(m.st.zk, m.zkAgentPath(), agentPingerPeriod)
48 } 48 }
(...skipping 21 matching lines...) Expand all
70 if err != nil { 70 if err != nil {
71 return err 71 return err
72 } 72 }
73 config.Set(providerMachineId, id) 73 config.Set(providerMachineId, id)
74 _, err = config.Write() 74 _, err = config.Write()
75 return err 75 return err
76 } 76 }
77 77
78 // String returns a unique description of this machine 78 // String returns a unique description of this machine
79 func (m *Machine) String() string { 79 func (m *Machine) String() string {
80 » return fmt.Sprintf("machine %d", m.Id()) 80 » return strconv.Itoa(m.Id())
niemeyer 2012/06/05 18:45:15 I think this should be something like: return
dfc 2012/06/05 22:55:55 Done. I fixed the test to not require this form, n
81 } 81 }
82 82
83 // zkKey returns the ZooKeeper key of the machine. 83 // zkKey returns the ZooKeeper key of the machine.
84 func (m *Machine) zkKey() string { 84 func (m *Machine) zkKey() string {
85 return m.key 85 return m.key
86 } 86 }
87 87
88 // zkPath returns the ZooKeeper base path for the machine. 88 // zkPath returns the ZooKeeper base path for the machine.
89 func (m *Machine) zkPath() string { 89 func (m *Machine) zkPath() string {
90 return path.Join(zkMachinesPath, m.zkKey()) 90 return path.Join(zkMachinesPath, m.zkKey())
(...skipping 24 matching lines...) Expand all
115 // machineKey returns the machine key corresponding to machineId. 115 // machineKey returns the machine key corresponding to machineId.
116 func machineKey(machineId int) string { 116 func machineKey(machineId int) string {
117 return fmt.Sprintf("machine-%010d", machineId) 117 return fmt.Sprintf("machine-%010d", machineId)
118 } 118 }
119 119
120 // MachinesChange contains information about 120 // MachinesChange contains information about
121 // machines that have been added or deleted. 121 // machines that have been added or deleted.
122 type MachinesChange struct { 122 type MachinesChange struct {
123 Added, Deleted []*Machine 123 Added, Deleted []*Machine
124 } 124 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b