Class: SISFC::Request
- Inherits:
-
Object
- Object
- SISFC::Request
- Defined in:
- lib/sisfc/request.rb
Instance Attribute Summary collapse
-
#arrival_time ⇒ Object
readonly
# states STATE_WORKING = 1 STATE_SUSPENDED = 2.
-
#closure_time ⇒ Object
readonly
# states STATE_WORKING = 1 STATE_SUSPENDED = 2.
-
#customer_id ⇒ Object
readonly
# states STATE_WORKING = 1 STATE_SUSPENDED = 2.
-
#data_center_id ⇒ Object
the data_center_id attribute is updated as requests move from a Cloud data center to another.
-
#generation_time ⇒ Object
readonly
# states STATE_WORKING = 1 STATE_SUSPENDED = 2.
-
#next_step ⇒ Object
readonly
# states STATE_WORKING = 1 STATE_SUSPENDED = 2.
-
#rid ⇒ Object
readonly
# states STATE_WORKING = 1 STATE_SUSPENDED = 2.
-
#workflow_type_id ⇒ Object
readonly
# states STATE_WORKING = 1 STATE_SUSPENDED = 2.
Instance Method Summary collapse
- #closed? ⇒ Boolean
- #finished_processing(time) ⇒ Object
-
#initialize(rid:, generation_time:, initial_data_center_id:, arrival_time:, workflow_type_id:, customer_id:) ⇒ Request
constructor
A new instance of Request.
- #step_completed(duration) ⇒ Object
- #to_s ⇒ Object
- #ttr ⇒ Object
- #update_queuing_time(duration) ⇒ Object
- #update_transfer_time(duration) ⇒ Object
Constructor Details
#initialize(rid:, generation_time:, initial_data_center_id:, arrival_time:, workflow_type_id:, customer_id:) ⇒ Request
Returns a new instance of Request.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/sisfc/request.rb', line 24 def initialize(rid:, generation_time:, initial_data_center_id:, arrival_time:, workflow_type_id:, customer_id:) @rid = rid @generation_time = generation_time @data_center_id = initial_data_center_id @arrival_time = arrival_time @workflow_type_id = workflow_type_id @customer_id = customer_id # steps start counting from zero @next_step = 0 # calculate communication latency @communication_latency = @arrival_time - @generation_time @queuing_time = 0.0 @working_time = 0.0 end |
Instance Attribute Details
#arrival_time ⇒ Object (readonly)
# states STATE_WORKING = 1 STATE_SUSPENDED = 2
10 11 12 |
# File 'lib/sisfc/request.rb', line 10 def arrival_time @arrival_time end |
#closure_time ⇒ Object (readonly)
# states STATE_WORKING = 1 STATE_SUSPENDED = 2
10 11 12 |
# File 'lib/sisfc/request.rb', line 10 def closure_time @closure_time end |
#customer_id ⇒ Object (readonly)
# states STATE_WORKING = 1 STATE_SUSPENDED = 2
10 11 12 |
# File 'lib/sisfc/request.rb', line 10 def customer_id @customer_id end |
#data_center_id ⇒ Object
the data_center_id attribute is updated as requests move from a Cloud data center to another
22 23 24 |
# File 'lib/sisfc/request.rb', line 22 def data_center_id @data_center_id end |
#generation_time ⇒ Object (readonly)
# states STATE_WORKING = 1 STATE_SUSPENDED = 2
10 11 12 |
# File 'lib/sisfc/request.rb', line 10 def generation_time @generation_time end |
#next_step ⇒ Object (readonly)
# states STATE_WORKING = 1 STATE_SUSPENDED = 2
10 11 12 |
# File 'lib/sisfc/request.rb', line 10 def next_step @next_step end |
#rid ⇒ Object (readonly)
# states STATE_WORKING = 1 STATE_SUSPENDED = 2
10 11 12 |
# File 'lib/sisfc/request.rb', line 10 def rid @rid end |
#workflow_type_id ⇒ Object (readonly)
# states STATE_WORKING = 1 STATE_SUSPENDED = 2
10 11 12 |
# File 'lib/sisfc/request.rb', line 10 def workflow_type_id @workflow_type_id end |
Instance Method Details
#closed? ⇒ Boolean
65 66 67 |
# File 'lib/sisfc/request.rb', line 65 def closed? !@closure_time.nil? end |
#finished_processing(time) ⇒ Object
60 61 62 63 |
# File 'lib/sisfc/request.rb', line 60 def finished_processing(time) # save closure time @closure_time = time end |
#step_completed(duration) ⇒ Object
55 56 57 58 |
# File 'lib/sisfc/request.rb', line 55 def step_completed(duration) @working_time += duration @next_step += 1 end |
#to_s ⇒ Object
74 75 76 |
# File 'lib/sisfc/request.rb', line 74 def to_s "rid: #{@rid}, generation_time: #{@generation_time}, data_center_id: #{@data_center_id}, arrival_time: #{@arrival_time}" end |
#ttr ⇒ Object
69 70 71 72 |
# File 'lib/sisfc/request.rb', line 69 def ttr # if incident isn't closed yet, just return nil without raising an exception. @closure_time.nil? ? nil : (@closure_time - @arrival_time) end |
#update_queuing_time(duration) ⇒ Object
47 48 49 |
# File 'lib/sisfc/request.rb', line 47 def update_queuing_time(duration) @queuing_time += duration end |
#update_transfer_time(duration) ⇒ Object
51 52 53 |
# File 'lib/sisfc/request.rb', line 51 def update_transfer_time(duration) @communication_latency += duration end |