Class: ContentData::ContentData

Inherits:
Object
  • Object
show all
Defined in:
lib/content_data/content_data.rb

Overview

Content Data(CD) object holds files information as contents and instances Files info retrieved from hardware: checksum, size, time modification, server, device and path Those attributes are divided into content and instance attributes:

unique checksum, size are content attributes
time modification, server, device and path are instance attributes

The relationship between content and instances is 1:many meaning that a content can have instances in many servers. content also has time attribute, which has the value of the time of the first instance. This can be changed by using unify_time method which sets all time attributes for a content and it’s instances to the min time off all. Different files(instances) with same content(checksum), are grouped together under that content. Interface methods include:

iterate over contents and instances info,
unify time, add/remove instance, queries, merge, remove directory and more.

Content info data structure:

@contents_info = { Checksum -> [size, *instances*, content_modification_time] }
  *instances* = {[server,path] -> [instance_modification_time,index_time] }

Notes:

1. content_modification_time is the instance_modification_time of the first
   instances which was added to @contents_info

Constant Summary collapse

CHUNK_SIZE =
5000

Instance Method Summary collapse

Constructor Details

#initialize(other = nil) ⇒ ContentData

Returns a new instance of ContentData.



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/content_data/content_data.rb', line 34

def initialize(other = nil)
  if other.nil?
    @contents_info = {}  # Checksum --> [size, paths-->time(instance), time(content)]
    @instances_info = {}  # location --> checksum to optimize instances query
    @symlinks_info = {}  # [server,symlink path] -> target
  else
    @contents_info = other.clone_contents_info
    @instances_info = other.clone_instances_info  # location --> checksum to optimize instances query
    @symlinks_info =  other.clone_symlinks_info
  end
end

Instance Method Details

#==(other) ⇒ Object



280
281
282
283
# File 'lib/content_data/content_data.rb', line 280

def ==(other)
  return nil if other.nil?  # for this case: content_data == nil
  unique_id  == other.unique_id
end

#add_instance(checksum, size, server, path, modification_time, index_time = Time.now.to_i) ⇒ Object



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/content_data/content_data.rb', line 183

def add_instance(checksum, size, server, path, modification_time, index_time=Time.now.to_i)
  location = [server, path]

  # file was changed but remove_instance was not called
  if (@instances_info.include?(location) && @instances_info[location] != checksum)
    Log.warning("#{server}:#{path} file already exists with different checksum")
    remove_instance(server, path)
  end

   = @contents_info[checksum]
  if .nil?
    @contents_info[checksum] = [size,
                                {location => [modification_time,index_time]},
                                modification_time]
  else
    if size != [0]
      Log.warning('File size different from content size while same checksum')
      Log.warning("instance location:server:'#{location[0]}'  path:'#{location[1]}'")
      Log.warning("instance mod time:'#{modification_time}'")
    end
    #override file if needed
    [0] = size
    instances = [1]
    instances[location] = [modification_time, index_time]
  end
  @instances_info[location] = checksum
end


211
212
213
# File 'lib/content_data/content_data.rb', line 211

def add_symlink(server, path, target)
  @symlinks_info[[server,path]] = target
end

#checksum_instances_size(checksum) ⇒ Object



169
170
171
172
173
# File 'lib/content_data/content_data.rb', line 169

def checksum_instances_size(checksum)
   = @contents_info[checksum]
  return 0 if .nil?
  [1].length
end

#clone_contents_infoObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/content_data/content_data.rb', line 62

def clone_contents_info
  clone_contents_info = {}
  contents_info_enum = @contents_info.each_key
  loop {
    checksum = contents_info_enum.next rescue break
    instances = @contents_info[checksum]
    size = instances[0]
    content_time = instances[2]
    instances_db = instances[1]
    instances_db_cloned = {}
    instances_db_enum = instances_db.each_key
    loop {
      location =  instances_db_enum.next rescue break
      inst_mod_times = instances_db[location]
      # we use deep clone for location since map key is using shallow clone.
      # we dont want references between new content data
      # and orig object. This will help the GC dispose the orig object if not used any more.
      instances_db_cloned[[location[0].clone,location[1].clone]] = inst_mod_times.clone
    }
    clone_contents_info[checksum] = [size,
                          instances_db_cloned,
                          content_time]
  }
  clone_contents_info
