AppController/djinn.rb
# An Array of DjinnJobData objects, each of which containing information about
# a node in the currently running AppScale deployment.
An Array of DjinnJobData objects, each of which containing information about
a node in the currently running AppScale deployment.
An Array of DjinnJobData objects each of which containing information about a node in the currently running AppScale deployment .
def try_to_scale_down(app_name)
    if @app_info_map[app_name].nil? or @app_info_map[app_name]['appengine'].nil?
      Djinn.log_debug("Not scaling down app #{app_name}, since we aren't " +
        "hosting it anymore.")
      return
    end
    if Time.now.to_i - @last_decision[app_name] < SCALEDOWN_THRESHOLD * DUTY_CYCLE
      Djinn.log_debug("Not enough time as passed to scale down app #{app_name}")
      return
    end
    if @app_info_map[app_name]['appengine'].length <= @num_appengines
      Djinn.log_debug("We are already at the minimum number of AppServers for " +
        "#{app_name}: requesting to remove node.")
      ZKInterface.request_scale_down_for_app(app_name, my_node.private_ip)
      return
    end
    scapegoat = @app_info_map[app_name]['appengine'].sample()
    appserver_to_use, port = scapegoat.split(":")
    Djinn.log_info("Removing an AppServer from #{appserver_to_use} for #{app_name}")
    @app_info_map[app_name]['appengine'].delete("#{appserver_to_use}:#{port}")
    @last_decision[app_name] = Time.now.to_i
  end
def try_to_scale_down ( app_name ) if @app_info_map [ app_name ] . nil? or @app_info_map [ app_name ] [ 'appengine' ] . nil? Djinn . log_debug ( "Not scaling down app #{app_name}, since we aren't " + "hosting it anymore." ) return end if Time . now . to_i - @last_decision [ app_name ] < SCALEDOWN_THRESHOLD * DUTY_CYCLE Djinn . log_debug ( "Not enough time as passed to scale down app #{app_name}" ) return end if @app_info_map [ app_name ] [ 'appengine' ] . length <= @num_appengines Djinn . log_debug ( "We are already at the minimum number of AppServers for " + "#{app_name}: requesting to remove node." ) ZKInterface . request_scale_down_for_app ( app_name , my_node . private_ip ) return end scapegoat = @app_info_map [ app_name ] [ 'appengine' ] . sample ( ) appserver_to_use , port = scapegoat . split ( ":" ) Djinn . log_info ( "Removing an AppServer from #{appserver_to_use} for #{app_name}" ) @app_info_map [ app_name ] [ 'appengine' ] . delete ( "#{appserver_to_use}:#{port}" ) @last_decision [ app_name ] = Time . now . to_i end
An Array of DjinnJobData objects, each of which containing information about
a node in the currently running AppScale deployment.
An Array of DjinnJobData objects each of which containing information about a node in the currently running AppScale deployment .
# We scale only if the designed time is passed. # See how many AppServers are running on each machine. We cannot scale # if we already are at the requested minimum @num_appengines. # If we're this far, nobody can scale down, so try to remove a node instead. # We pick a randon appengine that run the application.  Smarter # algorithms could be implemented, but without clear directives (ie # decide on cpu, or memory, or number of CPU available, or avg load # etc...) any static strategy is flawed, so we go for simplicity.
app_name
<not_specific>