AppController/djinn.rb
# Instructs HAProxy to stop routing traffic for the named application to
# the AppServer at the given location.
#
# This method should be called at the AppController running the login role,
# as it is the only node that runs haproxy.
#
# Args:
#   app_id: A String that identifies the application that runs the AppServer
#     to remove.
#   ip: A String that identifies the private IP address where the AppServer
#     to remove runs.
#   port: A Fixnum that identifies the port where the AppServer was running
#     at ip.
#   secret: A String that is used to authenticate the caller.
#
# Returns:
#   "OK" if the removal was successful. In case of failures, the following
#   Strings may be returned:
#   - BAD_SECRET_MSG: If the caller cannot be authenticated.
#   - NO_HAPROXY_PRESENT: If this node does not run HAProxy (and thus cannot
#     remove AppServers from HAProxy config files).
Instructs HAProxy to stop routing traffic for the named application to
the AppServer at the given location.

This method should be called at the AppController running the login role,
as it is the only node that runs haproxy.

A String that identifies the application that runs the AppServer
to remove.
ip: A String that identifies the private IP address where the AppServer
to remove runs.
port: A Fixnum that identifies the port where the AppServer was running
at ip.
secret: A String that is used to authenticate the caller.

"OK" if the removal was successful. In case of failures, the following
Strings may be returned:
BAD_SECRET_MSG: If the caller cannot be authenticated.
NO_HAPROXY_PRESENT: If this node does not run HAProxy (and thus cannot
remove AppServers from HAProxy config files).
Instructs HAProxy to stop routing traffic for the named application to the AppServer at the given location . This method should be called at the AppController running the login role as it is the only node that runs haproxy . A String that identifies the application that runs the AppServer to remove . ip : A String that identifies the private IP address where the AppServer to remove runs . port : A Fixnum that identifies the port where the AppServer was running at ip . secret : A String that is used to authenticate the caller . " OK " if the removal was successful . In case of failures the following Strings may be returned : BAD_SECRET_MSG : If the caller cannot be authenticated . NO_HAPROXY_PRESENT : If this node does not run HAProxy ( and thus cannot remove AppServers from HAProxy config files ) .
def remove_appserver_from_haproxy(app_id, ip, port, secret)
    return BAD_SECRET_MSG unless valid_secret?(secret)
    unless my_node.is_shadow?
       Djinn.log_debug("Sending remote_appserver_from_haproxy call for #{app_id} to shadow.")
       acc = AppControllerClient.new(get_shadow.private_ip, @@secret)
       begin
         return acc.remove_appserver_from_haproxy(app_id, ip, port)
       rescue FailedNodeException => except
         Djinn.log_warn("Failed to forward remote_appserver_from_haproxy" +
            " call to shadow (#{get_shadow}).")
         return NOT_READY
       end
    end
    Djinn.log_info("Removing AppServer for app #{app_id} at #{ip}:#{port}")
    APPS_LOCK.synchronize {
      if @app_info_map[app_id] and @app_info_map[app_id]['appengine']
        @app_info_map[app_id]['appengine'].delete("#{ip}:#{port}")
        HAProxy.update_app_config(my_node.private_ip, app_id,
          @app_info_map[app_id])
      else
        Djinn.log_debug("AppServer #{app_id} at #{ip}:#{port} is not known.")
      end
    }
    delete_instance_from_dashboard(app_id, "#{ip}:#{port}")
    return "OK"
  end
def remove_appserver_from_haproxy ( app_id , ip , port , secret ) return BAD_SECRET_MSG unless valid_secret? ( secret ) unless my_node . is_shadow? Djinn . log_debug ( "Sending remote_appserver_from_haproxy call for #{app_id} to shadow." ) acc = AppControllerClient . new ( get_shadow . private_ip , @@secret ) begin return acc . remove_appserver_from_haproxy ( app_id , ip , port ) rescue FailedNodeException => except Djinn . log_warn ( "Failed to forward remote_appserver_from_haproxy" + " call to shadow (#{get_shadow})." ) return NOT_READY end end Djinn . log_info ( "Removing AppServer for app #{app_id} at #{ip}:#{port}" ) APPS_LOCK . synchronize { if @app_info_map [ app_id ] and @app_info_map [ app_id ] [ 'appengine' ] @app_info_map [ app_id ] [ 'appengine' ] . delete ( "#{ip}:#{port}" ) HAProxy . update_app_config ( my_node . private_ip , app_id , @app_info_map [ app_id ] ) else Djinn . log_debug ( "AppServer #{app_id} at #{ip}:#{port} is not known." ) end } delete_instance_from_dashboard ( app_id , "#{ip}:#{port}" ) return "OK" end
Instructs HAProxy to stop routing traffic for the named application to
the AppServer at the given location.
Instructs HAProxy to stop routing traffic for the named application to the AppServer at the given location .
# Tell the AppDashboard that the AppServer has been killed.
app_id
<not_specific>
ip
<not_specific>
port
<not_specific>
secret
<not_specific>