end

#clone_instances_infoObject



52
53
54
55
56
57
58
59
60
# File 'lib/content_data/content_data.rb', line 52

def clone_instances_info
  clone_instances_info = {}
  instances_info_enum = @instances_info.each_key
  loop {
    location = instances_info_enum.next rescue break
    clone_instances_info[[location[0].clone, location[1].clone]] = @instances_info[location].clone
  }
  clone_instances_info
end


88
89
90
91
92
93
94
95
96
# File 'lib/content_data/content_data.rb', line 88

def clone_symlinks_info
  symlinks_info_enum = @symlinks_info.each_key
  cloned_symlinks = {}
  loop {
    symlink_key = symlinks_info_enum.next rescue break
    cloned_symlinks[[symlink_key[0].clone, symlink_key[0].clone]] = @symlinks_info[symlink_key].clone
  }
  cloned_symlinks
end

#content_each_instance(checksum, &block) ⇒ Object

iterator of instances over specific content block is provided with: checksum, size, content modification time,

instance modification time, server and file path


133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/content_data/content_data.rb', line 133

def content_each_instance(checksum, &block)
   = @contents_info[checksum]
  instances_db_enum = [1].each_key
  loop {
    location = instances_db_enum.next rescue break
    # provide the block with: checksum, size, content modification time,instance modification time,
    #   server and path.
    inst_mod_time,_ = [1][location]
    block.call(checksum,[0], [2], inst_mod_time,
               location[0], location[1])
  }
end

#content_exists(checksum) ⇒ Object



223
224
225
# File 'lib/content_data/content_data.rb', line 223

def content_exists(checksum)
  @contents_info.has_key?(checksum)
end

#contents_sizeObject



157
158
159
# File 'lib/content_data/content_data.rb', line 157

def contents_size()
  @contents_info.length
end

#each_content(&block) ⇒ Object

iterator over @contents_info data structure (not including instances) block is provided with: checksum, size and content modification time



100
101
102
103
104
105
106
107
108
# File 'lib/content_data/content_data.rb', line 100

def each_content(&block)
  contents_enum = @contents_info.each_key
  loop {
    checksum = contents_enum.next rescue break
    content_val = @contents_info[checksum]
    # provide checksum, size and content modification time to the block
    block.call(checksum,content_val[0], content_val[2])
  }
end

#each_instance(&block) ⇒ Object

iterator over @contents_info data structure (including instances) block is provided with: checksum, size, content modification time,

instance modification time, server and file path


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/content_data/content_data.rb', line 113

def each_instance(&block)
  contents_enum = @contents_info.each_key
  loop {
    checksum = contents_enum.next rescue break
     = @contents_info[checksum]
     = [1].each_key
    loop {
      location = .next rescue break
      # provide the block with: checksum, size, content modification time,instance modification time,
      #   server and path.
      inst_mod_time, inst_index_time = [1][location]
      block.call(checksum,[0], [2], inst_mod_time,
                 location[0], location[1], inst_index_time)
    }
  }
end

iterator over @symlinks_info data structure block is provided with: server, file path and target



148
149
150
151
152
153
154
155
# File 'lib/content_data/content_data.rb', line 148

def each_symlink(&block)
  symlink_enum = @symlinks_info.each_key
  loop {
    symlink_key = symlink_enum.next rescue break
    symlink_target = @symlinks_info[symlink_key]
    block.call(symlink_key[0], symlink_key[1], symlink_target)
  }
end

#empty?Boolean

Returns:

  • (Boolean)


219
220
221
# File 'lib/content_data/content_data.rb', line 219

def empty?
  @contents_info.empty? and @symlinks_info.empty?
end

#from_file(filename) ⇒ Object

