Feature #2118: Add cooldown attribute to elasticity_policies and Role.

This commit is contained in:
Carlos Martín committed 2013-06-12 16:25:12 +02:00
1 parent cb68721926
commit 8b9bf82ad4
3 files changed
+28 -22

No files matched your search

+1 -1
View File
@@ -154,7 +154,7 @@ class Strategy
if OpenNebula.is_error?(rc)
role.set_state(Role::STATE['FAILED_SCALING'])
elsif role_finished_scaling?(role)
if apply_cooldown = role.apply_cooldown_duration()
if role.apply_cooldown_duration()
role.set_state(Role::STATE['COOLDOWN'])
else
role.set_state(Role::STATE['RUNNING'])
+19 -10
View File
@@ -453,17 +453,19 @@ module OpenNebula
elasticity_pol ||= []
scheduled_pol ||= []
# TODO: Fixed duration
cooldown_duration = 60
scheduled_pol.each do |policy|
diff = scale_time?(policy)
return [diff, 0] if diff != 0
end
elasticity_pol.each do |policy|
diff = scale_attributes?(policy)
return [diff, cooldown_duration] if diff != 0
diff, cooldown_duration = scale_attributes?(policy)
if diff != 0
cooldown_duration = @body['cooldown'] if cooldown_duration.nil?
cooldown_duration = 0 if cooldown_duration.nil?
return [diff, cooldown_duration]
end
end
return [0, 0]
@@ -535,7 +537,8 @@ module OpenNebula
# Returns a positive, 0, or negative number of nodes to adjust,
# according to a policy based on attributes
# @param [Hash] A policy based on attributes
# @return [Integer] positive, 0, or negative number of nodes to adjust
# @return [Array<Integer>] positive, 0, or negative number of nodes to
# adjust, plus the cooldown period duration
def scale_attributes?(elasticity_pol)
now = Time.now.to_i
@@ -552,7 +555,7 @@ module OpenNebula
if now < (last_eval + period_duration)
Log.debug "ELAS", "Role #{name} expression '#{expression}' evaluation ignored, time < period"
return 0
return [0, 0]
end
end
@@ -576,7 +579,7 @@ module OpenNebula
elasticity_pol['true_evals'] = new_evals
return new_cardinality - cardinality()
return [new_cardinality - cardinality(), elasticity_pol['cooldown']]
end
# Returns true if the scalability rule is triggered
@@ -732,8 +735,14 @@ module OpenNebula
def apply_cooldown_duration()
cooldown_duration = @body['cooldown_duration'].to_i
@body['cooldown_end'] = Time.now + cooldown_duration
@body.delete('cooldown_duration')
if cooldown_duration != 0
@body['cooldown_end'] = Time.now.to_i + cooldown_duration
@body.delete('cooldown_duration')
return true
end
return false
end
# Returns true if the cooldown period ended
+8 -11
View File
@@ -42,13 +42,14 @@ module OpenNebula
:type => :integer,
:default => 1
},
#'cooldown' => {
# :type => :integer
#}
'max_vms' => {
:type => :integer,
:required => false
},
'cooldown' => {
:type => :integer,
:required => false
},
'elasticity_policies' => {
:type => :array,
:items => {
@@ -79,11 +80,11 @@ module OpenNebula
'expression' => {
:type => :string,
:required => false
},
'cooldown' => {
:type => :integer,
:required => false
}
#'cooldown' => {
# :type => :integer
#}
#'statistic' => {
# # SampleCount | Average | Sum | Minimum | Maximum
# :type => :string
@@ -117,10 +118,6 @@ module OpenNebula
:type => :string,
:required => false
}
#'cooldown' => {
# :type => :integer
#}
}
}
}