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">
6 <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8 <title>Class: MCollective::Runner</title>
10 <link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
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>
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">
31 <li><a href="../lib/mcollective/runner_rb.html?TB_iframe=true&height=550&width=785"
32 class="thickbox" title="lib/mcollective/runner.rb">lib/mcollective/runner.rb</a></li>
41 <div id="class-metadata">
45 <div id="parent-class-section" class="section">
46 <h3 class="section-header">Parent</h3>
48 <p class="link"><a href="../Object.html">Object</a></p>
53 <!-- Namespace Contents -->
56 <!-- Method Quickref -->
58 <div id="method-list-section" class="section">
59 <h3 class="section-header">Methods</h3>
60 <ul class="link-list">
62 <li><a href="#M000069">::new</a></li>
64 <li><a href="#M000071">#agentmsg</a></li>
66 <li><a href="#M000072">#controlmsg</a></li>
68 <li><a href="#M000073">#receive</a></li>
70 <li><a href="#M000074">#reply</a></li>
72 <li><a href="#M000070">#run</a></li>
78 <!-- Included Modules -->
80 <div id="includes-section" class="section">
81 <h3 class="section-header">Included Modules</h3>
82 <ul class="link-list">
85 <li><a class="include" href="Connector.html">MCollective::Connector</a></li>
93 <div id="project-metadata">
96 <div id="fileindex-section" class="section project-section">
97 <h3 class="section-header">Files</h3>
100 <li class="file"><a href="../COPYING.html">COPYING</a></li>
102 <li class="file"><a href="../Gemfile.html">Gemfile</a></li>
104 <li class="file"><a href="../README.html">README</a></li>
106 <li class="file"><a href="../Rakefile.html">Rakefile</a></li>
108 <li class="file"><a href="../etc/client_cfg_dist.html">client.cfg.dist</a></li>
110 <li class="file"><a href="../etc/data-help_erb.html">data-help.erb</a></li>
112 <li class="file"><a href="../etc/discovery-help_erb.html">discovery-help.erb</a></li>
114 <li class="file"><a href="../etc/facts_yaml_dist.html">facts.yaml.dist</a></li>
116 <li class="file"><a href="../etc/metadata-help_erb.html">metadata-help.erb</a></li>
118 <li class="file"><a href="../etc/msg-help_erb.html">msg-help.erb</a></li>
120 <li class="file"><a href="../etc/rpc-help_erb.html">rpc-help.erb</a></li>
122 <li class="file"><a href="../etc/server_cfg_dist.html">server.cfg.dist</a></li>
124 <li class="file"><a href="../etc/ssl/PLACEHOLDER.html">PLACEHOLDER</a></li>
126 <li class="file"><a href="../etc/ssl/clients/PLACEHOLDER.html">PLACEHOLDER</a></li>
128 <li class="file"><a href="../lib/mcollective/generators/templates/action_snippet_erb.html">action_snippet.erb</a></li>
130 <li class="file"><a href="../lib/mcollective/generators/templates/data_input_snippet_erb.html">data_input_snippet.erb</a></li>
132 <li class="file"><a href="../lib/mcollective/generators/templates/ddl_erb.html">ddl.erb</a></li>
134 <li class="file"><a href="../lib/mcollective/generators/templates/plugin_erb.html">plugin.erb</a></li>
136 <li class="file"><a href="../lib/mcollective/locales/en_yml.html">en.yml</a></li>
138 <li class="file"><a href="../mcollective_init.html">mcollective.init</a></li>
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">
151 <legend>Quicksearch</legend>
152 <input type="text" name="quicksearch" value=""
153 class="quicksearch-field" />
157 <ul class="link-list">
159 <li><a href="../MCollective.html">MCollective</a></li>
161 <li><a href="../MCollective/Agent.html">MCollective::Agent</a></li>
163 <li><a href="../MCollective/Agents.html">MCollective::Agents</a></li>
165 <li><a href="../MCollective/Aggregate.html">MCollective::Aggregate</a></li>
167 <li><a href="../MCollective/Aggregate/Base.html">MCollective::Aggregate::Base</a></li>
169 <li><a href="../MCollective/Aggregate/Result.html">MCollective::Aggregate::Result</a></li>
171 <li><a href="../MCollective/Aggregate/Result/Base.html">MCollective::Aggregate::Result::Base</a></li>
173 <li><a href="../MCollective/Aggregate/Result/CollectionResult.html">MCollective::Aggregate::Result::CollectionResult</a></li>
175 <li><a href="../MCollective/Aggregate/Result/NumericResult.html">MCollective::Aggregate::Result::NumericResult</a></li>
177 <li><a href="../MCollective/Application.html">MCollective::Application</a></li>
179 <li><a href="../MCollective/Applications.html">MCollective::Applications</a></li>
181 <li><a href="../MCollective/Cache.html">MCollective::Cache</a></li>
183 <li><a href="../MCollective/Client.html">MCollective::Client</a></li>
185 <li><a href="../MCollective/CodedError.html">MCollective::CodedError</a></li>
187 <li><a href="../MCollective/Config.html">MCollective::Config</a></li>
189 <li><a href="../MCollective/Connector.html">MCollective::Connector</a></li>
191 <li><a href="../MCollective/Connector/Base.html">MCollective::Connector::Base</a></li>
193 <li><a href="../MCollective/DDL.html">MCollective::DDL</a></li>
195 <li><a href="../MCollective/DDL/AgentDDL.html">MCollective::DDL::AgentDDL</a></li>
197 <li><a href="../MCollective/DDL/Base.html">MCollective::DDL::Base</a></li>
199 <li><a href="../MCollective/DDL/DataDDL.html">MCollective::DDL::DataDDL</a></li>
201 <li><a href="../MCollective/DDL/DiscoveryDDL.html">MCollective::DDL::DiscoveryDDL</a></li>
203 <li><a href="../MCollective/DDL/ValidatorDDL.html">MCollective::DDL::ValidatorDDL</a></li>
205 <li><a href="../MCollective/DDLValidationError.html">MCollective::DDLValidationError</a></li>
207 <li><a href="../MCollective/Data.html">MCollective::Data</a></li>
209 <li><a href="../MCollective/Data/Base.html">MCollective::Data::Base</a></li>
211 <li><a href="../MCollective/Data/Result.html">MCollective::Data::Result</a></li>
213 <li><a href="../MCollective/Discovery.html">MCollective::Discovery</a></li>
215 <li><a href="../MCollective/Facts.html">MCollective::Facts</a></li>
217 <li><a href="../MCollective/Facts/Base.html">MCollective::Facts::Base</a></li>
219 <li><a href="../MCollective/Generators.html">MCollective::Generators</a></li>
221 <li><a href="../MCollective/Generators/AgentGenerator.html">MCollective::Generators::AgentGenerator</a></li>
223 <li><a href="../MCollective/Generators/Base.html">MCollective::Generators::Base</a></li>
225 <li><a href="../MCollective/Generators/DataGenerator.html">MCollective::Generators::DataGenerator</a></li>
227 <li><a href="../MCollective/InvalidRPCData.html">MCollective::InvalidRPCData</a></li>
229 <li><a href="../MCollective/Log.html">MCollective::Log</a></li>
231 <li><a href="../MCollective/Logger.html">MCollective::Logger</a></li>
233 <li><a href="../MCollective/Logger/Base.html">MCollective::Logger::Base</a></li>
235 <li><a href="../MCollective/Logger/Console_logger.html">MCollective::Logger::Console_logger</a></li>
237 <li><a href="../MCollective/Logger/File_logger.html">MCollective::Logger::File_logger</a></li>
239 <li><a href="../MCollective/Logger/Syslog_logger.html">MCollective::Logger::Syslog_logger</a></li>
241 <li><a href="../MCollective/Matcher.html">MCollective::Matcher</a></li>
243 <li><a href="../MCollective/Matcher/Parser.html">MCollective::Matcher::Parser</a></li>
245 <li><a href="../MCollective/Matcher/Scanner.html">MCollective::Matcher::Scanner</a></li>
247 <li><a href="../MCollective/Message.html">MCollective::Message</a></li>
249 <li><a href="../MCollective/MissingRPCData.html">MCollective::MissingRPCData</a></li>
251 <li><a href="../MCollective/MsgDoesNotMatchRequestID.html">MCollective::MsgDoesNotMatchRequestID</a></li>
253 <li><a href="../MCollective/MsgTTLExpired.html">MCollective::MsgTTLExpired</a></li>
255 <li><a href="../MCollective/NotTargettedAtUs.html">MCollective::NotTargettedAtUs</a></li>
257 <li><a href="../MCollective/Optionparser.html">MCollective::Optionparser</a></li>
259 <li><a href="../MCollective/PluginManager.html">MCollective::PluginManager</a></li>
261 <li><a href="../MCollective/PluginPackager.html">MCollective::PluginPackager</a></li>
263 <li><a href="../MCollective/PluginPackager/AgentDefinition.html">MCollective::PluginPackager::AgentDefinition</a></li>
265 <li><a href="../MCollective/PluginPackager/StandardDefinition.html">MCollective::PluginPackager::StandardDefinition</a></li>
267 <li><a href="../MCollective/RPC.html">MCollective::RPC</a></li>
269 <li><a href="../MCollective/RPC/ActionRunner.html">MCollective::RPC::ActionRunner</a></li>
271 <li><a href="../MCollective/RPC/Agent.html">MCollective::RPC::Agent</a></li>
273 <li><a href="../MCollective/RPC/Audit.html">MCollective::RPC::Audit</a></li>
275 <li><a href="../MCollective/RPC/Client.html">MCollective::RPC::Client</a></li>
277 <li><a href="../MCollective/RPC/Helpers.html">MCollective::RPC::Helpers</a></li>
279 <li><a href="../MCollective/RPC/Progress.html">MCollective::RPC::Progress</a></li>
281 <li><a href="../MCollective/RPC/Reply.html">MCollective::RPC::Reply</a></li>
283 <li><a href="../MCollective/RPC/Request.html">MCollective::RPC::Request</a></li>
285 <li><a href="../MCollective/RPC/Result.html">MCollective::RPC::Result</a></li>
287 <li><a href="../MCollective/RPC/Stats.html">MCollective::RPC::Stats</a></li>
289 <li><a href="../MCollective/RPCAborted.html">MCollective::RPCAborted</a></li>
291 <li><a href="../MCollective/RPCError.html">MCollective::RPCError</a></li>
293 <li><a href="../MCollective/Registration.html">MCollective::Registration</a></li>
295 <li><a href="../MCollective/Registration/Base.html">MCollective::Registration::Base</a></li>
297 <li><a href="../MCollective/Runner.html">MCollective::Runner</a></li>
299 <li><a href="../MCollective/RunnerStats.html">MCollective::RunnerStats</a></li>
301 <li><a href="../MCollective/SSL.html">MCollective::SSL</a></li>
303 <li><a href="../MCollective/Security.html">MCollective::Security</a></li>
305 <li><a href="../MCollective/Security/Base.html">MCollective::Security::Base</a></li>
307 <li><a href="../MCollective/SecurityValidationFailed.html">MCollective::SecurityValidationFailed</a></li>
309 <li><a href="../MCollective/Shell.html">MCollective::Shell</a></li>
311 <li><a href="../MCollective/Translatable.html">MCollective::Translatable</a></li>
313 <li><a href="../MCollective/UnixDaemon.html">MCollective::UnixDaemon</a></li>
315 <li><a href="../MCollective/UnknownRPCAction.html">MCollective::UnknownRPCAction</a></li>
317 <li><a href="../MCollective/UnknownRPCError.html">MCollective::UnknownRPCError</a></li>
319 <li><a href="../MCollective/Util.html">MCollective::Util</a></li>
321 <li><a href="../MCollective/Validator.html">MCollective::Validator</a></li>
323 <li><a href="../MCollective/ValidatorError.html">MCollective::ValidatorError</a></li>
325 <li><a href="../MCollective/WindowsDaemon.html">MCollective::WindowsDaemon</a></li>
327 <li><a href="../Array.html">Array</a></li>
329 <li><a href="../Dir.html">Dir</a></li>
331 <li><a href="../Object.html">Object</a></li>
333 <li><a href="../String.html">String</a></li>
335 <li><a href="../Symbol.html">Symbol</a></li>
338 <div id="no-class-search-results" style="display: none;">No matching classes.</div>
345 <div id="documentation">
346 <h1 class="class">MCollective::Runner</h1>
348 <div id="description">
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
365 <div id="public-class-method-details" class="method-section section">
366 <h3 class="section-header">Public Class Methods</h3>
369 <div id="new-method" class="method-detail ">
370 <a name="M000069"></a>
372 <div class="method-heading">
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>
380 <div class="method-description">
382 <p class="missing-docs">(Not documented)</p>
386 <div class="method-source-code"
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>
395 13: <span class="ruby-ivar">@stats</span> = <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">"global_stats"</span>]
397 15: <span class="ruby-ivar">@security</span> = <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">"security_plugin"</span>]
398 16: <span class="ruby-ivar">@security</span>.<span class="ruby-identifier">initiated_by</span> = <span class="ruby-identifier">:node</span>
400 18: <span class="ruby-ivar">@connection</span> = <span class="ruby-constant">PluginManager</span>[<span class="ruby-value str">"connector_plugin"</span>]
401 19: <span class="ruby-ivar">@connection</span>.<span class="ruby-identifier">connect</span>
403 21: <span class="ruby-ivar">@agents</span> = <span class="ruby-constant">Agents</span>.<span class="ruby-identifier">new</span>
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">"USR1"</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">"Reloading all agents after receiving USR1 signal"</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>
411 29: <span class="ruby-constant">Signal</span>.<span class="ruby-identifier">trap</span>(<span class="ruby-value str">"USR2"</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">"Cycling logging level due to USR2 signal"</span>, <span class="ruby-identifier">:info</span>)
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>
430 <div id="public-instance-method-details" class="method-section section">
431 <h3 class="section-header">Public Instance Methods</h3>
434 <div id="run-method" class="method-detail ">
435 <a name="M000070"></a>
437 <div class="method-heading">
439 <span class="method-name">run</span><span
440 class="method-args">()</span>
441 <span class="method-click-advice">click to toggle source</span>
445 <div class="method-description">
448 Starts the main loop, before calling this you should initialize the <a
449 href="Config.html">MCollective::Config</a> singleton.
454 <div class="method-source-code"
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>
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">"mcollective"</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">"mcollective"</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>
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">"registration_plugin"</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">></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">"Failed to start registration plugin: %{error}"</span>, <span class="ruby-identifier">:error</span>, <span class="ruby-identifier">e</span>)
469 51: <span class="ruby-keyword kw">end</span>
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>
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">"mcollective"</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">"Received a control message, possibly via 'mco controller' but this has been deprecated"</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">></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">"Exiting after signal: %{error}"</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>
485 67: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">MsgTTLExpired</span> =<span class="ruby-operator">></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">"Expired Message: %{error}"</span>, <span class="ruby-identifier">:warn</span>, <span class="ruby-identifier">e</span>)
488 70: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">NotTargettedAtUs</span> =<span class="ruby-operator">></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">"Message does not pass filters, ignoring"</span>, <span class="ruby-identifier">:debug</span>)
491 73: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></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">"Failed to handle message: %{error}"</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>
506 <div id="private-instance-method-details" class="method-section section">
507 <h3 class="section-header">Private Instance Methods</h3>
510 <div id="agentmsg-method" class="method-detail ">
511 <a name="M000071"></a>
513 <div class="method-heading">
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>
521 <div class="method-description">
524 Deals with messages directed to agents
529 <div class="method-source-code"
530 id="agentmsg-source">
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">"Handling message for agent '%{agent}' on collective '%{collective} with requestid '%{requestid}'"</span>, <span class="ruby-identifier">:debug</span>, <span class="ruby-identifier">:agent</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">agent</span>, <span class="ruby-identifier">:collective</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">collective</span>, <span class="ruby-identifier">:requestid</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">request</span>.<span class="ruby-identifier">requestid</span>)
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>
548 <div id="controlmsg-method" class="method-detail ">
549 <a name="M000072"></a>
551 <div class="method-heading">
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>
559 <div class="method-description">
562 Deals with messages sent to our control topic
567 <div class="method-source-code"
568 id="controlmsg-source">
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">"Handling message for mcollectived controller"</span>)
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>)
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">"reloaded #{$1} agent"</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>)
582 101: <span class="ruby-keyword kw">when</span> <span class="ruby-regexp re">/^reload_agents$/</span>
584 103: <span class="ruby-identifier">reply</span>(<span class="ruby-value str">"reloaded all agents"</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>
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">"Received an unknown message to the controller"</span>)
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">></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">"Failed to handle control message: #{e}"</span>)
592 111: <span class="ruby-keyword kw">end</span>
593 112: <span class="ruby-keyword kw">end</span></pre>
602 <div id="receive-method" class="method-detail ">
603 <a name="M000073"></a>
605 <div class="method-heading">
607 <span class="method-name">receive</span><span
608 class="method-args">()</span>
609 <span class="method-click-advice">click to toggle source</span>
613 <div class="method-description">
616 Receive a message from the connection handler
621 <div class="method-source-code"
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>
629 119: <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">received</span>
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>
634 124: <span class="ruby-identifier">request</span>
635 125: <span class="ruby-keyword kw">end</span></pre>
644 <div id="reply-method" class="method-detail ">
645 <a name="M000074"></a>
647 <div class="method-heading">
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>
655 <div class="method-description">
658 Sends a reply to a specific target topic
663 <div class="method-source-code"
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">></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>
672 133: <span class="ruby-ivar">@stats</span>.<span class="ruby-identifier">sent</span>
673 134: <span class="ruby-keyword kw">end</span></pre>
688 <div id="rdoc-debugging-section-dump" class="debugging-section">
690 <p>Disabled; run with --debug to generate this.</p>
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>