TODO validation that file indeed contains ContentData missing TODO class level method? Loading db from file using chunks for better memory performance



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
# File 'lib/content_data/content_data.rb', line 383

def from_file(filename)
  # read first line (number of contents)
  # calculate line number (number of instances)
  # read number of instances.
  # loop over instances lines (using chunks) and add instances

  unless File.exists? filename
    raise ArgumentError.new "No such a file #{filename}"
  end

  File.open(filename, 'r') { |file|
    # Get number of contents (at first line)
    number_of_contents = file.gets  # this gets the next line or return nil at EOF
    unless (number_of_contents and number_of_contents.match(/^[\d]+$/))  # check that line is of Number format
      raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
            "number of contents should be a number. We got:#{number_of_contents}")
    end
    number_of_contents = number_of_contents.to_i
    # advance file lines over all contents. We need only the instances data to build the content data object
    # use chunks and GC
    contents_chunks = number_of_contents / CHUNK_SIZE
    contents_chunks += 1 if (contents_chunks * CHUNK_SIZE < number_of_contents)
    chunk_index = 0
    while chunk_index < contents_chunks
      chunk_size = CHUNK_SIZE
      if chunk_index + 1 == contents_chunks
        # update last chunk size
        chunk_size = number_of_contents - (chunk_index * CHUNK_SIZE)
      end
      return unless read_contents_chunk(filename, file, chunk_size)
      GC.start
      chunk_index += 1
    end

    # get number of instances
    number_of_instances = file.gets
    unless (number_of_instances and number_of_instances.match(/^[\d]+$/))  # check that line is of Number format
      raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
            "number of instances should be a Number. We got:#{number_of_instances}")
    end
    number_of_instances = number_of_instances.to_i
    # read in instances chunks and GC
    instances_chunks = number_of_instances / CHUNK_SIZE
    instances_chunks += 1 if (instances_chunks * CHUNK_SIZE < number_of_instances)
    chunk_index = 0
    while chunk_index < instances_chunks
      chunk_size = CHUNK_SIZE
      if chunk_index + 1 == instances_chunks
        # update last chunk size
        chunk_size = number_of_instances - (chunk_index * CHUNK_SIZE)
      end
      return unless read_instances_chunk(filename, file, chunk_size)
      GC.start
      chunk_index += 1
    end

    # get number of symlinks
    number_of_symlinks = file.gets
    unless (number_of_symlinks and number_of_symlinks.match(/^[\d]+$/))  # check that line is of Number format
      raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
                "number of symlinks should be a Number. We got:#{number_of_symlinks}")
    end
    number_of_symlinks.to_i.times {
      symlinks_line = file.gets
      unless symlinks_line
        raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
               "Expected to read symlink line but reached EOF")
      end
      parameters = symlinks_line.split('<')
      if (3 != parameters.length)
        raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
              "Expected to read 3 fields ('<' separated) but got #{parameters.length}.\nLine:#{symlinks_line}")
      end

      @symlinks_info[[parameters[0],parameters[1]]] = parameters[2]
    }
  }
end

#get_instance_mod_time(checksum, location) ⇒ Object



175
176
177
178
179
180
181
# File 'lib/content_data/content_data.rb', line 175

def get_instance_mod_time(checksum, location)
   = @contents_info[checksum]
  return nil if .nil?
  instances = [1]
  instance_time,_ = instances[location]
  instance_time
end

#get_query(variable, params) ⇒ Object

TODO simplify conditions This mehod is experimental and shouldn't be used nil is used to define +/- infinity for to/from method arguments from/to values are exlusive in condition’a calculations Need to take care about ‘==’ operation that is used for object’s comparison. In need of case user should define it’s own ‘==’ implemementation.



664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
# File 'lib/content_data/content_data.rb', line 664

