LEFT | RIGHT |
1 package state | 1 package state |
2 | 2 |
3 import ( | 3 import ( |
4 "errors" | 4 "errors" |
5 "fmt" | 5 "fmt" |
6 "launchpad.net/goyaml" | 6 "launchpad.net/goyaml" |
7 "launchpad.net/gozk/zookeeper" | 7 "launchpad.net/gozk/zookeeper" |
8 "launchpad.net/juju-core/charm" | 8 "launchpad.net/juju-core/charm" |
9 "launchpad.net/juju-core/state/presence" | 9 "launchpad.net/juju-core/state/presence" |
10 "launchpad.net/juju-core/trivial" | 10 "launchpad.net/juju-core/trivial" |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 // See OpenPorts for details. | 474 // See OpenPorts for details. |
475 func (u *Unit) WatchPorts() *PortsWatcher { | 475 func (u *Unit) WatchPorts() *PortsWatcher { |
476 return newPortsWatcher(u.st, u.zkPortsPath()) | 476 return newPortsWatcher(u.st, u.zkPortsPath()) |
477 } | 477 } |
478 | 478 |
479 // AgentAlive returns whether the respective remote agent is alive. | 479 // AgentAlive returns whether the respective remote agent is alive. |
480 func (u *Unit) AgentAlive() (bool, error) { | 480 func (u *Unit) AgentAlive() (bool, error) { |
481 return presence.Alive(u.st.zk, u.zkAgentPath()) | 481 return presence.Alive(u.st.zk, u.zkAgentPath()) |
482 } | 482 } |
483 | 483 |
484 // AgentName returns the name used to identify the unit's agent. | 484 // PathKey returns a name identifying the unit that can be used as a |
485 func (u *Unit) AgentName() string { | 485 // file name. The returned key will be different from other |
486 » return fmt.Sprintf("unit-%s-%d", u.serviceName, keySeq(u.key)) | 486 // PathKeys returned by any other entities from the same state. |
| 487 func (u *Unit) PathKey() string { |
| 488 » return "unit-" + strings.Replace(u.Name(), "/", "-", -1) |
487 } | 489 } |
488 | 490 |
489 // WaitAgentAlive blocks until the respective agent is alive. | 491 // WaitAgentAlive blocks until the respective agent is alive. |
490 func (u *Unit) WaitAgentAlive(timeout time.Duration) error { | 492 func (u *Unit) WaitAgentAlive(timeout time.Duration) error { |
491 err := presence.WaitAlive(u.st.zk, u.zkAgentPath(), timeout) | 493 err := presence.WaitAlive(u.st.zk, u.zkAgentPath(), timeout) |
492 if err != nil { | 494 if err != nil { |
493 return fmt.Errorf("waiting for agent of unit %q: %v", u, err) | 495 return fmt.Errorf("waiting for agent of unit %q: %v", u, err) |
494 } | 496 } |
495 return nil | 497 return nil |
496 } | 498 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 // valid mode if acceptNone is true. | 563 // valid mode if acceptNone is true. |
562 func validResolvedMode(mode ResolvedMode, acceptNone bool) error { | 564 func validResolvedMode(mode ResolvedMode, acceptNone bool) error { |
563 if acceptNone && mode == ResolvedNone { | 565 if acceptNone && mode == ResolvedNone { |
564 return nil | 566 return nil |
565 } | 567 } |
566 if mode != ResolvedRetryHooks && mode != ResolvedNoHooks { | 568 if mode != ResolvedRetryHooks && mode != ResolvedNoHooks { |
567 return fmt.Errorf("invalid error resolution mode: %d", mode) | 569 return fmt.Errorf("invalid error resolution mode: %d", mode) |
568 } | 570 } |
569 return nil | 571 return nil |
570 } | 572 } |
LEFT | RIGHT |