Skip to content

Commit

Permalink
Move graph refresh internals logging to debug
Browse files Browse the repository at this point in the history
Fixes: #16374
  • Loading branch information
agrare committed Nov 10, 2017
1 parent e5b50ff commit 670b776
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
8 changes: 4 additions & 4 deletions app/models/manager_refresh/save_collection/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ module ManagerRefresh::SaveCollection
class Base
class << self
def save_inventory_object_inventory(ems, inventory_collection)
_log.info("SYNCHRONIZING collection #{inventory_collection} of size #{inventory_collection.size} to"\
" the database, for the manager: '#{ems.name}'")
_log.debug("Saving collection #{inventory_collection} of size #{inventory_collection.size} to"\
" the database, for the manager: '#{ems.name}'...")

if inventory_collection.custom_save_block.present?
_log.info("SYNCHRONIZING collection #{inventory_collection} using a custom save block")
_log.debug("Saving collection #{inventory_collection} using a custom save block")
inventory_collection.custom_save_block.call(ems, inventory_collection)
else
save_inventory(inventory_collection)
end
_log.info("SYNCHRONIZED collection #{inventory_collection}, for the manager: '#{ems.name}'")
_log.debug("Saving collection #{inventory_collection}, for the manager: '#{ems.name}'...Complete")
inventory_collection.saved = true
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/manager_refresh/save_collection/recursive.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def save_collection(ems, inventory_collection, traversed_collections)
end
end

_log.info("Saving #{inventory_collection} of size #{inventory_collection.size}")
_log.debug("Saving #{inventory_collection} of size #{inventory_collection.size}")
save_inventory_object_inventory(ems, inventory_collection)
end
end
Expand Down
18 changes: 9 additions & 9 deletions app/models/manager_refresh/save_collection/saver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def save!(association)
inventory_objects_index[index] = inventory_object
end

_log.info("*************** PROCESSING #{inventory_collection} of size #{inventory_collection.size} *************")
_log.debug("Processing #{inventory_collection} of size #{inventory_collection.size}...")
# Records that are in the DB, we will be updating or deleting them.
ActiveRecord::Base.transaction do
association.find_each do |record|
Expand Down Expand Up @@ -121,10 +121,10 @@ def save!(association)
end
end
end
_log.info("*************** PROCESSED #{inventory_collection}, "\
"created=#{inventory_collection.created_records.count}, "\
"updated=#{inventory_collection.updated_records.count}, "\
"deleted=#{inventory_collection.deleted_records.count} *************")
_log.debug("Processing #{inventory_collection}, "\
"created=#{inventory_collection.created_records.count}, "\
"updated=#{inventory_collection.updated_records.count}, "\
"deleted=#{inventory_collection.deleted_records.count}...Complete")
rescue => e
_log.error("Error when saving #{inventory_collection} with #{inventory_collection_details}. Message: #{e.message}")
raise e
Expand All @@ -143,8 +143,8 @@ def delete_complement

all_manager_uuids_size = inventory_collection.all_manager_uuids.size

_log.info("*************** PROCESSING :delete_complement of #{inventory_collection} of size "\
"#{all_manager_uuids_size} *************")
_log.debug("Processing :delete_complement of #{inventory_collection} of size "\
"#{all_manager_uuids_size}...")
deleted_counter = 0

inventory_collection.db_collection_for_comparison_for_complement_of(
Expand All @@ -158,8 +158,8 @@ def delete_complement
end
end

_log.info("*************** PROCESSED :delete_complement of #{inventory_collection} of size "\
"#{all_manager_uuids_size}, deleted=#{deleted_counter} *************")
_log.debug("Processing :delete_complement of #{inventory_collection} of size "\
"#{all_manager_uuids_size}, deleted=#{deleted_counter}...Complete")
end

def delete_record!(record)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def save!(association)
all_attribute_keys << :created_on if supports_created_on?
all_attribute_keys << :updated_on if supports_updated_on?

_log.info("*************** PROCESSING #{inventory_collection} of size #{inventory_collection.size} *************")
_log.debug("Processing #{inventory_collection} of size #{inventory_collection.size}...")

update_or_destroy_records!(batch_iterator(association), inventory_objects_index, attributes_index, all_attribute_keys)

Expand All @@ -80,10 +80,10 @@ def save!(association)
create_records!(all_attribute_keys, batch, attributes_index)
end
end
_log.info("*************** PROCESSED #{inventory_collection}, "\
"created=#{inventory_collection.created_records.count}, "\
"updated=#{inventory_collection.updated_records.count}, "\
"deleted=#{inventory_collection.deleted_records.count} *************")
_log.debug("Processing #{inventory_collection}, "\
"created=#{inventory_collection.created_records.count}, "\
"updated=#{inventory_collection.updated_records.count}, "\
"deleted=#{inventory_collection.deleted_records.count}...Complete")
rescue => e
_log.error("Error when saving #{inventory_collection} with #{inventory_collection_details}. Message: #{e.message}")
raise e
Expand Down
10 changes: 6 additions & 4 deletions app/models/manager_refresh/save_collection/topological_sort.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ def save_collections(ems, inventory_collections)

layers = ManagerRefresh::Graph::TopologicalSort.new(graph).topological_sort

_log.debug("Saving manager #{ems.name}...")

sorted_graph_log = "Topological sorting of manager #{ems.name} resulted in these layers processable in parallel:\n"
sorted_graph_log += graph.to_graphviz(:layers => layers)
_log.info(sorted_graph_log)
_log.debug(sorted_graph_log)

layers.each_with_index do |layer, index|
_log.info("Saving manager #{ems.name} | Layer #{index}")
_log.debug("Saving manager #{ems.name} | Layer #{index}")
layer.each do |inventory_collection|
save_inventory_object_inventory(ems, inventory_collection) unless inventory_collection.saved?
end
_log.info("Saved manager #{ems.name} | Layer #{index}")
_log.debug("Saved manager #{ems.name} | Layer #{index}")
end

_log.info("All layers of manager #{ems.name} saved!")
_log.debug("Saving manager #{ems.name}...Complete")
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions app/models/manager_refresh/save_inventory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ module ManagerRefresh
class SaveInventory
class << self
def save_inventory(ems, inventory_collections)
_log.info("#{log_header(ems)} Scanning Inventory Collections...Start")
_log.debug("#{log_header(ems)} Scanning Inventory Collections...Start")
ManagerRefresh::InventoryCollection::Scanner.scan!(inventory_collections)
_log.info("#{log_header(ems)} Scanning Inventory Collections...Complete")
_log.debug("#{log_header(ems)} Scanning Inventory Collections...Complete")

_log.info("#{log_header(ems)} Saving EMS Inventory...Start")
_log.info("#{log_header(ems)} Saving EMS Inventory...")

inventory_object_saving_strategy = Settings.ems_refresh[ems.class.ems_type].try(:[], :inventory_object_saving_strategy)
if inventory_object_saving_strategy == :recursive
Expand Down

0 comments on commit 670b776

Please sign in to comment.