def get_query(variable, params)
  raise RuntimeError.new 'This method is experimental and shouldn\'t be used'

  exact = params['exact'].nil? ? Array.new : params['exact']
  from = params['from']
  to = params ['to']
  is_inside = params['is_inside']

  unless ContentInstance.new.instance_variable_defined?("@#{attribute}")
    raise ArgumentError "#{variable} isn't a ContentInstance variable"
  end

  if (exact.nil? && from.nil? && to.nil?)
    raise ArgumentError 'At least one of the argiments {exact, from, to} must be defined'
  end

  if (!(from.nil? || to.nil?) && from.kind_of?(to.class))
    raise ArgumentError 'to and from arguments should be comparable one with another'
  end

  # FIXME add support for from/to for Strings
  if ((!from.nil? && !from.kind_of?(Numeric.new.class))\
        || (!to.nil? && to.kind_of?(Numeric.new.class)))
    raise ArgumentError 'from and to options supported only for numeric values'
  end

  if (!exact.empty? && (!from.nil? || !to.nil?))
    raise ArgumentError 'exact and from/to options are mutually exclusive'
  end

  result_index = ContentData.new
  instances.each_value do |instance|
    is_match = false
    var_value = instance.instance_variable_get("@#{variable}")

    if exact.include? var_value
      is_match = true
    elsif (from.nil? || var_value > from) && (to.nil? || var_value < to)
      is_match = true
    end

    if (is_match && is_inside) || (!is_match && !is_inside)
      checksum = instance.checksum
      result_index.add_content(contents[checksum]) unless result_index.content_exists(checksum)
      result_index.add_instance instance
    end
  end
  result_index
end

#instance_exists(path, server) ⇒ Object



227
228
229
# File 'lib/content_data/content_data.rb', line 227

def instance_exists(path, server)
  @instances_info.has_key?([server, path])
end

#instances_sizeObject



161
162
163
# File 'lib/content_data/content_data.rb', line 161

def instances_size()
  @instances_info.length
end

#read_contents_chunk(filename, file, chunk_size) ⇒ Object



462
463
464
465
466
467
468
469
470
471
472
# File 'lib/content_data/content_data.rb', line 462

def read_contents_chunk(filename, file, chunk_size)
  chunk_index = 0
  while chunk_index < chunk_size
    unless file.gets
      raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
            "Expecting content line but reached end of file")
    end
    chunk_index += 1
  end
  true
end

#read_instances_chunk(filename, file, chunk_size) ⇒ Object



474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/content_data/content_data.rb', line 474

def read_instances_chunk(filename, file, chunk_size)
  chunk_index = 0
  while chunk_index < chunk_size
    instance_line = file.gets
    unless instance_line
      raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
            "Expected to read Instance line but reached EOF")
    end

    parameters = instance_line.split('<')
    if (6 != parameters.length)
      raise("Parse error of content data file:#{filename}  line ##{$.}\n" +
                "Expected to read 6 fields ('<' separated) but got #{parameters.length}.\nLine:#{instance_line}")
    end
    add_instance(parameters[0],        #checksum
                 parameters[1].to_i,   # size
                 parameters[2],        # server
                 parameters[3],        # path
                 parameters[4].to_i,   # mod time
                 parameters[5].to_i)   # index time
    chunk_index += 1
  end
  true
end

#remove_content(checksum) ⇒ Object



285
286
287
288
289
290
291
292
293
# File 'lib/content_data/content_data.rb', line 285

def remove_content(checksum)
   = @contents_info[checksum]
  if 
    [1].each_key { |location|
      @instances_info.delete(location)
    }
    @contents_info.delete(checksum)
  end
end

#remove_directory(dir_to_remove, server) ⇒ Object

removes all instances records which are located under input param: dir_to_remove. found records are removed from @contents_info , @instances_info and @symlinks_info input params: server & dir_to_remove - are used to check each instance unique key (called location) removes also contents, if a contents becomes empty after removing instances



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/content_data/content_data.rb', line 254

