Class EurekaServletHandler

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    public class EurekaServletHandler
    extends javax.servlet.http.HttpServlet
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void doDelete​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Handle DELETE requests to /apps/{appId}/{instanceId} to unregister an app.
      protected void doGet​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Handle GET requests to /apps/{appId}/{instanceId} or to /vips/{vipAddress}.
      protected void doPost​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Handle registration requests via POSTs to /apps.
      protected void doPut​(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
      Handles PUT requests for either heartbeats or status updates.
      • Methods inherited from class javax.servlet.http.HttpServlet

        doHead, doOptions, doTrace, getLastModified, service, service
      • Methods inherited from class javax.servlet.GenericServlet

        destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
    • Constructor Detail

      • EurekaServletHandler

        public EurekaServletHandler​(EurekaServer eurekaServer)
    • Method Detail

      • doGet

        protected void doGet​(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse resp)
                      throws IOException
        Handle GET requests to /apps/{appId}/{instanceId} or to /vips/{vipAddress}.

        You can cause requests to /apps/{appId}/{instanceId} to return an HTTP 500 error N times by setting the instanceId/hostName of the candidate to the literal string "FailAwaitRegistrationFirstNTimes-N", for example FailAwaitRegistrationFirstNTimes-5 causes it to return a 500 error for the first 5 times a GET to /apps/someAppName/FailAwaitRegistrationFirstNTimes-5 is made.

        Overrides:
        doGet in class javax.servlet.http.HttpServlet
        Throws:
        IOException
      • doPut

        protected void doPut​(javax.servlet.http.HttpServletRequest req,
                             javax.servlet.http.HttpServletResponse resp)
                      throws IOException
        Handles PUT requests for either heartbeats or status updates.

        To perform a heartbeat just do a PUT to /apps/{appId}/{instanceId}. You can cause heartbeats to fail with a 404 by setting the hostName to "FailHeartbeat-N" where N is the number of times to fail. You can also specify the response code by adding the response code you want under the key "FailHeartbeatResponseCode" in the registration candidate's metadata map.

        To do a status update, PUT to /apps/{appId}/{instanceId}/status?value=new-status. You can also cause a status change to fail by setting the candidate instanceId/hostName to the literal string "FailStatusChange".

        Overrides:
        doPut in class javax.servlet.http.HttpServlet
        Throws:
        IOException
      • doPost

        protected void doPost​(javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse resp)
                       throws IOException
        Handle registration requests via POSTs to /apps.

        You can cause two different failure types. By setting the candidate's VIP address to "RegisterUseResponseStatusCode-status-code" (example: RegisterUseResponseStatusCode-500) you can force the mock server to return the specified response code. Or, by setting the VIP address to "FailRegistrationFirstNTimes-numberOfTimes" (example FailRegistrationFirstNTimes-3) you can cause registration to fail with a 500 error the first N times (3 times in the example).

        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Throws:
        IOException
      • doDelete

        protected void doDelete​(javax.servlet.http.HttpServletRequest req,
                                javax.servlet.http.HttpServletResponse resp)
                         throws javax.servlet.ServletException,
                                IOException
        Handle DELETE requests to /apps/{appId}/{instanceId} to unregister an app.

        You can cause a 500 error by setting the hostName/instanceId of the candidate to "FailUnregister".

        Overrides:
        doDelete in class javax.servlet.http.HttpServlet
        Throws:
        javax.servlet.ServletException
        IOException