Class: ScbiMapreduce::WorkManagerData
- Inherits:
-
Object
- Object
- ScbiMapreduce::WorkManagerData
- Defined in:
- lib/scbi_mapreduce/work_manager.rb
Constant Summary collapse
- @@job_id =
1
- @@longest_processing_time =
0
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#job_identifier ⇒ Object
readonly
Returns the value of attribute job_identifier.
-
#received_time ⇒ Object
Returns the value of attribute received_time.
-
#sent_time ⇒ Object
Returns the value of attribute sent_time.
-
#status ⇒ Object
Returns the value of attribute status.
-
#worker_end_time ⇒ Object
Returns the value of attribute worker_end_time.
-
#worker_identifier ⇒ Object
Returns the value of attribute worker_identifier.
-
#worker_start_time ⇒ Object
Returns the value of attribute worker_start_time.
-
#working_time ⇒ Object
Returns the value of attribute working_time.
Class Method Summary collapse
Instance Method Summary collapse
- #end_worker_time! ⇒ Object
-
#initialize(objs) ⇒ WorkManagerData
constructor
A new instance of WorkManagerData.
- #inspect ⇒ Object
- #print_worker_time ⇒ Object
-
#processing_time ⇒ Object
return running or real processing time.
- #received!(objs) ⇒ Object
- #sent! ⇒ Object
- #start_worker_time! ⇒ Object
- #stuck? ⇒ Boolean
- #transmission_time ⇒ Object
- #update_with_received!(job) ⇒ Object
- #worker_time ⇒ Object
Constructor Details
#initialize(objs) ⇒ WorkManagerData
Returns a new instance of WorkManagerData.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 32 def initialize(objs) @worker_identifier=0 @job_identifier=@@job_id @@job_id+=1 @data=objs @received_time=nil @sent_time=0 @processing_time=nil @worker_start_time=0 @worker_end_time=0 @worker_time=0 sent! end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def data @data end |
#job_identifier ⇒ Object (readonly)
Returns the value of attribute job_identifier.
29 30 31 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 29 def job_identifier @job_identifier end |
#received_time ⇒ Object
Returns the value of attribute received_time.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def received_time @received_time end |
#sent_time ⇒ Object
Returns the value of attribute sent_time.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def sent_time @sent_time end |
#status ⇒ Object
Returns the value of attribute status.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def status @status end |
#worker_end_time ⇒ Object
Returns the value of attribute worker_end_time.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def worker_end_time @worker_end_time end |
#worker_identifier ⇒ Object
Returns the value of attribute worker_identifier.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def worker_identifier @worker_identifier end |
#worker_start_time ⇒ Object
Returns the value of attribute worker_start_time.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def worker_start_time @worker_start_time end |
#working_time ⇒ Object
Returns the value of attribute working_time.
30 31 32 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def working_time @working_time end |
Class Method Details
.job_id ⇒ Object
131 132 133 134 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 131 def self.job_id # puts "Setting job_id to #{c}" @@job_id end |
.job_id=(c) ⇒ Object
126 127 128 129 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 126 def self.job_id=(c) # puts "Setting job_id to #{c}" @@job_id=c end |
Instance Method Details
#end_worker_time! ⇒ Object
85 86 87 88 89 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 85 def end_worker_time! @worker_end_time=Time.now_us @worker_time= (@worker_end_time - @worker_start_time) end |
#inspect ⇒ Object
117 118 119 120 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 117 def inspect time="; time: #{processing_time} usecs" return "WorkManagerData: #{@job_identifier} => #{@status} #{time}" end |
#print_worker_time ⇒ Object
122 123 124 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 122 def print_worker_time return "WorkManagerData Times: #{@worker_start_time} => #{@worker_end_time} #{worker_time}" end |
#processing_time ⇒ Object
return running or real processing time
105 106 107 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 105 def processing_time return (@processing_time || (Time.now_us-@sent_time)) end |
#received!(objs) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 70 def received!(objs) @received_time=Time.now_us @processing_time=@received_time-@sent_time @worker_time=@worker_end_time-@worker_start_time # save longer processing time @@longest_processing_time=[@@longest_processing_time,@processing_time].max @data=objs @status=:received end |
#sent! ⇒ Object
95 96 97 98 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 95 def sent! @status=:running @sent_time=Time.now_us end |
#start_worker_time! ⇒ Object
91 92 93 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 91 def start_worker_time! @worker_start_time=Time.now_us end |
#stuck? ⇒ Boolean
100 101 102 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 100 def stuck? (@status==:running) && (@@longest_processing_time>0) && (processing_time>(@@longest_processing_time*PROCESSING_TIMEOUT_MULTIPLIER)) end |
#transmission_time ⇒ Object
113 114 115 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 113 def transmission_time return (processing_time - worker_time) end |
#update_with_received!(job) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 49 def update_with_received!(job) @received_time=job.received_time @sent_time=job.sent_time @worker_end_time=job.worker_end_time @worker_start_time=job.worker_start_time @processing_time=@received_time-@sent_time @worker_time=@worker_end_time-@worker_start_time # save longer processing time @@longest_processing_time=[@@longest_processing_time,@processing_time].max @data=job.data # if job.worker_identifier==0 # puts print_worker_time # end @status=:received end |
#worker_time ⇒ Object
109 110 111 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 109 def worker_time return (@worker_time) end |