def remove_directory(dir_to_remove, server)
  contents_enum = @contents_info.each_key
  loop {
    checksum = contents_enum.next rescue break
    instances =  @contents_info[checksum][1]
    instances_enum = instances.each_key
    loop {
      location = instances_enum.next rescue break
      if location[0] == server and location[1].scan(dir_to_remove).size > 0
        instances.delete(location)
        @instances_info.delete(location)
      end
    }
    @contents_info.delete(checksum) if instances.empty?
  }

  # handle symlinks
  symlinks_enum = @symlinks_info.each_key
  loop {
    symlink_key = symlinks_enum.next rescue break
    if symlink_key[0] == server and symlink_key[1].scan(dir_to_remove).size > 0
      @symlinks_info.delete(symlink_key)
    end
  }
end

#remove_instance(server, path) ⇒ Object

removes an instance record both in @instances_info and @instances_info. input params: server & path - are the instance unique key (called location) removes also the content, if content becomes empty after removing the instance



239
240
241
242
243
244
245
246
247
248
# File 'lib/content_data/content_data.rb', line 239

def remove_instance(server, path)
  location = [server, path]
  checksum = @instances_info[location]
   = @contents_info[checksum]
  return nil if .nil?
  instances = [1]
  instances.delete(location)
  @contents_info.delete(checksum) if instances.empty?
  @instances_info.delete(location)
end


215
216
217
# File 'lib/content_data/content_data.rb', line 215

def remove_symlink(server, path)
  @symlinks_info.delete([server,path])
end


231
232
233
# File 'lib/content_data/content_data.rb', line 231

def symlink_exists(path, server)
  @symlinks_info.has_key?([server, path])
end


165
166
167
# File 'lib/content_data/content_data.rb', line 165

def symlinks_size()
  @symlinks_info.length
end

#to_file(filename) ⇒ Object

Write content data to file. Write is using chunks (for both content chunks and instances chunks) Chunk is used to maximize GC affect. The temporary memory of each chunk is GCed. Without the chunks used in a dipper stack level, GC keeps the temporary objects as part of the stack context.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/content_data/content_data.rb', line 316

def to_file(filename)
  content_data_dir = File.dirname(filename)
  FileUtils.makedirs(content_data_dir) unless File.directory?(content_data_dir)
  File.open(filename, 'w') { |file|
    # Write contents
    file.write("#{@contents_info.length}\n")
    contents_enum = @contents_info.each_key
    content_chunks = @contents_info.length / CHUNK_SIZE + 1
    chunks_counter = 0
    while chunks_counter < content_chunks
      to_file_contents_chunk(file,contents_enum, CHUNK_SIZE)
      GC.start
      chunks_counter += 1
    end

    # Write instances
    file.write("#{@instances_info.length}\n")
    contents_enum = @contents_info.each_key
    chunks_counter = 0
    while chunks_counter < content_chunks
      to_file_instances_chunk(file,contents_enum, CHUNK_SIZE)
      GC.start
      chunks_counter += 1
    end

    # Write symlinks
    symlinks_info_enum = @symlinks_info.each_key
    file.write("#{@symlinks_info.length}\n")
    loop {
      symlink_key = symlinks_info_enum.next rescue break
      file.write("#{symlink_key[0]}<#{symlink_key[1]}<#{@symlinks_info[symlink_key]}\n")
    }
  }
end

#to_file_contents_chunk(file, contents_enum, chunk_size) ⇒ Object



351
352
353
354
355
356
357
358
359
# File 'lib/content_data/content_data.rb', line 351

def to_file_contents_chunk(file, contents_enum, chunk_size)
  chunk_counter = 0
  while chunk_counter < chunk_size
    checksum = contents_enum.next rescue return
     = @contents_info[checksum]
    file.write("#{checksum}<#{[0]}<#{[2]}\n")
    chunk_counter += 1
  end
end

#to_file_instances_chunk(file, contents_enum, chunk_size) ⇒ Object



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
# File 'lib/content_data/content_data.rb', line 361

