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.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(objs) ⇒ WorkManagerData
constructor
A new instance of WorkManagerData.
- #inspect ⇒ Object
-
#processing_time ⇒ Object
return running or real processing time.
- #received!(objs) ⇒ Object
- #sent! ⇒ Object
- #stuck? ⇒ Boolean
Constructor Details
#initialize(objs) ⇒ WorkManagerData
Returns a new instance of WorkManagerData.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 30 def initialize(objs) @job_identifier=@@job_id @@job_id+=1 @data=objs sent! @received_time=0 @processing_time=nil end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
28 29 30 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 28 def data @data end |
#job_identifier ⇒ Object (readonly)
Returns the value of attribute job_identifier.
27 28 29 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 27 def job_identifier @job_identifier end |
#received_time ⇒ Object
Returns the value of attribute received_time.
28 29 30 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 28 def received_time @received_time end |
#sent_time ⇒ Object
Returns the value of attribute sent_time.
28 29 30 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 28 def sent_time @sent_time end |
#status ⇒ Object
Returns the value of attribute status.
28 29 30 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 28 def status @status end |
Class Method Details
.job_id ⇒ Object
76 77 78 79 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 76 def self.job_id # puts "Setting job_id to #{c}" @@job_id end |
.job_id=(c) ⇒ Object
71 72 73 74 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 71 def self.job_id=(c) # puts "Setting job_id to #{c}" @@job_id=c end |
Instance Method Details
#inspect ⇒ Object
66 67 68 69 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 66 def inspect time="; time: #{processing_time} seg" return "WorkManagerData: #{@job_identifier} => #{@status} #{time}" end |
#processing_time ⇒ Object
return running or real processing time
62 63 64 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 62 def processing_time return (@processing_time || (Time.now-@sent_time)) end |
#received!(objs) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 41 def received!(objs) @data=objs @received_time=Time.now @processing_time=@received_time-@sent_time # save longer processing time @@longest_processing_time=[@@longest_processing_time,@processing_time].max @status=:received end |
#sent! ⇒ Object
52 53 54 55 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 52 def sent! @status=:running @sent_time=Time.now end |
#stuck? ⇒ Boolean
57 58 59 |
# File 'lib/scbi_mapreduce/work_manager.rb', line 57 def stuck? (@status==:running) && (@@longest_processing_time>0) && (processing_time>(@@longest_processing_time*2)) end |