Class RollingUpdateHandler

java.lang.Object
com.vaadin.kubernetes.starter.ui.RollingUpdateHandler
All Implemented Interfaces:
com.vaadin.flow.server.VaadinServiceInitListener, Serializable, EventListener
Direct Known Subclasses:
ClusterSupport

public class RollingUpdateHandler extends Object implements com.vaadin.flow.server.VaadinServiceInitListener
Handles rolling updates for Vaadin applications running in a cluster.

When the ingress controller or gateway sets the update version header on requests to the current (old) version, and its value differs from the configured application version, a notification is shown prompting the user to switch to the new version. When the user accepts, the sticky session cookie is removed and the session is invalidated, so that the next request is routed to a pod running the new version.

Since:
3.0
See Also:
  • Constructor Details

    • RollingUpdateHandler

      public RollingUpdateHandler(String appVersion, List<String> stickySessionCookieNames, String updateVersionHeaderName)
      Creates a new RollingUpdateHandler instance.
      Parameters:
      appVersion - the application version. When the update version header value differs from this version, a notification is shown prompting the user to switch to the new version. If null, rolling update version detection is disabled.
      stickySessionCookieNames - the names of the cookies used by the ingress controller or gateway implementation for sticky sessions. All cookies in the list are removed when the user accepts a version switch, so that the next request is no longer pinned to the old pod. Multiple names are needed when the gateway sets more than one affinity cookie (e.g. Azure Application Gateway with AGIC).
      updateVersionHeaderName - the name of the HTTP request header used to detect a new application version during rolling updates. The ingress controller or gateway sets this header on requests to the current version with the new version as its value.
      See Also:
    • RollingUpdateHandler

      @Deprecated(forRemoval=true) public RollingUpdateHandler(String appVersion, String stickySessionCookieName, String updateVersionHeaderName)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use RollingUpdateHandler(String, List, String) instead to support multiple sticky session cookie names.
      Creates a new RollingUpdateHandler instance with a single sticky session cookie name.
      Parameters:
      appVersion - the application version. When the update version header value differs from this version, a notification is shown prompting the user to switch to the new version. If null, rolling update version detection is disabled.
      stickySessionCookieName - the name of the cookie used by the ingress controller or gateway implementation for sticky sessions.
      updateVersionHeaderName - the name of the HTTP request header used to detect a new application version during rolling updates.
      See Also:
  • Method Details

    • setSwitchVersionListener

      public void setSwitchVersionListener(SwitchVersionListener listener)
      Register the global version switch listener. If set to null the current session and the sticky cluster cookie are removed without any version switch condition check.
      Parameters:
      listener - the listener to register.
    • serviceInit

      public void serviceInit(com.vaadin.flow.server.ServiceInitEvent serviceInitEvent)
      Specified by:
      serviceInit in interface com.vaadin.flow.server.VaadinServiceInitListener