Class: Kato::Instance

Inherits:
Object
  • Object
show all
Defined in:
lib/kato/pool_manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, minimum_lifetime_in_minutes = 55) ⇒ Instance

Returns a new instance of Instance.



218
219
220
221
222
223
224
225
226
# File 'lib/kato/pool_manager.rb', line 218

def initialize(id, minimum_lifetime_in_minutes = 55)
  @id = id
  @minimum_lifetime_in_minutes = minimum_lifetime_in_minutes
  @load_estimate = 0
			@last_idle_interval = 0
			@last_busy_interval = 0
			@last_report_time = Time.now
			@startup_time = Time.now
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



216
217
218
# File 'lib/kato/pool_manager.rb', line 216

def id
  @id
end

#last_busy_intervalObject

Returns the value of attribute last_busy_interval.



216
217
218
# File 'lib/kato/pool_manager.rb', line 216

def last_busy_interval
  @last_busy_interval
end

#last_idle_intervalObject

Returns the value of attribute last_idle_interval.



216
217
218
# File 'lib/kato/pool_manager.rb', line 216

def last_idle_interval
  @last_idle_interval
end

#last_report_timeObject

Returns the value of attribute last_report_time.



216
217
218
# File 'lib/kato/pool_manager.rb', line 216

def last_report_time
  @last_report_time
end

#load_estimateObject

Returns the value of attribute load_estimate.



216
217
218
# File 'lib/kato/pool_manager.rb', line 216

def load_estimate
  @load_estimate
end

#minimum_lifetime_in_minutesObject

Returns the value of attribute minimum_lifetime_in_minutes.



216
217
218
# File 'lib/kato/pool_manager.rb', line 216

def minimum_lifetime_in_minutes
  @minimum_lifetime_in_minutes
end

#startup_timeObject

Returns the value of attribute startup_time.



216
217
218
# File 'lib/kato/pool_manager.rb', line 216

def startup_time
  @startup_time
end

Instance Method Details

#minimum_lifetime_elapsed?Boolean

Returns:

  • (Boolean)


232
233
234
# File 'lib/kato/pool_manager.rb', line 232

def minimum_lifetime_elapsed?
  (Time.now - startup_time) > (minimum_lifetime_in_minutes * 60)
end

#update_loadObject



228
229
230
# File 'lib/kato/pool_manager.rb', line 228

def update_load
  @load_estimate = (last_busy_interval.to_i / (last_idle_interval.to_i + last_busy_interval.to_i).to_f * 100)
end