Class: Roby::Distributed::Transaction::DRoby

Inherits:
BasicObject::DRoby show all
Defined in:
lib/roby/distributed/transaction.rb

Overview

Intermediate representation of a Roby::Distributed::Transaction object, suitable for representing that transaction in the dRoby protocol.

Instance Attribute Summary collapse

Attributes inherited from BasicObject::DRoby

#owners, #remote_siblings

Instance Method Summary collapse

Methods inherited from BasicObject::DRoby

#owners_to_s, #remote_siblings_to_s, #sibling_on, #update

Constructor Details

#initialize(remote_siblings, owners, plan, options) ⇒ DRoby

Returns a new instance of DRoby.



326
327
328
329
# File 'lib/roby/distributed/transaction.rb', line 326

def initialize(remote_siblings, owners, plan, options)
    super(remote_siblings, owners)
    @plan, @options = plan, options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



325
326
327
# File 'lib/roby/distributed/transaction.rb', line 325

def options
  @options
end

#planObject (readonly)

Returns the value of attribute plan.



325
326
327
# File 'lib/roby/distributed/transaction.rb', line 325

def plan
  @plan
end

Instance Method Details

#created_sibling(peer, trsc) ⇒ Object

Called when a new sibling has been created locally for a distributed transaction present on peer. trsc is the local representation of this transaction.

In practice, it announces the new transaction by calling the block stored in Distributed.transaction_handler (if there is one).

See PeerServer#created_sibling



357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/roby/distributed/transaction.rb', line 357

def created_sibling(peer, trsc)
    Thread.new do
	Thread.current.priority = 0
	begin
	    Distributed.transaction_handler[trsc] if Distributed.transaction_handler
	rescue 
	    Roby.warn "transaction handler for #{trsc} failed"
	    Roby.warn $!.full_message
	    trsc.invalidate("failed transaction handler")
	end
    end
end

#proxy(peer) ⇒ Object

Returns the local representation of this transaction, or raises InvalidRemoteOperation if none exists.



333
334
335
# File 'lib/roby/distributed/transaction.rb', line 333

def proxy(peer)
    raise InvalidRemoteOperation, "the transaction #{self} does not exist on #{peer.connection_space.name}"
end

#sibling(peer) ⇒ Object

Create a local representation for this transaction.



338
339
340
341
342
343
344
345
346
# File 'lib/roby/distributed/transaction.rb', line 338

def sibling(peer)
    plan = peer.local_object(self.plan)
    trsc = Roby::Distributed::Transaction.new(plan, peer.local_object(options))
    update(peer, trsc)
    trsc.instance_eval do
	@editor  = false
    end
    trsc
end

#to_sObject

:nodoc:



370
371
372
# File 'lib/roby/distributed/transaction.rb', line 370

def to_s # :nodoc:
    "#<dRoby:Trsc#{remote_siblings_to_s} owners=#{owners_to_s} plan=#{plan}>"
end