Class: ScbiMapreduce::WorkManager
- Inherits:
-
Object
- Object
- ScbiMapreduce::WorkManager
show all
- Defined in:
- lib/full_lengther_next/my_worker_manager_fln.rb
Instance Method Summary
collapse
Instance Method Details
#send_next_work ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/full_lengther_next/my_worker_manager_fln.rb', line 13
def send_next_work
sleep = false
if @@want_to_exit
send_object(:quit)
elsif !send_stuck_work
objs=[]
t=Time.now_us
begin
@@chunk_size.times do
obj=next_work
if obj.nil?
break
elsif obj == :sleep
sleep = true
break
else
objs << obj
end
end
rescue Exception => e
$SERVER_LOG.error("Exception creating next_work. Worker, quit!")
$SERVER_LOG.error("#{e.message}\n#{e.backtrace.join("\n")}")
send_object(:sleep)
self.class.global_error_received(e)
end
@@total_read_time+=(Time.now_us - t)
if objs.count>0
@@count += objs.count
@@chunk_count += 1
work_data=WorkManagerData.new(objs)
send_object(work_data)
@@sent_chunks+=1
if @@keep_order || @@retry_stuck_jobs
@@running_jobs.push work_data
end
else
if @@running_jobs.count >0 || sleep
$SERVER_LOG.info("Worker, go to sleep")
send_object(:sleep)
else
send_object(:quit)
end
end
end
end
|