Class: Roby::BasicObject::DRoby
Direct Known Subclasses
Distributed::Transaction::DRoby, PlanObject::DRoby, Transaction::Proxy::DRoby
Instance Attribute Summary collapse
-
#owners ⇒ Object
readonly
The set of owners for that object.
-
#remote_siblings ⇒ Object
readonly
The set of remote siblings for that object, as known by the peer who called #droby_dump.
Instance Method Summary collapse
-
#initialize(remote_siblings, owners) ⇒ DRoby
constructor
Create a BasicObject::DRoby object with the given information.
-
#owners_to_s ⇒ Object
:nodoc:.
-
#remote_siblings_to_s ⇒ Object
:nodoc:.
-
#sibling_on(peer) ⇒ Object
If we know of a sibling on
peer, return it. -
#to_s ⇒ Object
:nodoc:.
-
#update(peer, proxy) ⇒ Object
Update an existing proxy, using the information stored in this DRoby object.
Constructor Details
#initialize(remote_siblings, owners) ⇒ DRoby
Create a BasicObject::DRoby object with the given information
12 13 14 |
# File 'lib/roby/distributed/proxy.rb', line 12 def initialize(remote_siblings, owners) @remote_siblings, @owners = remote_siblings, owners end |
Instance Attribute Details
#owners ⇒ Object (readonly)
The set of owners for that object.
10 11 12 |
# File 'lib/roby/distributed/proxy.rb', line 10 def owners @owners end |
#remote_siblings ⇒ Object (readonly)
The set of remote siblings for that object, as known by the peer who called #droby_dump. This is used to match object identity among plan managers.
8 9 10 |
# File 'lib/roby/distributed/proxy.rb', line 8 def remote_siblings @remote_siblings end |
Instance Method Details
#owners_to_s ⇒ Object
:nodoc:
19 20 21 |
# File 'lib/roby/distributed/proxy.rb', line 19 def owners_to_s # :nodoc: "[ " << owners.map { |peer| peer.name }.join(", ") << " ]" end |
#remote_siblings_to_s ⇒ Object
:nodoc:
16 17 18 |
# File 'lib/roby/distributed/proxy.rb', line 16 def remote_siblings_to_s # :nodoc: "{ " << remote_siblings.map { |peer, id| id.to_s(peer) }.join(", ") << " }" end |
#sibling_on(peer) ⇒ Object
If we know of a sibling on peer, return it. Otherwise, raises RemotePeerMismatch.
27 28 29 30 31 32 33 34 |
# File 'lib/roby/distributed/proxy.rb', line 27 def sibling_on(peer) remote_siblings.each do |m_peer, remote_id| if m_peer.peer_id == peer.remote_id return remote_id end end raise RemotePeerMismatch, "#{self} has no known sibling on #{peer}" end |
#to_s ⇒ Object
:nodoc:
22 23 24 |
# File 'lib/roby/distributed/proxy.rb', line 22 def to_s # :nodoc: "#<dRoby:BasicObject#{remote_siblings_to_s} owners=#{owners_to_s}>" end |
#update(peer, proxy) ⇒ Object
Update an existing proxy, using the information stored in this DRoby object.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/roby/distributed/proxy.rb', line 38 def update(peer, proxy) proxy.owners.clear owners.each do |m_owner| proxy.owners << peer.local_object(m_owner) end remote_siblings.each do |m_peer_sibling, remote_id| peer_sibling = peer.local_object(m_peer_sibling) if current = proxy.remote_siblings[peer_sibling] if current != remote_id && peer_sibling != Roby::Distributed raise "inconsistency for sibling on #{peer_sibling}: #{proxy} has #{current} while #{self} has #{remote_id}" end else proxy.sibling_of(remote_id, peer_sibling) end end end |