Class: SDBTools::Load
Instance Method Summary collapse
-
#initialize(domain, filename, logger) ⇒ Load
constructor
A new instance of Load.
- #start! ⇒ Object
- #status_filename ⇒ Object
Methods inherited from Task
#failed_items, #finish_items!, #incomplete_count, #release_working_items!, #report, #reserve_items!, #session
Constructor Details
#initialize(domain, filename, logger) ⇒ Load
Returns a new instance of Load.
156 157 158 159 160 161 162 163 |
# File 'lib/sdbtools.rb', line 156 def initialize(domain, filename, logger) @domain = domain @dump_filename = Pathname(filename) @dump_file = DumpFile.new(filename) super(status_filename, logger) { @dump_file.item_names } end |
Instance Method Details
#start! ⇒ Object
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/sdbtools.rb', line 171 def start! session do chunk = [] reserved = Set.new @dump_file.each do |item_name, attributes| if reserved.empty? finish_items!(chunk) reserved.replace(chunk = reserve_items!(chunk_size)) break if chunk.empty? end if reserved.include?(item_name) @logger.info("#{item_name} is reserved, loading to #{@domain.name}") begin @domain.put(item_name, attributes) rescue record_failed_item!( item_name, "#{$!.class.name}: #{$!.}") end reserved.delete(item_name) callback.call(item_name) end end finish_items!(chunk) end end |
#status_filename ⇒ Object
165 166 167 168 169 |
# File 'lib/sdbtools.rb', line 165 def status_filename Pathname( @dump_filename.basename(@dump_filename.extname).to_s + "-load-#{@domain.name}.simpledb_op_status") end |