def to_file_instances_chunk(file, contents_enum, chunk_size)
  chunk_counter = 0
  while chunk_counter < chunk_size
    checksum = contents_enum.next rescue return
     = @contents_info[checksum]
    instances_db_enum = [1].each_key
    loop {
      location = instances_db_enum.next rescue break
      # provide the block with: checksum, size, content modification time,instance modification time,
      #   server and path.
      instance_modification_time,instance_index_time = [1][location]
      file.write("#{checksum}<#{[0]}<#{location[0]}<#{location[1]}<" +
                 "#{instance_modification_time}<#{instance_index_time}\n")
    }
    chunk_counter += 1
    break if chunk_counter == chunk_size
  end
end

#to_sObject



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/content_data/content_data.rb', line 295

def to_s
  return_str = ""
  contents_str = ""
  instances_str = ""
  each_content { |checksum, size, content_mod_time|
    contents_str << "%s,%d,%d\n" % [checksum, size, content_mod_time]
  }
  each_instance { |checksum, size, content_mod_time, instance_mod_time, server, path|
    instances_str <<  "%s,%d,%s,%s,%d\n" % [checksum, size, server, path, instance_mod_time]
  }
  return_str << "%d\n" % [@contents_info.length]
  return_str << contents_str
  return_str << "%d\n" % [@instances_info.length]
  return_str << instances_str
  return_str
end

#unify_timeObject

for each content, all time fields (content and instances) are replaced with the min time found, while going through all time fields.



501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/content_data/content_data.rb', line 501

def unify_time()
  contents_enum = @contents_info.each_key
  loop {
    checksum = contents_enum.next rescue break
     = @contents_info[checksum]
    min_time_per_checksum = [2]
    instances = [1]
    instances_enum = instances.each_key
    loop {
      location = instances_enum.next rescue break
      instance_mod_time = instances[location][0]
      if instance_mod_time < min_time_per_checksum
        min_time_per_checksum = instance_mod_time
      end
    }
    # update all instances with min time
    instances_enum = instances.each_key
    loop {
      location = instances_enum.next rescue break
      instances[location][0] = min_time_per_checksum
    }
    # update content time with min time
    [2] = min_time_per_checksum
  }
end

#unique_idID

Content Data unique identification

Returns:

  • (ID)

    hash identification



48
49
50
# File 'lib/content_data/content_data.rb', line 48

def unique_id
  [@contents_info.hash,@symlinks_info.hash]
end

#validate(params = nil) ⇒ Boolean

Validates index against file system that all instances hold a correct data regarding files that they represents.

There are two levels of validation, controlled by instance_check_level system parameter:

  • shallow - quick, tests instance for file existence and attributes.

  • deep - can take more time, in addition to shallow recalculates hash sum.

Parameters:

  • params (Hash) (defaults to: nil)

    hash of parameters of validation, can be used to return additional data.

    Supported key/value combinations:

    • key is :failed value is ContentData used to return failed instances

Returns:

  • (Boolean)

    true when index is correct, false otherwise

Raises:

  • (ArgumentError)

    when instance_check_level is incorrect



539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# File 'lib/content_data/content_data.rb', line 539

def validate(params = nil)
  # used to answer whether specific param was set
  param_exists = Proc.new do |param|
    !(params.nil? || params[param].nil?)
  end

  # used to process method parameters centrally
  process_params = Proc.new do |values|
    if param_exists.call(:failed)
      info = values[:details]
      unless info.nil?
        checksum = info[0]
        content_mtime = info[1]
        size = info[2]
        inst_mtime = info[3]
        server = info[4]
        file_path = info[5]
        params[:failed].add_instance(checksum, size, server, file_path, inst_mtime)
      end
    end
  end

  is_valid = true
  contents_enum = @contents_info.each_key
  loop {
    checksum = contents_enum.next rescue break
    instances = @contents_info[checksum]
    content_size = instances[0]
    content_mtime = instances[2]
    instances_enum = instances[1].each_key
    loop {
      unique_path = instances_enum.next rescue break
      instance_mtime = instances[1][unique_path][0]
      instance_info = [checksum, content_mtime, content_size, instance_mtime]
      instance_info.concat(unique_path)
      unless check_instance(instance_info)
        is_valid = false

        unless params.nil? || params.empty?
          process_params.call({:details => instance_info})
        end
      end
    }
  }
  is_valid
end