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, String stickySessionCookieName, 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.
      stickySessionCookieName - the name of the cookie used by the ingress controller or gateway implementation for sticky sessions. This must match the cookie name configured in the infrastructure routing traffic to the application. When the user accepts a version switch, this cookie is removed so that the next request is no longer pinned to the old pod.
      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:
  • 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