lib/berkshelf/api/cache_manager.rb in berkshelf-api-1.1.1 vs lib/berkshelf/api/cache_manager.rb in berkshelf-api-1.2.0.rc1
- old
+ new
@@ -21,11 +21,11 @@
# @return [DependencyCache]
attr_reader :cache
def initialize
- log.info "Cache Manager starting..."
+ log.info "#{self} starting..."
@cache = DependencyCache.new
load_save if File.exist?(self.class.cache_file)
every(SAVE_INTERVAL) { save }
end
@@ -77,13 +77,13 @@
self.set_warmed
end
# @param [CacheBuilder::Worker::Base] worker
def process_worker(worker)
- log.info "processing #{worker}"
+ log.info "Processing #{worker}"
remote_cookbooks = worker.cookbooks
- log.info "found #{remote_cookbooks.size} cookbooks from #{worker}"
+ log.info "Found #{remote_cookbooks.size} cookbooks from #{worker}"
created_cookbooks, deleted_cookbooks = diff(remote_cookbooks, worker.priority)
log.debug "#{created_cookbooks.size} cookbooks to be added to the cache from #{worker}"
log.debug "#{deleted_cookbooks.size} cookbooks to be removed from the cache from #{worker}"
# Process metadata in chunks - Ridley cookbook resource uses a
@@ -91,21 +91,21 @@
# thread. If we have many (>2000) cookbooks we can easily
# exhaust the available threads on the system.
created_cookbooks_with_metadata = []
until created_cookbooks.empty?
work = created_cookbooks.slice!(0,500)
- log.info "processing metadata for #{work.size} cookbooks with #{created_cookbooks.size} remaining on #{worker}"
+ log.info "Processing metadata for #{work.size} cookbooks with #{created_cookbooks.size} remaining on #{worker}"
work.map! do |remote|
[ remote, worker.future(:metadata, remote) ]
end.map! do |remote, metadata|
metadata.value ? [remote, metadata.value] : nil
end
created_cookbooks_with_metadata += work.compact
end
- log.info "about to merge cookbooks"
+ log.info "About to merge cookbooks"
merge(created_cookbooks_with_metadata, deleted_cookbooks)
log.info "#{self} cache updated."
end
# Check if the cache knows about the given cookbook version
@@ -120,9 +120,14 @@
def load_save
log.info "Loading save from #{self.class.cache_file}"
@cache = DependencyCache.from_file(self.class.cache_file)
log.info "Cache contains #{@cache.cookbooks.size} items"
+ end
+
+ # @return [String]
+ def to_s
+ "Cache manager"
end
private
def merge(created_cookbooks, deleted_cookbooks)