Class: Calvin::Node
- Inherits:
-
Spinoza::Node
- Object
- Spinoza::Model
- Spinoza::Node
- Calvin::Node
- Defined in:
- lib/spinoza/calvin/node.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#meta_log ⇒ Object
readonly
Returns the value of attribute meta_log.
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
-
#sequencer ⇒ Object
readonly
Returns the value of attribute sequencer.
Attributes inherited from Spinoza::Node
#links, #lock_manager, #name, #store
Attributes inherited from Spinoza::Model
Instance Method Summary collapse
- #default_output(transaction, result) ⇒ Object
-
#finished_transaction(transaction, result) ⇒ Object
Override this to put the result somewhere.
-
#initialize(*tables, log: nil, meta_log: nil, sequencer: nil, scheduler: nil, **rest) ⇒ Node
constructor
A new instance of Node.
- #on_transaction_finish(&b) ⇒ Object
- #read_batch(batch_id) ⇒ Object
- #recv(msg: nil) ⇒ Object
Methods inherited from Spinoza::Node
#inspect, #link, #new_name, new_name, #tables, #to_s
Methods inherited from Spinoza::Model
Constructor Details
#initialize(*tables, log: nil, meta_log: nil, sequencer: nil, scheduler: nil, **rest) ⇒ Node
Returns a new instance of Node.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/spinoza/calvin/node.rb', line 9 def initialize *tables, log: nil, meta_log: nil, sequencer: nil, scheduler: nil, **rest super *tables, **rest @log = log @meta_log = @sequencer = sequencer || Calvin::Sequencer.new(node: self) @scheduler = scheduler || Calvin::Scheduler.new(node: self) on_transaction_finish &method(:default_output) end |
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
7 8 9 |
# File 'lib/spinoza/calvin/node.rb', line 7 def log @log end |
#meta_log ⇒ Object (readonly)
Returns the value of attribute meta_log.
7 8 9 |
# File 'lib/spinoza/calvin/node.rb', line 7 def @meta_log end |
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
6 7 8 |
# File 'lib/spinoza/calvin/node.rb', line 6 def scheduler @scheduler end |
#sequencer ⇒ Object (readonly)
Returns the value of attribute sequencer.
6 7 8 |
# File 'lib/spinoza/calvin/node.rb', line 6 def sequencer @sequencer end |
Instance Method Details
#default_output(transaction, result) ⇒ Object
21 22 23 24 |
# File 'lib/spinoza/calvin/node.rb', line 21 def default_output transaction, result r = result.map {|rr| [rr.op.table, rr.val].join(":")}.join(", ") puts "%07.6f [RESULT] #{transaction} => #{r}" % timeline.now end |
#finished_transaction(transaction, result) ⇒ Object
Override this to put the result somewhere.
39 40 41 42 43 |
# File 'lib/spinoza/calvin/node.rb', line 39 def finished_transaction transaction, result if @finished_transaction_handler @finished_transaction_handler[transaction, result] end end |
#on_transaction_finish(&b) ⇒ Object
34 35 36 |
# File 'lib/spinoza/calvin/node.rb', line 34 def on_transaction_finish &b @finished_transaction_handler = b end |
#read_batch(batch_id) ⇒ Object
30 31 32 |
# File 'lib/spinoza/calvin/node.rb', line 30 def read_batch batch_id log.read batch_id, node: self end |
#recv(msg: nil) ⇒ Object
26 27 28 |
# File 'lib/spinoza/calvin/node.rb', line 26 def recv msg: nil scheduler.recv_peer_results **msg end |