### Home Classes Methods

### In Files

- lib/mcollective/aggregate/base.rb
- lib/mcollective/aggregate/result/numeric_result.rb
- lib/mcollective/aggregate/result/base.rb
- lib/mcollective/aggregate/result/collection_result.rb
- lib/mcollective/aggregate/result.rb
- lib/mcollective/aggregate.rb

### Parent

Object

### Namespace

- MODULE MCollective::Aggregate::Result
- CLASS MCollective::Aggregate::Base

### Methods

- ::new
- #call_functions
- #contains_output?
- #create_functions
- #load_function
- #summarize

### Files

- COPYING
- README
- Rakefile
- PLACEHOLDER
- PLACEHOLDER

### Class/Module Index

Quicksearch

- MCollective
- MCollective::Agent
- MCollective::Agents
- MCollective::Aggregate
- MCollective::Aggregate::Base
- MCollective::Aggregate::Result
- MCollective::Aggregate::Result::Base
- MCollective::Aggregate::Result::CollectionResult
- MCollective::Aggregate::Result::NumericResult
- MCollective::Application
- MCollective::Applications
- MCollective::Client
- MCollective::Config
- MCollective::Connector
- MCollective::Connector::Base
- MCollective::DDL
- MCollective::DDLValidationError
- MCollective::Data
- MCollective::Data::Base
- MCollective::Data::Result
- MCollective::Discovery
- MCollective::Facts
- MCollective::Facts::Base
- MCollective::Generators
- MCollective::Generators::AgentGenerator
- MCollective::Generators::Base
- MCollective::Generators::DataGenerator
- MCollective::InvalidRPCData
- MCollective::Log
- MCollective::Logger
- MCollective::Logger::Base
- MCollective::Logger::Console_logger
- MCollective::Logger::File_logger
- MCollective::Logger::Syslog_logger
- MCollective::Matcher
- MCollective::Matcher::Parser
- MCollective::Matcher::Scanner
- MCollective::Message
- MCollective::MissingRPCData
- MCollective::MsgDoesNotMatchRequestID
- MCollective::MsgTTLExpired
- MCollective::NotTargettedAtUs
- MCollective::Optionparser
- MCollective::PluginManager
- MCollective::PluginPackager
- MCollective::PluginPackager::AgentDefinition
- MCollective::PluginPackager::StandardDefinition
- MCollective::RPC
- MCollective::RPC::ActionRunner
- MCollective::RPC::Agent
- MCollective::RPC::Audit
- MCollective::RPC::Client
- MCollective::RPC::Helpers
- MCollective::RPC::Progress
- MCollective::RPC::Reply
- MCollective::RPC::Request
- MCollective::RPC::Result
- MCollective::RPC::Stats
- MCollective::RPCAborted
- MCollective::RPCError
- MCollective::Registration
- MCollective::Registration::Base
- MCollective::Runner
- MCollective::RunnerStats
- MCollective::SSL
- MCollective::Security
- MCollective::Security::Base
- MCollective::SecurityValidationFailed
- MCollective::Shell
- MCollective::UnixDaemon
- MCollective::UnknownRPCAction
- MCollective::UnknownRPCError
- MCollective::Util
- MCollective::WindowsDaemon
- Array
- Dir
- Object
- String
- Symbol

No matching classes.

# MCollective::Aggregate

### Attributes

action[RW]
ddl[RW]
functions[RW]

### Public Instance Methods

call_functions(reply) click to toggle source

Call all the appropriate functions with the reply data received from RPC::Client

    # File lib/mcollective/aggregate.rb, line 35
    def call_functions(reply)
      @functions.each do |function|
        Log.debug("Calling aggregate function #{function} for result")
        function.process_result(reply[:data][function.output_name], reply)
      end
    end

contains_output?(output) click to toggle source

Check if the function param is defined as an output for the action in the ddl

    # File lib/mcollective/aggregate.rb, line 30
    def contains_output?(output)
      raise "'#{@ddl[:action]}' action does not contain output '#{output}'" unless @ddl[:output].keys.include?(output)
    end

create_functions() click to toggle source

Creates instances of the Aggregate functions and stores them in the function array. All aggregate call and summarize method calls operate on these function as a batch.

    # File lib/mcollective/aggregate.rb, line 18
    def create_functions
      @ddl[:aggregate].each_with_index do |agg, i|
        contains_output?(agg[:args][0])

        output = agg[:args][0]
        arguments = agg[:args][1..(agg[:args].size)]

        @functions << load_function(agg[:function]).new(output, arguments, agg[:format], @action)
      end
    end

load_function(function_name) click to toggle source

Loads function from disk for use

    # File lib/mcollective/aggregate.rb, line 52
    def load_function(function_name)
      function_name = function_name.to_s.capitalize

      PluginManager.loadclass("MCollective::Aggregate::#{function_name}") unless Aggregate.const_defined?(function_name)
      Aggregate.const_get(function_name)
    rescue Exception
      raise "Aggregate function file '#{function_name.downcase}.rb' cannot be loaded"
    end

summarize() click to toggle source

Finalizes the function returning a result object

    # File lib/mcollective/aggregate.rb, line 43
    def summarize
      summary = @functions.map do |function|
        function.summarize
      end

      summary.sort{|x,y| x.result[:output] <=> y.result[:output]}
    end

### Public Class Methods

new(ddl) click to toggle source

    # File lib/mcollective/aggregate.rb, line 8
    def initialize(ddl)
      @functions = []
      @ddl = ddl
      @action = ddl[:action]

      create_functions
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.