-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reducing the data persited in the full_data columm #185
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ class ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventCatcher::Stream | |
def initialize(ems) | ||
@ems = ems | ||
@collect_events = true | ||
@last_event_ems_ref = last_event_ems_ref(@ems.id) | ||
end | ||
|
||
# Stop capturing events | ||
|
@@ -15,7 +16,7 @@ def stop | |
def each_batch | ||
$log.info('Starting collect of LXCA events ...') | ||
while @collect_events | ||
yield(events.collect { |e| ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventParser.event_to_hash(e, @ems.id) }) | ||
yield(parse_events(events)) | ||
end | ||
$log.info('Stopping collect of LXCA events ...') | ||
end | ||
|
@@ -27,12 +28,26 @@ def filter_fields | |
{ :operation => 'NOT', :field => 'eventClass', :value => '200' }, | ||
{ :operation => 'NOT', :field => 'eventClass', :value => '800' } | ||
] | ||
last_cn_event = get_last_cnn_from_events(@ems.id) | ||
cn_operation = { :operation => 'GT', :field => 'cn', :value => last_cn_event.to_s } | ||
fields.push(cn_operation) unless last_cn_event.nil? | ||
|
||
unless @last_event_ems_ref.nil? | ||
cn_operation = { :operation => 'GT', :field => 'cn', :value => @last_event_ems_ref.to_s } | ||
fields.push(cn_operation) | ||
end | ||
fields | ||
end | ||
|
||
def parse_events(events) | ||
return if events.blank? | ||
|
||
parsed_events = events.sort { |x, y| Integer(x.cn) <=> Integer(y.cn) }.collect do |event| | ||
ManageIQ::Providers::Lenovo::PhysicalInfraManager::EventParser.event_to_hash(event, @ems.id) | ||
end | ||
|
||
# Update the @last_event_ems_ref with the new last ems_ref if to exist new events | ||
@last_event_ems_ref = parsed_events.last[:ems_ref] | ||
parsed_events | ||
end | ||
|
||
def events | ||
expression = { :filterType => 'FIELDNOTREGEXAND', :fields => filter_fields } | ||
|
||
|
@@ -54,7 +69,7 @@ def create_event_connection(ems) | |
:port => ems.endpoints.first.port) | ||
end | ||
|
||
def get_last_cnn_from_events(ems_id) | ||
EventStream.where(:ems_id => ems_id).maximum('ems_ref') || 1 | ||
def last_event_ems_ref(ems_id) | ||
EventStream.where(:ems_id => ems_id).maximum('CAST(ems_ref AS int)') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is going to be expensive but now that it is only done once on startup it should be manageable. If this proves to be an issue we can add a column to the events stream table to store this specifically. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you. I think all the thinks are ok, but if we need in the future add a new column to store this, let me know I can do this. 👍 |
||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you call this raw_events? Parsing
events
and returningevents
is confusingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