Update version according to OSCI-883
[packages/precise/mcollective.git] / doc / MCollective / Runner.html
1 <?xml version="1.0" encoding="utf-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 <head>
6         <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
7
8         <title>Class: MCollective::Runner</title>
9
10         <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
11
12         <script src="../js/jquery.js" type="text/javascript"
13                 charset="utf-8"></script>
14         <script src="../js/thickbox-compressed.js" type="text/javascript"
15                 charset="utf-8"></script>
16         <script src="../js/quicksearch.js" type="text/javascript"
17                 charset="utf-8"></script>
18         <script src="../js/darkfish.js" type="text/javascript"
19                 charset="utf-8"></script>
20
21 </head>
22 <body class="class">
23
24         <div id="metadata">
25                 <div id="file-metadata">
26                         <div id="file-list-section" class="section">
27                                 <h3 class="section-header">In Files</h3>
28                                 <div class="section-body">
29                                         <ul>
30                                         
31                                                 <li><a href="../lib/mcollective/runner_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
32                                                         class="thickbox" title="lib/mcollective/runner.rb">lib/mcollective/runner.rb</a></li>
33                                         
34                                         </ul>
35                                 </div>
36                         </div>
37
38                         
39                 </div>
40
41                 <div id="class-metadata">
42
43                         <!-- Parent Class -->
44                         
45                         <div id="parent-class-section" class="section">
46                                 <h3 class="section-header">Parent</h3>
47                                 
48                                 <p class="link"><a href="../Object.html">Object</a></p>
49                                 
50                         </div>
51                         
52
53                         <!-- Namespace Contents -->
54                         
55
56                         <!-- Method Quickref -->
57                         
58                         <div id="method-list-section" class="section">
59                                 <h3 class="section-header">Methods</h3>
60                                 <ul class="link-list">
61                                         
62                                         <li><a href="#M000069">::new</a></li>
63                                         
64                                         <li><a href="#M000071">#agentmsg</a></li>
65                                         
66                                         <li><a href="#M000072">#controlmsg</a></li>
67                                         
68                                         <li><a href="#M000077">#receive</a></li>
69                                         
70                                         <li><a href="#M000078">#reply</a></li>
71                                         
72                                         <li><a href="#M000070">#run</a></li>
73                                         
74                                 </ul>
75                         </div>
76                         
77
78                         <!-- Included Modules -->
79                         
80                         <div id="includes-section" class="section">
81                                 <h3 class="section-header">Included Modules</h3>
82                                 <ul class="link-list">
83                                 
84                                 
85                                         <li><a class="include" href="Validator.html">MCollective::Validator</a></li>
86                                 
87                                 
88                                 </ul>
89                         </div>
90                         
91                 </div>
92
93                 <div id="project-metadata">
94                         
95                         
96                         <div id="fileindex-section" class="section project-section">
97                                 <h3 class="section-header">Files</h3>
98                                 <ul>
99                                 
100                                         <li class="file"><a href="../COPYING.html">COPYING</a></li>
101                                 
102                                         <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
103                                 
104                                         <li class="file"><a href="../README.html">README</a></li>
105                                 
106                                         <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
107                                 
108                                         <li class="file"><a href="../etc/client_cfg_dist.html">client.cfg.dist</a></li>
109                                 
110                                         <li class="file"><a href="../etc/data-help_erb.html">data-help.erb</a></li>
111                                 
112                                         <li class="file"><a href="../etc/discovery-help_erb.html">discovery-help.erb</a></li>
113                                 
114                                         <li class="file"><a href="../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
115                                 
116                                         <li class="file"><a href="../etc/metadata-help_erb.html">metadata-help.erb</a></li>
117                                 
118                                         <li class="file"><a href="../etc/msg-help_erb.html">msg-help.erb</a></li>
119                                 
120                                         <li class="file"><a href="../etc/rpc-help_erb.html">rpc-help.erb</a></li>
121                                 
122                                         <li class="file"><a href="../etc/server_cfg_dist.html">server.cfg.dist</a></li>
123                                 
124                                         <li class="file"><a href="../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
125                                 
126                                         <li class="file"><a href="../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
127                                 
128                                         <li class="file"><a href="../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
129                                 
130                                         <li class="file"><a href="../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
131                                 
132                                         <li class="file"><a href="../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
133                                 
134                                         <li class="file"><a href="../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
135                                 
136                                         <li class="file"><a href="../lib/mcollective/locales/en_yml.html">en.yml</a></li>
137                                 
138                                         <li class="file"><a href="../mcollective_init.html">mcollective.init</a></li>
139                                 
140                                 </ul>
141                         </div>
142                         
143
144                         <div id="classindex-section" class="section project-section">
145                                 <h3 class="section-header">Class Index
146                                         <span class="search-toggle"><img src="../images/find.png"
147                                                 height="16" width="16" alt="[+]"
148                                                 title="show/hide quicksearch" /></span></h3>
149                                 <form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
150                                 <fieldset>
151                                         <legend>Quicksearch</legend>
152                                         <input type="text" name="quicksearch" value=""
153                                                 class="quicksearch-field" />
154                                 </fieldset>
155                                 </form>
156
157                                 <ul class="link-list">
158                                 
159                                         <li><a href="../MCollective.html">MCollective</a></li>
160                                 
161                                         <li><a href="../MCollective/Agent.html">MCollective::Agent</a></li>
162                                 
163                                         <li><a href="../MCollective/Agents.html">MCollective::Agents</a></li>
164                                 
165                                         <li><a href="../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
166                                 
167                                         <li><a href="../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
168                                 
169                                         <li><a href="../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
170                                 
171                                         <li><a href="../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
172                                 
173                                         <li><a href="../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
174                                 
175                                         <li><a href="../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
176                                 
177                                         <li><a href="../MCollective/Application.html">MCollective::Application</a></li>
178                                 
179                                         <li><a href="../MCollective/Applications.html">MCollective::Applications</a></li>
180                                 
181                                         <li><a href="../MCollective/Cache.html">MCollective::Cache</a></li>
182                                 
183                                         <li><a href="../MCollective/Client.html">MCollective::Client</a></li>
184                                 
185                                         <li><a href="../MCollective/CodedError.html">MCollective::CodedError</a></li>
186                                 
187                                         <li><a href="../MCollective/Config.html">MCollective::Config</a></li>
188                                 
189                                         <li><a href="../MCollective/Connector.html">MCollective::Connector</a></li>
190                                 
191                                         <li><a href="../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
192                                 
193                                         <li><a href="../MCollective/DDL.html">MCollective::DDL</a></li>
194                                 
195                                         <li><a href="../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
196                                 
197                                         <li><a href="../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
198                                 
199                                         <li><a href="../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
200                                 
201                                         <li><a href="../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
202                                 
203                                         <li><a href="../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
204                                 
205                                         <li><a href="../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
206                                 
207                                         <li><a href="../MCollective/Data.html">MCollective::Data</a></li>
208                                 
209                                         <li><a href="../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
210                                 
211                                         <li><a href="../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
212                                 
213                                         <li><a href="../MCollective/Discovery.html">MCollective::Discovery</a></li>
214                                 
215                                         <li><a href="../MCollective/Facts.html">MCollective::Facts</a></li>
216                                 
217                                         <li><a href="../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
218                                 
219                                         <li><a href="../MCollective/Generators.html">MCollective::Generators</a></li>
220                                 
221                                         <li><a href="../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
222                                 
223                                         <li><a href="../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
224                                 
225                                         <li><a href="../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
226                                 
227                                         <li><a href="../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
228                                 
229                                         <li><a href="../MCollective/Log.html">MCollective::Log</a></li>
230                                 
231                                         <li><a href="../MCollective/Logger.html">MCollective::Logger</a></li>
232                                 
233                                         <li><a href="../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
234                                 
235                                         <li><a href="../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
236                                 
237                                         <li><a href="../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
238                                 
239                                         <li><a href="../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
240                                 
241                                         <li><a href="../MCollective/Matcher.html">MCollective::Matcher</a></li>
242                                 
243                                         <li><a href="../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
244                                 
245                                         <li><a href="../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
246                                 
247                                         <li><a href="../MCollective/Message.html">MCollective::Message</a></li>
248                                 
249                                         <li><a href="../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
250                                 
251                                         <li><a href="../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
252                                 
253                                         <li><a href="../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
254                                 
255                                         <li><a href="../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
256                                 
257                                         <li><a href="../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
258                                 
259                                         <li><a href="../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
260                                 
261                                         <li><a href="../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
262                                 
263                                         <li><a href="../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
264                                 
265                                         <li><a href="../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
266                                 
267                                         <li><a href="../MCollective/RPC.html">MCollective::RPC</a></li>
268                                 
269                                         <li><a href="../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
270                                 
271                                         <li><a href="../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
272                                 
273                                         <li><a href="../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
274                                 
275                                         <li><a href="../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
276                                 
277                                         <li><a href="../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
278                                 
279                                         <li><a href="../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
280                                 
281                                         <li><a href="../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
282                                 
283                                         <li><a href="../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
284                                 
285                                         <li><a href="../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
286                                 
287                                         <li><a href="../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
288                                 
289                                         <li><a href="../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
290                                 
291                                         <li><a href="../MCollective/RPCError.html">MCollective::RPCError</a></li>
292                                 
293                                         <li><a href="../MCollective/Registration.html">MCollective::Registration</a></li>
294                                 
295                                         <li><a href="../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
296                                 
297                                         <li><a href="../MCollective/Runner.html">MCollective::Runner</a></li>
298                                 
299                                         <li><a href="../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
300                                 
301                                         <li><a href="../MCollective/SSL.html">MCollective::SSL</a></li>
302                                 
303                                         <li><a href="../MCollective/Security.html">MCollective::Security</a></li>
304                                 
305                                         <li><a href="../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
306                                 
307                                         <li><a href="../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
308                                 
309                                         <li><a href="../MCollective/Shell.html">MCollective::Shell</a></li>
310                                 
311                                         <li><a href="../MCollective/Translatable.html">MCollective::Translatable</a></li>
312                                 
313                                         <li><a href="../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
314                                 
315                                         <li><a href="../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
316                                 
317                                         <li><a href="../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
318                                 
319                                         <li><a href="../MCollective/Util.html">MCollective::Util</a></li>
320                                 
321                                         <li><a href="../MCollective/Validator.html">MCollective::Validator</a></li>
322                                 
323                                         <li><a href="../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
324                                 
325                                         <li><a href="../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
326                                 
327                                         <li><a href="../Array.html">Array</a></li>
328                                 
329                                         <li><a href="../Dir.html">Dir</a></li>
330                                 
331                                         <li><a href="../Object.html">Object</a></li>
332                                 
333                                         <li><a href="../String.html">String</a></li>
334                                 
335                                         <li><a href="../Symbol.html">Symbol</a></li>
336                                 
337                                 </ul>
338                                 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
339                         </div>
340
341                         
342                 </div>
343         </div>
344
345         <div id="documentation">
346                 <h1 class="class">MCollective::Runner</h1>
347
348                 <div id="description">
349                         <p>
350 The main runner for the daemon, supports running in the foreground and the
351 background, keeps detailed stats and provides hooks to access all this
352 information
353 </p>
354
355                 </div>
356
357                 <!-- Constants -->
358                 
359
360                 <!-- Attributes -->
361                 
362
363                 <!-- Methods -->
364                 
365                 <div id="public-class-method-details" class="method-section section">
366                         <h3 class="section-header">Public Class Methods</h3>
367
368                 
369                         <div id="new-method" class="method-detail ">
370                                 <a name="M000069"></a>
371
372                                 <div class="method-heading">
373                                 
374                                         <span class="method-name">new</span><span
375                                                 class="method-args">(configfile)</span>
376                                         <span class="method-click-advice">click to toggle source</span>
377                                 
378                                 </div>
379
380                                 <div class="method-description">
381                                         
382                                         <p class="missing-docs">(Not documented)</p>
383                                         
384
385                                         
386                                         <div class="method-source-code"
387                                                 id="new-source">
388 <pre>
389     <span class="ruby-comment cmt"># File lib/mcollective/runner.rb, line 8</span>
390  8:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">configfile</span>)
391  9:       <span class="ruby-ivar">@config</span> = <span class="ruby-constant">Config</span>.<span class="ruby-identifier">instance</span>
392 10:       <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">loadconfig</span>(<span class="ruby-identifier">configfile</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">configured</span>
393 11:       <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">mode</span> = <span class="ruby-identifier">:server</span>
394 12: 
395 13:       <span class="ruby-ivar">@stats</span> = <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">&quot;global_stats&quot;</span>]
396 14: 
397 15:       <span class="ruby-ivar">@security</span> = <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">&quot;security_plugin&quot;</span>]
398 16:       <span class="ruby-ivar">@security</span>.<span class="ruby-identifier">initiated_by</span> = <span class="ruby-identifier">:node</span>
399 17: 
400 18:       <span class="ruby-ivar">@connection</span> = <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">&quot;connector_plugin&quot;</span>]
401 19:       <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">connect</span>
402 20: 
403 21:       <span class="ruby-ivar">@agents</span> = <span class="ruby-constant">Agents</span>.<span class="ruby-identifier">new</span>
404 22: 
405 23:       <span class="ruby-keyword kw">unless</span> <span class="ruby-constant">Util</span>.<span class="ruby-identifier">windows?</span>
406 24:         <span class="ruby-constant">Signal</span>.<span class="ruby-identifier">trap</span>(<span class="ruby-value str">&quot;USR1&quot;</span>) <span class="ruby-keyword kw">do</span>
407 25:           <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC2</span>, <span class="ruby-value str">&quot;Reloading all agents after receiving USR1 signal&quot;</span>, <span class="ruby-identifier">:info</span>)
408 26:           <span class="ruby-ivar">@agents</span>.<span class="ruby-identifier">loadagents</span>
409 27:         <span class="ruby-keyword kw">end</span>
410 28: 
411 29:         <span class="ruby-constant">Signal</span>.<span class="ruby-identifier">trap</span>(<span class="ruby-value str">&quot;USR2&quot;</span>) <span class="ruby-keyword kw">do</span>
412 30:           <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC3</span>, <span class="ruby-value str">&quot;Cycling logging level due to USR2 signal&quot;</span>, <span class="ruby-identifier">:info</span>)
413 31: 
414 32:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">cycle_level</span>
415 33:         <span class="ruby-keyword kw">end</span>
416 34:       <span class="ruby-keyword kw">else</span>
417 35:         <span class="ruby-constant">Util</span>.<span class="ruby-identifier">setup_windows_sleeper</span>
418 36:       <span class="ruby-keyword kw">end</span>
419 37:     <span class="ruby-keyword kw">end</span></pre>
420                                         </div>
421                                         
422                                 </div>
423
424                                 
425                         </div>
426
427                 
428                 </div>
429         
430                 <div id="public-instance-method-details" class="method-section section">
431                         <h3 class="section-header">Public Instance Methods</h3>
432
433                 
434                         <div id="run-method" class="method-detail ">
435                                 <a name="M000070"></a>
436
437                                 <div class="method-heading">
438                                 
439                                         <span class="method-name">run</span><span
440                                                 class="method-args">()</span>
441                                         <span class="method-click-advice">click to toggle source</span>
442                                 
443                                 </div>
444
445                                 <div class="method-description">
446                                         
447                                         <p>
448 Starts the main loop, before calling this you should initialize the <a
449 href="Config.html">MCollective::Config</a> singleton.
450 </p>
451                                         
452
453                                         
454                                         <div class="method-source-code"
455                                                 id="run-source">
456 <pre>
457     <span class="ruby-comment cmt"># File lib/mcollective/runner.rb, line 40</span>
458 40:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>
459 41:       <span class="ruby-constant">Data</span>.<span class="ruby-identifier">load_data_sources</span>
460 42: 
461 43:       <span class="ruby-constant">Util</span>.<span class="ruby-identifier">subscribe</span>(<span class="ruby-constant">Util</span>.<span class="ruby-identifier">make_subscriptions</span>(<span class="ruby-value str">&quot;mcollective&quot;</span>, <span class="ruby-identifier">:broadcast</span>))
462 44:       <span class="ruby-constant">Util</span>.<span class="ruby-identifier">subscribe</span>(<span class="ruby-constant">Util</span>.<span class="ruby-identifier">make_subscriptions</span>(<span class="ruby-value str">&quot;mcollective&quot;</span>, <span class="ruby-identifier">:directed</span>)) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">direct_addressing</span>
463 45: 
464 46:       <span class="ruby-comment cmt"># Start the registration plugin if interval isn't 0</span>
465 47:       <span class="ruby-keyword kw">begin</span>
466 48:         <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">&quot;registration_plugin&quot;</span>].<span class="ruby-identifier">run</span>(<span class="ruby-ivar">@connection</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@config</span>.<span class="ruby-identifier">registerinterval</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
467 49:       <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>
468 50:         <span class="ruby-identifier">logexception</span>(<span class="ruby-identifier">:PLMC4</span>, <span class="ruby-value str">&quot;Failed to start registration plugin: %{error}&quot;</span>, <span class="ruby-identifier">:error</span>, <span class="ruby-identifier">e</span>)
469 51:       <span class="ruby-keyword kw">end</span>
470 52: 
471 53:       <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
472 54:         <span class="ruby-keyword kw">begin</span>
473 55:           <span class="ruby-identifier">request</span> = <span class="ruby-identifier">receive</span>
474 56: 
475 57:           <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">agent</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;mcollective&quot;</span>
476 58:             <span class="ruby-identifier">agentmsg</span>(<span class="ruby-identifier">request</span>)
477 59:           <span class="ruby-keyword kw">else</span>
478 60:             <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC5</span>, <span class="ruby-value str">&quot;Received a control message, possibly via 'mco controller' but this has been deprecated&quot;</span>, <span class="ruby-identifier">:error</span>)
479 61:           <span class="ruby-keyword kw">end</span>
480 62:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">SignalException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
481 63:           <span class="ruby-identifier">logexception</span>(<span class="ruby-identifier">:PLMC7</span>, <span class="ruby-value str">&quot;Exiting after signal: %{error}&quot;</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">e</span>)
482 64:           <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">disconnect</span>
483 65:           <span class="ruby-identifier">raise</span>
484 66: 
485 67:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MsgTTLExpired</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
486 68:           <span class="ruby-identifier">logexception</span>(<span class="ruby-identifier">:PLMC9</span>, <span class="ruby-value str">&quot;Expired Message: %{error}&quot;</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">e</span>)
487 69: 
488 70:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NotTargettedAtUs</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
489 71:           <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC6</span>, <span class="ruby-value str">&quot;Message does not pass filters, ignoring&quot;</span>, <span class="ruby-identifier">:debug</span>)
490 72: 
491 73:         <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>
492 74:           <span class="ruby-identifier">logexception</span>(<span class="ruby-identifier">:PLMC10</span>, <span class="ruby-value str">&quot;Failed to handle message: %{error}&quot;</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">e</span>, <span class="ruby-keyword kw">true</span>)
493 75:         <span class="ruby-keyword kw">end</span>
494 76:       <span class="ruby-keyword kw">end</span>
495 77:     <span class="ruby-keyword kw">end</span></pre>
496                                         </div>
497                                         
498                                 </div>
499
500                                 
501                         </div>
502
503                 
504                 </div>
505         
506                 <div id="private-instance-method-details" class="method-section section">
507                         <h3 class="section-header">Private Instance Methods</h3>
508
509                 
510                         <div id="agentmsg-method" class="method-detail ">
511                                 <a name="M000071"></a>
512
513                                 <div class="method-heading">
514                                 
515                                         <span class="method-name">agentmsg</span><span
516                                                 class="method-args">(request)</span>
517                                         <span class="method-click-advice">click to toggle source</span>
518                                 
519                                 </div>
520
521                                 <div class="method-description">
522                                         
523                                         <p>
524 Deals with messages directed to agents
525 </p>
526                                         
527
528                                         
529                                         <div class="method-source-code"
530                                                 id="agentmsg-source">
531 <pre>
532     <span class="ruby-comment cmt"># File lib/mcollective/runner.rb, line 81</span>
533 81:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">agentmsg</span>(<span class="ruby-identifier">request</span>)
534 82:       <span class="ruby-identifier">log_code</span>(<span class="ruby-identifier">:PLMC8</span>, <span class="ruby-value str">&quot;Handling message for agent '%{agent}' on collective '%{collective} with requestid '%{requestid}'&quot;</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">agent</span>, <span class="ruby-identifier">:collective</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">collective</span>, <span class="ruby-identifier">:requestid</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">requestid</span>)
535 83: 
536 84:       <span class="ruby-ivar">@agents</span>.<span class="ruby-identifier">dispatch</span>(<span class="ruby-identifier">request</span>, <span class="ruby-ivar">@connection</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">reply_message</span><span class="ruby-operator">|</span>
537 85:         <span class="ruby-identifier">reply</span>(<span class="ruby-identifier">reply_message</span>, <span class="ruby-identifier">request</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">reply_message</span>
538 86:       <span class="ruby-keyword kw">end</span>
539 87:     <span class="ruby-keyword kw">end</span></pre>
540                                         </div>
541                                         
542                                 </div>
543
544                                 
545                         </div>
546
547                 
548                         <div id="controlmsg-method" class="method-detail ">
549                                 <a name="M000072"></a>
550
551                                 <div class="method-heading">
552                                 
553                                         <span class="method-name">controlmsg</span><span
554                                                 class="method-args">(request)</span>
555                                         <span class="method-click-advice">click to toggle source</span>
556                                 
557                                 </div>
558
559                                 <div class="method-description">
560                                         
561                                         <p>
562 Deals with messages sent to our control topic
563 </p>
564                                         
565
566                                         
567                                         <div class="method-source-code"
568                                                 id="controlmsg-source">
569 <pre>
570      <span class="ruby-comment cmt"># File lib/mcollective/runner.rb, line 90</span>
571  90:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">controlmsg</span>(<span class="ruby-identifier">request</span>)
572  91:       <span class="ruby-constant">Log</span>.<span class="ruby-identifier">debug</span>(<span class="ruby-value str">&quot;Handling message for mcollectived controller&quot;</span>)
573  92: 
574  93:       <span class="ruby-keyword kw">begin</span>
575  94:         <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">payload</span>[<span class="ruby-identifier">:body</span>]
576  95:         <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^stats$/</span>
577  96:           <span class="ruby-identifier">reply</span>(<span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">to_hash</span>, <span class="ruby-identifier">request</span>)
578  97: 
579  98:         <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^reload_agent (.+)$/</span>
580  99:           <span class="ruby-identifier">reply</span>(<span class="ruby-node">&quot;reloaded #{$1} agent&quot;</span>, <span class="ruby-identifier">request</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@agents</span>.<span class="ruby-identifier">loadagent</span>(<span class="ruby-identifier">$1</span>)
581 100: 
582 101:         <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^reload_agents$/</span>
583 102: 
584 103:           <span class="ruby-identifier">reply</span>(<span class="ruby-value str">&quot;reloaded all agents&quot;</span>, <span class="ruby-identifier">request</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@agents</span>.<span class="ruby-identifier">loadagents</span>
585 104: 
586 105:         <span class="ruby-keyword kw">else</span>
587 106:           <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-value str">&quot;Received an unknown message to the controller&quot;</span>)
588 107: 
589 108:         <span class="ruby-keyword kw">end</span>
590 109:       <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>
591 110:         <span class="ruby-constant">Log</span>.<span class="ruby-identifier">error</span>(<span class="ruby-node">&quot;Failed to handle control message: #{e}&quot;</span>)
592 111:       <span class="ruby-keyword kw">end</span>
593 112:     <span class="ruby-keyword kw">end</span></pre>
594                                         </div>
595                                         
596                                 </div>
597
598                                 
599                         </div>
600
601                 
602                         <div id="receive-method" class="method-detail ">
603                                 <a name="M000077"></a>
604
605                                 <div class="method-heading">
606                                 
607                                         <span class="method-name">receive</span><span
608                                                 class="method-args">()</span>
609                                         <span class="method-click-advice">click to toggle source</span>
610                                 
611                                 </div>
612
613                                 <div class="method-description">
614                                         
615                                         <p>
616 Receive a message from the connection handler
617 </p>
618                                         
619
620                                         
621                                         <div class="method-source-code"
622                                                 id="receive-source">
623 <pre>
624      <span class="ruby-comment cmt"># File lib/mcollective/runner.rb, line 115</span>
625 115:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">receive</span>
626 116:       <span class="ruby-identifier">request</span> = <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">receive</span>
627 117:       <span class="ruby-identifier">request</span>.<span class="ruby-identifier">type</span> = <span class="ruby-identifier">:request</span>
628 118: 
629 119:       <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">received</span>
630 120: 
631 121:       <span class="ruby-identifier">request</span>.<span class="ruby-identifier">decode!</span>
632 122:       <span class="ruby-identifier">request</span>.<span class="ruby-identifier">validate</span>
633 123: 
634 124:       <span class="ruby-identifier">request</span>
635 125:     <span class="ruby-keyword kw">end</span></pre>
636                                         </div>
637                                         
638                                 </div>
639
640                                 
641                         </div>
642
643                 
644                         <div id="reply-method" class="method-detail ">
645                                 <a name="M000078"></a>
646
647                                 <div class="method-heading">
648                                 
649                                         <span class="method-name">reply</span><span
650                                                 class="method-args">(msg, request)</span>
651                                         <span class="method-click-advice">click to toggle source</span>
652                                 
653                                 </div>
654
655                                 <div class="method-description">
656                                         
657                                         <p>
658 Sends a reply to a specific target topic
659 </p>
660                                         
661
662                                         
663                                         <div class="method-source-code"
664                                                 id="reply-source">
665 <pre>
666      <span class="ruby-comment cmt"># File lib/mcollective/runner.rb, line 128</span>
667 128:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reply</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-identifier">request</span>)
668 129:       <span class="ruby-identifier">msg</span> = <span class="ruby-constant">Message</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">msg</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-identifier">:request</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">request</span>)
669 130:       <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">encode!</span>
670 131:       <span class="ruby-identifier">msg</span>.<span class="ruby-identifier">publish</span>
671 132: 
672 133:       <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">sent</span>
673 134:     <span class="ruby-keyword kw">end</span></pre>
674                                         </div>
675                                         
676                                 </div>
677
678                                 
679                         </div>
680
681                 
682                 </div>
683         
684
685         </div>
686
687
688         <div id="rdoc-debugging-section-dump" class="debugging-section">
689         
690                 <p>Disabled; run with --debug to generate this.</p>
691         
692         </div>
693
694         <div id="validator-badges">
695                 <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
696                 <p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
697                         Rdoc Generator</a> 1.1.6</small>.</p>
698         </div>
699
700 </body>
701 </html>
702