Class: Worker::Base
- Inherits:
-
Object
- Object
- Worker::Base
- Defined in:
- lib/spark/worker/worker.rb
Constant Summary
Constants included from Spark::Constant
Spark::Constant::ACCUMULATOR_ACK, Spark::Constant::CREATE_WORKER, Spark::Constant::DATA_EOF, Spark::Constant::KILL_WORKER, Spark::Constant::KILL_WORKER_AND_WAIT, Spark::Constant::SUCCESSFULLY_KILLED, Spark::Constant::UNSUCCESSFUL_KILLING, Spark::Constant::WORKER_DONE, Spark::Constant::WORKER_ERROR
Constants included from Spark::Helper::Serialize
Spark::Helper::Serialize::DIRECTIVE_CHARS, Spark::Helper::Serialize::DIRECTIVE_DOUBLES_BIG_ENDIAN, Spark::Helper::Serialize::DIRECTIVE_DOUBLE_BIG_ENDIAN, Spark::Helper::Serialize::DIRECTIVE_INTEGERS_BIG_ENDIAN, Spark::Helper::Serialize::DIRECTIVE_INTEGER_BIG_ENDIAN, Spark::Helper::Serialize::DIRECTIVE_LONGS_BIG_ENDIAN, Spark::Helper::Serialize::DIRECTIVE_LONG_BIG_ENDIAN, Spark::Helper::Serialize::DIRECTIVE_UNSIGNED_CHARS
Instance Attribute Summary collapse
-
#socket ⇒ Object
Returns the value of attribute socket.
Instance Method Summary collapse
-
#initialize(port) ⇒ Base
constructor
A new instance of Base.
- #run ⇒ Object
Methods included from Spark::Helper::System
Methods included from Spark::Helper::Serialize
#pack_double, #pack_doubles, #pack_int, #pack_ints, #pack_long, #pack_longs, #pack_unsigned_chars, #unpack_chars, #unpack_int, #unpack_long
Constructor Details
#initialize(port) ⇒ Base
Returns a new instance of Base.
27 28 29 30 31 32 33 |
# File 'lib/spark/worker/worker.rb', line 27 def initialize(port) # Open socket to Spark @socket = TCPSocket.open('localhost', port) # Send back worker ID socket.write_long(id) end |
Instance Attribute Details
#socket ⇒ Object
Returns the value of attribute socket.
25 26 27 |
# File 'lib/spark/worker/worker.rb', line 25 def socket @socket end |
Instance Method Details
#run ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/spark/worker/worker.rb', line 35 def run begin compute rescue => e send_error(e) else successful_finish end end |