Class: DRbQS::Client
- Inherits:
-
Object
- Object
- DRbQS::Client
- Defined in:
- lib/drbqs/client.rb
Constant Summary collapse
- WAIT_NEW_TASK =
1
- PRIORITY_RESPOND =
10
- PRIORITY_CALCULATE =
0
- OUTPUT_NOT_SEND_RESULT =
'not_send_result'
- DEFAULT_LOG_FILE =
'drbqs_client.log'
Instance Method Summary collapse
- #calculate(opts = {}) ⇒ Object
- #connect ⇒ Object
-
#initialize(access_uri, opts = {}) ⇒ Client
constructor
:continue.
- #set_signal_trap ⇒ Object
Constructor Details
#initialize(access_uri, opts = {}) ⇒ Client
:continue
15 16 17 18 19 20 21 22 |
# File 'lib/drbqs/client.rb', line 15 def initialize(access_uri, opts = {}) @access_uri = access_uri @logger = DRbQS::Utils.create_logger(opts[:log_file] || DEFAULT_LOG_FILE, opts[:log_level]) @connection = nil @task_client = nil @process_continue = opts[:continue] @signal_queue = Queue.new end |
Instance Method Details
#calculate(opts = {}) ⇒ Object
155 156 157 158 159 160 161 162 |
# File 'lib/drbqs/client.rb', line 155 def calculate(opts = {}) set_signal_trap cn = thread_communicate exec = thread_calculate cn.priority = PRIORITY_RESPOND exec.priority = PRIORITY_CALCULATE cn.join end |
#connect ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/drbqs/client.rb', line 41 def connect obj = DRbObject.new_with_uri(@access_uri) @connection = ConnectionClient.new(obj[:message], @logger) node_id = @connection.get_id @task_client = TaskClient.new(node_id, obj[:queue], obj[:result], @logger) @transfer = obj[:transfer] if ary = @connection.get_initialization execute_task(*ary) end end |
#set_signal_trap ⇒ Object
149 150 151 152 153 |
# File 'lib/drbqs/client.rb', line 149 def set_signal_trap Signal.trap(:TERM) do process_exit end end |