Module: MapReduce::File

Defined in:
lib/map_reduce/file.rb

Defined Under Namespace

Classes: Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#empty_queue_waitObject

Returns the value of attribute empty_queue_wait.



3
4
5
# File 'lib/map_reduce/file.rb', line 3

def empty_queue_wait
  @empty_queue_wait
end

#lines_per_clientObject

Returns the value of attribute lines_per_client.



3
4
5
# File 'lib/map_reduce/file.rb', line 3

def lines_per_client
  @lines_per_client
end

#locked_queue_waitObject

Returns the value of attribute locked_queue_wait.



3
4
5
# File 'lib/map_reduce/file.rb', line 3

def locked_queue_wait
  @locked_queue_wait
end

#queue_sizeObject

Returns the value of attribute queue_size.



3
4
5
# File 'lib/map_reduce/file.rb', line 3

def queue_size
  @queue_size
end

#rescan_when_completeObject

Returns the value of attribute rescan_when_complete.



3
4
5
# File 'lib/map_reduce/file.rb', line 3

def rescan_when_complete
  @rescan_when_complete
end

#vigilantObject

Returns the value of attribute vigilant.



3
4
5
# File 'lib/map_reduce/file.rb', line 3

def vigilant
  @vigilant
end

Instance Method Details

#get_linesObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/map_reduce/file.rb', line 25

def get_lines
  t = Time.now
  
  lines = []
  (@lines_per_client || 1).times do
    begin
      if @lock
        sleep locked_queue_wait || 1
        retry
      else
        if line = queue.shift
          lines << line
        else
          sleep empty_queue_wait || 30
          retry
        end
      end
    rescue MapReduceError
      retry
    end
  end

  @time_spent_grabbing_objects += (Time.now - t)
  @num_objects_grabbed += 1

  return lines.join
end