Changeset 1587

Show
Ignore:
Timestamp:
05/21/08 18:45:50 (3 months ago)
Author:
kindlund
Message:

Updated get_new_queue_urls() call; when URLs are selected and about to be assigned to a given host, we checked to make sure that no other host had already been assigned them. Before, when such an issue occurred, we simply rolled back the transaction and asked the Manager to try again. Now, we try to figure out what of the originally selected URLs were successfully assigned to the Manager, and only return that set.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • hive/trunk/data_webapp/app/controllers/hc_database_controller.rb

    r1575 r1587  
    348348      QueueUrl.transaction do 
    349349        # Lock URLs to prevent duplication of work, by setting host_id (!=0). 
    350         if (QueueUrl.update_all('host_id='+host.id.to_s,'id IN ('+urls.map(&:id).join(',')+') AND (host_id=0)') != urls.length) 
    351           urls = [] 
    352           logger.warn "get_new_queue_urls(): collision detected - rolling back" 
    353           raise ActiveRecord::Rollback 
     350        num_urls_updated = QueueUrl.update_all('host_id='+host.id.to_s,'id IN ('+urls.map(&:id).join(',')+') AND (host_id=0)') 
     351        if (num_urls_updated != urls.length) 
     352          # TODO: Clean this up. 
     353          #urls = [] 
     354          #logger.warn "get_new_queue_urls(): collision detected - rolling back" 
     355          num_overlap = urls.length - num_urls_updated 
     356          logger.warn "get_new_queue_urls(): Overlap detected - (" + num_overlap.to_s + ") URLs already assigned." 
     357          # Okay, there's overlap, so only return the set of URLs that we successfully updated. 
     358          urls = QueueUrl.find(:all, 
     359            :conditions => {:host_id => host.id, :id => urls.map(&:id)}) 
     360          # TODO: Clean this up. 
     361          #raise ActiveRecord::Rollback 
    354362        end 
    355363      end