Parent

BackgrounDRb::MasterWorker

Attributes

debug_logger[RW]

(Not documented)

Public Instance Methods

all_worker_info(t_data) click to toggle source

collect all worker info in an array and send to the user

    # File server/lib/master_worker.rb, line 68
68:     def all_worker_info(t_data)
69:       info_response = []
70:       reactor.live_workers.each do |key,value|
71:         worker_key = (value.worker_key.to_s).gsub(/#{value.worker_name}_?/,"")
72:         info_response << { :worker => value.worker_name,:worker_key => worker_key,:status => :running }
73:       end
74:       send_object(info_response)
75:     end
async_method_invoke(t_data) click to toggle source

Invoke an asynchronous method on a worker

     # File server/lib/master_worker.rb, line 103
103:     def async_method_invoke(t_data)
104:       worker_name = t_data[:worker]
105:       worker_name_key = gen_worker_key(worker_name,t_data[:worker_key])
106:       t_data.delete(:worker)
107:       t_data.delete(:type)
108:       begin
109:         ask_worker(worker_name_key,:data => t_data, :type => :request, :result => false)
110:       rescue Packet::DisconnectError => sock_error
111:         reactor.live_workers.delete(worker_name_key)
112:       rescue
113:         debug_logger.info($!.message)
114:         debug_logger.info($!.backtrace.join("\n"))
115:         return
116:       end
117:     end
connection_completed() click to toggle source

(Not documented)

     # File server/lib/master_worker.rb, line 167
167:     def connection_completed; end
delete_drb_worker(t_data) click to toggle source

Delete the worker. Sends TERM signal to the worker process and removes worker key from list of available workers

    # File server/lib/master_worker.rb, line 79
79:     def delete_drb_worker(t_data)
80:       worker_name = t_data[:worker]
81:       worker_key = t_data[:worker_key]
82:       worker_name_key = gen_worker_key(worker_name,worker_key)
83:       begin
84:         worker_instance = reactor.live_workers[worker_name_key]
85:         raise Packet::InvalidWorker.new("Invalid worker with name #{worker_name} key #{worker_key}") unless worker_instance
86:         Process.kill('TERM',worker_instance.pid)
87:         # Warning: Change is temporary, may break things
88:         reactor.live_workers.delete(worker_name_key)
89:       rescue Packet::DisconnectError => sock_error
90:         reactor.remove_worker(sock_error)
91:       rescue
92:         debug_logger.info($!.to_s)
93:         debug_logger.info($!.backtrace.join("\n"))
94:       end
95:     end
get_result_object(t_data) click to toggle source

Given a cache key, ask the worker for result stored in it. If you are using Memcache for result storage, this method won’t be called at all and bdrb client library will directly fetch the results from memcache and return

     # File server/lib/master_worker.rb, line 123
123:     def get_result_object(t_data)
124:       worker_name = t_data[:worker]
125:       worker_name_key = gen_worker_key(worker_name,t_data[:worker_key])
126:       t_data.delete(:worker)
127:       t_data.delete(:type)
128:       begin
129:         ask_worker(worker_name_key,:data => t_data, :type => :get_result,:result => true)
130:       rescue Packet::DisconnectError => sock_error
131:         reactor.live_workers.delete(worker_name_key)
132:       rescue
133:         debug_logger.info($!.to_s)
134:         debug_logger.info($!.backtrace.join("\n"))
135:         return
136:       end
137:     end
method_invoke(t_data) click to toggle source

Invoke a synchronous/blocking method on a worker.

     # File server/lib/master_worker.rb, line 140
140:     def method_invoke(t_data)
141:       worker_name = t_data[:worker]
142:       worker_name_key = gen_worker_key(worker_name,t_data[:worker_key])
143:       t_data.delete(:worker)
144:       t_data.delete(:type)
145:       begin
146:         ask_worker(worker_name_key,:data => t_data, :type => :request,:result => true)
147:       rescue Packet::DisconnectError => sock_error
148:         reactor.live_workers.delete(worker_name_key)
149:       rescue
150:         debug_logger.info($!.message)
151:         debug_logger.info($!.backtrace.join("\n"))
152:         return
153:       end
154:     end
pass_worker_info(t_data) click to toggle source

Send worker info to the user

    # File server/lib/master_worker.rb, line 59
59:     def pass_worker_info(t_data)
60:       worker_name_key = gen_worker_key(t_data[:worker],t_data[:worker_key])
61:       worker_instance = reactor.live_workers[worker_name_key]
62:       info_response = { :worker => t_data[:worker],:worker_key => t_data[:worker_key]}
63:       worker_instance ? (info_response[:status] = :running) : (info_response[:status] = :stopped)
64:       send_object(info_response)
65:     end
post_init() click to toggle source

called whenever a new connection is made.Initializes binary data parser

     # File server/lib/master_worker.rb, line 164
164:     def post_init
165:       @tokenizer = Packet::BinParser.new
166:     end
receive_data(p_data) click to toggle source

receives requests from rails and based on request type invoke appropriate method

    # File server/lib/master_worker.rb, line 31
31:     def receive_data p_data
32:       @tokenizer.extract(p_data) do |b_data|
33:         begin
34:           t_data = load_data b_data
35:           if t_data
36:             case t_data[:type]
37:               # async method invocation
38:             when :async_invoke: async_method_invoke(t_data)
39:               # get status/result
40:             when :get_result: get_result_object(t_data)
41:               # sync method invocation
42:             when :sync_invoke: method_invoke(t_data)
43:             when :start_worker: start_worker_request(t_data)
44:             when :delete_worker: delete_drb_worker(t_data)
45:             when :worker_info: pass_worker_info(t_data)
46:             when :all_worker_info: all_worker_info(t_data)
47:             else; debug_logger.info("Invalid request")
48:             end
49:           end
50:         rescue Exception => e
51:           debug_logger.info(e)
52:           debug_logger.info(e.backtrace.join("\n"))
53:           send_object(nil)
54:         end
55:       end
56:     end
start_worker_request(p_data) click to toggle source

start a new worker

     # File server/lib/master_worker.rb, line 98
 98:     def start_worker_request(p_data)
 99:       start_worker(p_data)
100:     end
unbind() click to toggle source

(Not documented)

     # File server/lib/master_worker.rb, line 161
161:     def unbind; end
worker_receive(p_data) click to toggle source

Receieve responses from workers and dispatch them back to the client

     # File server/lib/master_worker.rb, line 157
157:     def worker_receive p_data
158:       send_object(p_data)
159:     end

secsequence

--- SEC00028

seccomment

--- ""

attributes

--- 
- name: debug_logger
  rw: RW
  a_desc: ""

method_list

--- 
- methods: 
  - visibility: public
    aref: M000032
    name: all_worker_info
    sourcecode: "    <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 68</span>\n\
      68:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">all_worker_info</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      69:       <span class=\"ruby-identifier\">info_response</span> = []\n\
      70:       <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">live_workers</span>.<span class=\"ruby-identifier\">each</span> <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">key</span>,<span class=\"ruby-identifier\">value</span><span class=\"ruby-operator\">|</span>\n\
      71:         <span class=\"ruby-identifier\">worker_key</span> = (<span class=\"ruby-identifier\">value</span>.<span class=\"ruby-identifier\">worker_key</span>.<span class=\"ruby-identifier\">to_s</span>).<span class=\"ruby-identifier\">gsub</span>(<span class=\"ruby-node\">/#{value.worker_name}_?/</span>,<span class=\"ruby-value str\">&quot;&quot;</span>)\n\
      72:         <span class=\"ruby-identifier\">info_response</span> <span class=\"ruby-operator\">&lt;&lt;</span> { <span class=\"ruby-identifier\">:worker</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">value</span>.<span class=\"ruby-identifier\">worker_name</span>,<span class=\"ruby-identifier\">:worker_key</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">worker_key</span>,<span class=\"ruby-identifier\">:status</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">:running</span> }\n\
      73:       <span class=\"ruby-keyword kw\">end</span>\n\
      74:       <span class=\"ruby-identifier\">send_object</span>(<span class=\"ruby-identifier\">info_response</span>)\n\
      75:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      collect all worker info in an array and send to the user
      </p>
    params: (t_data)
  - visibility: public
    aref: M000035
    name: async_method_invoke
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 103</span>\n\
      103:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">async_method_invoke</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      104:       <span class=\"ruby-identifier\">worker_name</span> = <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker</span>]\n\
      105:       <span class=\"ruby-identifier\">worker_name_key</span> = <span class=\"ruby-identifier\">gen_worker_key</span>(<span class=\"ruby-identifier\">worker_name</span>,<span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker_key</span>])\n\
      106:       <span class=\"ruby-identifier\">t_data</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">:worker</span>)\n\
      107:       <span class=\"ruby-identifier\">t_data</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">:type</span>)\n\
      108:       <span class=\"ruby-keyword kw\">begin</span>\n\
      109:         <span class=\"ruby-identifier\">ask_worker</span>(<span class=\"ruby-identifier\">worker_name_key</span>,<span class=\"ruby-identifier\">:data</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">t_data</span>, <span class=\"ruby-identifier\">:type</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">:request</span>, <span class=\"ruby-identifier\">:result</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-keyword kw\">false</span>)\n\
      110:       <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-constant\">Packet</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">DisconnectError</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">sock_error</span>\n\
      111:         <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">live_workers</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">worker_name_key</span>)\n\
      112:       <span class=\"ruby-keyword kw\">rescue</span>\n\
      113:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">message</span>)\n\
      114:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">&quot;\\n&quot;</span>))\n\
      115:         <span class=\"ruby-keyword kw\">return</span>\n\
      116:       <span class=\"ruby-keyword kw\">end</span>\n\
      117:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Invoke an asynchronous method on a worker
      </p>
    params: (t_data)
  - visibility: public
    aref: M000041
    name: connection_completed
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 167</span>\n\
      167:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">connection_completed</span>; <span class=\"ruby-keyword kw\">end</span>"
    params: ()
  - visibility: public
    aref: M000033
    name: delete_drb_worker
    sourcecode: "    <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 79</span>\n\
      79:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">delete_drb_worker</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      80:       <span class=\"ruby-identifier\">worker_name</span> = <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker</span>]\n\
      81:       <span class=\"ruby-identifier\">worker_key</span> = <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker_key</span>]\n\
      82:       <span class=\"ruby-identifier\">worker_name_key</span> = <span class=\"ruby-identifier\">gen_worker_key</span>(<span class=\"ruby-identifier\">worker_name</span>,<span class=\"ruby-identifier\">worker_key</span>)\n\
      83:       <span class=\"ruby-keyword kw\">begin</span>\n\
      84:         <span class=\"ruby-identifier\">worker_instance</span> = <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">live_workers</span>[<span class=\"ruby-identifier\">worker_name_key</span>]\n\
      85:         <span class=\"ruby-identifier\">raise</span> <span class=\"ruby-constant\">Packet</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">InvalidWorker</span>.<span class=\"ruby-identifier\">new</span>(<span class=\"ruby-node\">&quot;Invalid worker with name #{worker_name} key #{worker_key}&quot;</span>) <span class=\"ruby-keyword kw\">unless</span> <span class=\"ruby-identifier\">worker_instance</span>\n\
      86:         <span class=\"ruby-constant\">Process</span>.<span class=\"ruby-identifier\">kill</span>(<span class=\"ruby-value str\">'TERM'</span>,<span class=\"ruby-identifier\">worker_instance</span>.<span class=\"ruby-identifier\">pid</span>)\n\
      87:         <span class=\"ruby-comment cmt\"># Warning: Change is temporary, may break things</span>\n\
      88:         <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">live_workers</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">worker_name_key</span>)\n\
      89:       <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-constant\">Packet</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">DisconnectError</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">sock_error</span>\n\
      90:         <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">remove_worker</span>(<span class=\"ruby-identifier\">sock_error</span>)\n\
      91:       <span class=\"ruby-keyword kw\">rescue</span>\n\
      92:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
      93:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">&quot;\\n&quot;</span>))\n\
      94:       <span class=\"ruby-keyword kw\">end</span>\n\
      95:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Delete the worker. Sends TERM signal to the worker process and removes
      worker key from list of available workers
      </p>
    params: (t_data)
  - visibility: public
    aref: M000036
    name: get_result_object
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 123</span>\n\
      123:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">get_result_object</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      124:       <span class=\"ruby-identifier\">worker_name</span> = <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker</span>]\n\
      125:       <span class=\"ruby-identifier\">worker_name_key</span> = <span class=\"ruby-identifier\">gen_worker_key</span>(<span class=\"ruby-identifier\">worker_name</span>,<span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker_key</span>])\n\
      126:       <span class=\"ruby-identifier\">t_data</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">:worker</span>)\n\
      127:       <span class=\"ruby-identifier\">t_data</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">:type</span>)\n\
      128:       <span class=\"ruby-keyword kw\">begin</span>\n\
      129:         <span class=\"ruby-identifier\">ask_worker</span>(<span class=\"ruby-identifier\">worker_name_key</span>,<span class=\"ruby-identifier\">:data</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">t_data</span>, <span class=\"ruby-identifier\">:type</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">:get_result</span>,<span class=\"ruby-identifier\">:result</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-keyword kw\">true</span>)\n\
      130:       <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-constant\">Packet</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">DisconnectError</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">sock_error</span>\n\
      131:         <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">live_workers</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">worker_name_key</span>)\n\
      132:       <span class=\"ruby-keyword kw\">rescue</span>\n\
      133:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">to_s</span>)\n\
      134:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">&quot;\\n&quot;</span>))\n\
      135:         <span class=\"ruby-keyword kw\">return</span>\n\
      136:       <span class=\"ruby-keyword kw\">end</span>\n\
      137:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Given a cache key, ask the worker for result stored in it. If you are using
      Memcache for result storage, this method won&#8217;t be called at all and
      bdrb client library will directly fetch the results from memcache and
      return
      </p>
    params: (t_data)
  - visibility: public
    aref: M000037
    name: method_invoke
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 140</span>\n\
      140:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">method_invoke</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      141:       <span class=\"ruby-identifier\">worker_name</span> = <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker</span>]\n\
      142:       <span class=\"ruby-identifier\">worker_name_key</span> = <span class=\"ruby-identifier\">gen_worker_key</span>(<span class=\"ruby-identifier\">worker_name</span>,<span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker_key</span>])\n\
      143:       <span class=\"ruby-identifier\">t_data</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">:worker</span>)\n\
      144:       <span class=\"ruby-identifier\">t_data</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">:type</span>)\n\
      145:       <span class=\"ruby-keyword kw\">begin</span>\n\
      146:         <span class=\"ruby-identifier\">ask_worker</span>(<span class=\"ruby-identifier\">worker_name_key</span>,<span class=\"ruby-identifier\">:data</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">t_data</span>, <span class=\"ruby-identifier\">:type</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">:request</span>,<span class=\"ruby-identifier\">:result</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-keyword kw\">true</span>)\n\
      147:       <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-constant\">Packet</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">DisconnectError</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">sock_error</span>\n\
      148:         <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">live_workers</span>.<span class=\"ruby-identifier\">delete</span>(<span class=\"ruby-identifier\">worker_name_key</span>)\n\
      149:       <span class=\"ruby-keyword kw\">rescue</span>\n\
      150:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">message</span>)\n\
      151:         <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">$!</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">&quot;\\n&quot;</span>))\n\
      152:         <span class=\"ruby-keyword kw\">return</span>\n\
      153:       <span class=\"ruby-keyword kw\">end</span>\n\
      154:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Invoke a synchronous/blocking method on a worker.
      </p>
    params: (t_data)
  - visibility: public
    aref: M000031
    name: pass_worker_info
    sourcecode: "    <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 59</span>\n\
      59:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">pass_worker_info</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      60:       <span class=\"ruby-identifier\">worker_name_key</span> = <span class=\"ruby-identifier\">gen_worker_key</span>(<span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker</span>],<span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker_key</span>])\n\
      61:       <span class=\"ruby-identifier\">worker_instance</span> = <span class=\"ruby-identifier\">reactor</span>.<span class=\"ruby-identifier\">live_workers</span>[<span class=\"ruby-identifier\">worker_name_key</span>]\n\
      62:       <span class=\"ruby-identifier\">info_response</span> = { <span class=\"ruby-identifier\">:worker</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker</span>],<span class=\"ruby-identifier\">:worker_key</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:worker_key</span>]}\n\
      63:       <span class=\"ruby-identifier\">worker_instance</span> <span class=\"ruby-value\">? </span>(<span class=\"ruby-identifier\">info_response</span>[<span class=\"ruby-identifier\">:status</span>] = <span class=\"ruby-identifier\">:running</span>) <span class=\"ruby-operator\">:</span> (<span class=\"ruby-identifier\">info_response</span>[<span class=\"ruby-identifier\">:status</span>] = <span class=\"ruby-identifier\">:stopped</span>)\n\
      64:       <span class=\"ruby-identifier\">send_object</span>(<span class=\"ruby-identifier\">info_response</span>)\n\
      65:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Send worker info to the user
      </p>
    params: (t_data)
  - visibility: public
    aref: M000040
    name: post_init
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 164</span>\n\
      164:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">post_init</span>\n\
      165:       <span class=\"ruby-ivar\">@tokenizer</span> = <span class=\"ruby-constant\">Packet</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">BinParser</span>.<span class=\"ruby-identifier\">new</span>\n\
      166:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      called whenever a new connection is made.Initializes binary data parser
      </p>
    params: ()
  - visibility: public
    aref: M000030
    name: receive_data
    sourcecode: "    <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 31</span>\n\
      31:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">receive_data</span> <span class=\"ruby-identifier\">p_data</span>\n\
      32:       <span class=\"ruby-ivar\">@tokenizer</span>.<span class=\"ruby-identifier\">extract</span>(<span class=\"ruby-identifier\">p_data</span>) <span class=\"ruby-keyword kw\">do</span> <span class=\"ruby-operator\">|</span><span class=\"ruby-identifier\">b_data</span><span class=\"ruby-operator\">|</span>\n\
      33:         <span class=\"ruby-keyword kw\">begin</span>\n\
      34:           <span class=\"ruby-identifier\">t_data</span> = <span class=\"ruby-identifier\">load_data</span> <span class=\"ruby-identifier\">b_data</span>\n\
      35:           <span class=\"ruby-keyword kw\">if</span> <span class=\"ruby-identifier\">t_data</span>\n\
      36:             <span class=\"ruby-keyword kw\">case</span> <span class=\"ruby-identifier\">t_data</span>[<span class=\"ruby-identifier\">:type</span>]\n\
      37:               <span class=\"ruby-comment cmt\"># async method invocation</span>\n\
      38:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:async_invoke</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">async_method_invoke</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      39:               <span class=\"ruby-comment cmt\"># get status/result</span>\n\
      40:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:get_result</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">get_result_object</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      41:               <span class=\"ruby-comment cmt\"># sync method invocation</span>\n\
      42:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:sync_invoke</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">method_invoke</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      43:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:start_worker</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">start_worker_request</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      44:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:delete_worker</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">delete_drb_worker</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      45:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:worker_info</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">pass_worker_info</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      46:             <span class=\"ruby-keyword kw\">when</span> <span class=\"ruby-identifier\">:all_worker_info</span><span class=\"ruby-operator\">:</span> <span class=\"ruby-identifier\">all_worker_info</span>(<span class=\"ruby-identifier\">t_data</span>)\n\
      47:             <span class=\"ruby-keyword kw\">else</span>; <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-value str\">&quot;Invalid request&quot;</span>)\n\
      48:             <span class=\"ruby-keyword kw\">end</span>\n\
      49:           <span class=\"ruby-keyword kw\">end</span>\n\
      50:         <span class=\"ruby-keyword kw\">rescue</span> <span class=\"ruby-constant\">Exception</span> =<span class=\"ruby-operator\">&gt;</span> <span class=\"ruby-identifier\">e</span>\n\
      51:           <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">e</span>)\n\
      52:           <span class=\"ruby-identifier\">debug_logger</span>.<span class=\"ruby-identifier\">info</span>(<span class=\"ruby-identifier\">e</span>.<span class=\"ruby-identifier\">backtrace</span>.<span class=\"ruby-identifier\">join</span>(<span class=\"ruby-value str\">&quot;\\n&quot;</span>))\n\
      53:           <span class=\"ruby-identifier\">send_object</span>(<span class=\"ruby-keyword kw\">nil</span>)\n\
      54:         <span class=\"ruby-keyword kw\">end</span>\n\
      55:       <span class=\"ruby-keyword kw\">end</span>\n\
      56:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      receives requests from rails and based on request type invoke appropriate
      method
      </p>
    params: (p_data)
  - visibility: public
    aref: M000034
    name: start_worker_request
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 98</span>\n 98:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">start_worker_request</span>(<span class=\"ruby-identifier\">p_data</span>)\n 99:       <span class=\"ruby-identifier\">start_worker</span>(<span class=\"ruby-identifier\">p_data</span>)\n\
      100:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      start a new worker
      </p>
    params: (p_data)
  - visibility: public
    aref: M000039
    name: unbind
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 161</span>\n\
      161:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">unbind</span>; <span class=\"ruby-keyword kw\">end</span>"
    params: ()
  - visibility: public
    aref: M000038
    name: worker_receive
    sourcecode: "     <span class=\"ruby-comment cmt\"># File server/lib/master_worker.rb, line 157</span>\n\
      157:     <span class=\"ruby-keyword kw\">def</span> <span class=\"ruby-identifier\">worker_receive</span> <span class=\"ruby-identifier\">p_data</span>\n\
      158:       <span class=\"ruby-identifier\">send_object</span>(<span class=\"ruby-identifier\">p_data</span>)\n\
      159:     <span class=\"ruby-keyword kw\">end</span>"
    m_desc: |-
      <p>
      Receieve responses from workers and dispatch them back to the client
      </p>
    params: (p_data)
  category: Instance
  type: Public

sectitle

--- 

[Validate]

Generated with the Darkfish Rdoc Generator.