Module: RSMP::SiteProxy::Modules::AggregatedStatus

Included in:
RSMP::SiteProxy
Defined in:
lib/rsmp/proxy/site/modules/aggregated_status.rb

Overview

Handles aggregated status requests and responses

Instance Method Summary collapse

Instance Method Details

#aggregated_status_changed(component, _options = {}) ⇒ Object



46
47
48
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 46

def aggregated_status_changed(component, _options = {})
  @supervisor.aggregated_status_changed self, component
end

#process_aggregated_status(message) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 29

def process_aggregated_status(message)
  status_elements = message.attribute('se')
  validate_aggregated_status(message, status_elements)
  c_id = message.attributes['cId']
  component = find_component c_id
  unless component
    reason = "component #{c_id} not found"
    dont_acknowledge message, "Ignoring #{message.type}:", reason
    return
  end

  component.aggregated_status_bools = status_elements
  log "Received #{message.type} status for component #{c_id} [#{component.aggregated_status.join(', ')}]",
      message: message
  acknowledge message
end

#request_aggregated_status(component, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 6

def request_aggregated_status(component, options = {})
  validate_ready 'request aggregated status'
  m_id = options[:m_id] || RSMP::Message.make_m_id
  message = RSMP::AggregatedStatusRequest.new({
                                                'cId' => component,
                                                'mId' => m_id
                                              })
  apply_nts_message_attributes message
  send_and_optionally_collect message, options do |collect_options|
    AggregatedStatusCollector.new(
      self,
      collect_options.merge(task: @task, m_id: m_id, num: 1)
    )
  end
end

#validate_aggregated_status(message, status_elements) ⇒ Object

Raises:



22
23
24
25
26
27
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 22

def validate_aggregated_status(message, status_elements)
  return if status_elements.is_a?(Array) && status_elements.size == 8

  dont_acknowledge message, 'Received', reaons
  raise InvalidMessage
end