Class ExternalLoadBalancerInterceptor
- java.lang.Object
-
- jetbrains.buildServer.controllers.interceptors.proxy.ExternalLoadBalancerInterceptor
-
- All Implemented Interfaces:
org.springframework.web.servlet.AsyncHandlerInterceptor
,org.springframework.web.servlet.HandlerInterceptor
public class ExternalLoadBalancerInterceptor extends Object implements org.springframework.web.servlet.AsyncHandlerInterceptor
Interceptor, responsible for managing requests that come from external load balancers When external proxy is used to route requests between agents and multi-node TeamCity setup, the agents use cookies to hint proxy where to route the request. On the server side, we check whether the request landed on a node which is responsible for the build that produced the request or not. If the request has landed on a responsible node,ExternalLoadBalancerInterceptor
prolongs the lifetime of the cookie by the value ofPROPERTY_MULTI_NODE_COOKIE_LONG_LIFETIME
property If (when the responsible node is down) the request has landed on another node for the first time,ExternalLoadBalancerInterceptor
sets a new cookie lifetime with value ofPROPERTY_MULTI_NODE_COOKIE_SHORT_LIFETIME
and refuses to process the request by sendingHttpStatus.SC_SERVICE_UNAVAILABLE
. When the cookie expires and the request without cookie lands on any node that is capable of taking the responsibility for the build, the build is reassigned to this node, a new cookie withPROPERTY_MULTI_NODE_COOKIE_LONG_LIFETIME
is set and the node proceeds with processing the request.- Author:
- Oleg Rybak (oleg.rybak@jetbrains.com)
- See Also:
- TW-66859 issue in YouTrack
-
-
Constructor Summary
Constructors Constructor Description ExternalLoadBalancerInterceptor(TimeService timeService, BuildPromotionManagerEx buildPromotionManager, BuildsManager buildsManager, TeamCityNodes teamCityNodes, BuildAgentMessagesQueue buildAgentMessagesQueue, ServerResponsibility serverResponsibility)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getLongCookieLifetimeMillis()
long
getShortCookieLifetimeMillis()
boolean
preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Constructor Detail
-
ExternalLoadBalancerInterceptor
public ExternalLoadBalancerInterceptor(@NotNull TimeService timeService, @NotNull BuildPromotionManagerEx buildPromotionManager, @NotNull BuildsManager buildsManager, @NotNull TeamCityNodes teamCityNodes, @NotNull BuildAgentMessagesQueue buildAgentMessagesQueue, @NotNull ServerResponsibility serverResponsibility)
-
-
Method Detail
-
preHandle
public boolean preHandle(@NotNull javax.servlet.http.HttpServletRequest request, @NotNull javax.servlet.http.HttpServletResponse response, @NotNull Object handler) throws Exception
- Specified by:
preHandle
in interfaceorg.springframework.web.servlet.HandlerInterceptor
- Throws:
Exception
-
getShortCookieLifetimeMillis
public long getShortCookieLifetimeMillis()
-
getLongCookieLifetimeMillis
public long getLongCookieLifetimeMillis()
-
-