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 scale_appservers_across_nodes()
    return unless my_node.is_shadow?
    Djinn.log_debug("Seeing if we need to spawn new AppServer nodes")
    nodes_needed = []
    all_scaling_requests = {}
    @apps_loaded.each { |appid|
      begin
        scaling_requests = ZKInterface.get_scaling_requests_for_app(appid)
        all_scaling_requests[appid] = scaling_requests
        ZKInterface.clear_scaling_requests_for_app(appid)
      rescue FailedZooKeeperOperationException => e
        Djinn.log_warn("(scale_appservers_across_nodes) issues talking " +
          "to zookeeper with #{e.message}.")
        next
      end
      scale_up_requests = scaling_requests.select { |item| item == "scale_up" }
      num_of_scale_up_requests = scale_up_requests.length
      if num_of_scale_up_requests > 0
        Djinn.log_debug("Login node is requesting more AppServers for app " +
          "#{appid}, so adding a node.")
        nodes_needed << ["memcache", "taskqueue_slave", "appengine"]
      end
    }
    if nodes_needed.empty?
      Djinn.log_debug("Not adding any new AppServers at this time. Checking " +
        "to see if we need to scale down.")
      return examine_scale_down_requests(all_scaling_requests)
    end
    if Time.now.to_i - @last_scaling_time < (SCALEUP_THRESHOLD *
            SCALE_TIME_MULTIPLIER * DUTY_CYCLE)
      Djinn.log_info("Not scaling up right now, as we recently scaled " +
        "up or down.")
      return 0
    end
    Djinn.log_info("Need to spawn #{nodes_needed.length} new AppServers.")
    added_nodes = start_new_roles_on_nodes(nodes_needed,
      @options['instance_type'], @@secret)
    if added_nodes != "OK"
      Djinn.log_error("Was not able to add #{nodes_needed.length} new nodes" +
        " because: #{added_nodes}")
      return 0
    end
    @last_scaling_time = Time.now.to_i
    return nodes_needed.length
  end
def scale_appservers_across_nodes ( ) return unless my_node . is_shadow? Djinn . log_debug ( "Seeing if we need to spawn new AppServer nodes" ) nodes_needed = [ ] all_scaling_requests = { } @apps_loaded . each { | appid | begin scaling_requests = ZKInterface . get_scaling_requests_for_app ( appid ) all_scaling_requests [ appid ] = scaling_requests ZKInterface . clear_scaling_requests_for_app ( appid ) rescue FailedZooKeeperOperationException => e Djinn . log_warn ( "(scale_appservers_across_nodes) issues talking " + "to zookeeper with #{e.message}." ) next end scale_up_requests = scaling_requests . select { | item | item == "scale_up" } num_of_scale_up_requests = scale_up_requests . length if num_of_scale_up_requests > 0 Djinn . log_debug ( "Login node is requesting more AppServers for app " + "#{appid}, so adding a node." ) nodes_needed << [ "memcache" , "taskqueue_slave" , "appengine" ] end } if nodes_needed . empty? Djinn . log_debug ( "Not adding any new AppServers at this time. Checking " + "to see if we need to scale down." ) return examine_scale_down_requests ( all_scaling_requests ) end if Time . now . to_i - @last_scaling_time < ( SCALEUP_THRESHOLD * SCALE_TIME_MULTIPLIER * DUTY_CYCLE ) Djinn . log_info ( "Not scaling up right now, as we recently scaled " + "up or down." ) return 0 end Djinn . log_info ( "Need to spawn #{nodes_needed.length} new AppServers." ) added_nodes = start_new_roles_on_nodes ( nodes_needed , @options [ 'instance_type' ] , @@secret ) if added_nodes != "OK" Djinn . log_error ( "Was not able to add #{nodes_needed.length} new nodes" + " because: #{added_nodes}" ) return 0 end @last_scaling_time = Time . now . to_i return nodes_needed . length 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 .
# Only the shadow makes scaling decisions. # TODO: Do we need to get the apps lock here?