Class LoadBalancerDrainingValve

java.lang.Object
All Implemented Interfaces:
MBeanRegistration, Contained, JmxEnabled, Lifecycle, Valve

public class LoadBalancerDrainingValve extends ValveBase

A Valve to detect situations where a load-balanced node receiving a request has been deactivated by the load balancer (JK_LB_ACTIVATION=DIS) and the incoming request has no valid session.

In these cases, the user's session cookie should be removed if it exists, any ";jsessionid" parameter should be removed from the request URI, and the client should be redirected to the same URI. This will cause the load-balanced to re-balance the client to another server.

All this work is required because when the activation state of a node is DISABLED, the load-balancer will still send requests to the node if they appear to have a session on that node. Since mod_jk doesn't actually know whether the session id is valid, it will send the request blindly to the disabled node, which makes it take much longer to drain the node than strictly necessary.

For testing purposes, a special cookie can be configured and used by a client to ignore the normal behavior of this Valve and allow a client to get a new session on a DISABLED node. See setIgnoreCookieName(java.lang.String) and setIgnoreCookieValue(java.lang.String) to configure those values.

This Valve should be installed earlier in the Valve pipeline than any authentication valves, as the redirection should take place before an authentication valve would save a request to a protected resource.

See Also: