Interface BackendConnector

All Known Implementing Classes:
HazelcastConnector, RedisConnector

public interface BackendConnector
Interface for backend storage connectors that handle session serialization/deserialization lifecycle.

Implementations of this interface provide the underlying storage mechanism for persisting serialized Vaadin session data. The interface supports both session data storage and coordination mechanisms to track the serialization lifecycle.

  • Method Details

    • sendSession

      void sendSession(SessionInfo sessionInfo)
      Stores serialized session data in the backend storage.
      Parameters:
      sessionInfo - the session information containing the cluster key, serialized data, and time-to-live settings.
    • getSession

      SessionInfo getSession(String clusterKey)
      Retrieves session data from the backend storage by cluster key.
      Parameters:
      clusterKey - the distributed storage key identifying the session.
      Returns:
      the session information containing the serialized data, or null if no session is found for the given key.
    • deleteSession

      void deleteSession(String clusterKey)
      Removes session data from the backend storage.
      Parameters:
      clusterKey - the distributed storage key identifying the session to delete.
    • markSerializationStarted

      void markSerializationStarted(String clusterKey, Duration timeToLive)
      Marks the beginning of the serialization process for a session.

      This method is used for coordination between multiple requests to indicate that serialization is in progress and prevent concurrent access issues. Implementors can decide if the method should block in case of concurrent requests; potential acquired locks should be released in markSerializationComplete(String) and markSerializationFailed(String, Throwable) methods.

      Parameters:
      clusterKey - the distributed storage key identifying the session.
      timeToLive - the maximum amount of time the serialization marker should be preserved in the backend. A zero or negative value means the marker should not be evicted.
    • markSerializationComplete

      void markSerializationComplete(String clusterKey)
      Marks the successful completion of the serialization process for a session.

      This method is called after session data has been successfully serialized and stored in the backend. Any lock has been acquired by markSerializationStarted(String, Duration) should be released here.

      Parameters:
      clusterKey - the distributed storage key identifying the session.
    • markSerializationFailed

      void markSerializationFailed(String clusterKey, Throwable error)
      Marks the serialization process as failed for a session.

      This method is called when an error occurs during the serialization process to record the failure and its cause. Any lock has been acquired by markSerializationStarted(String, Duration) should be released here.

      Parameters:
      clusterKey - the distributed storage key identifying the session.
      error - the error that caused the serialization to fail.
    • markDeserializationStarted

      boolean markDeserializationStarted(String clusterKey, Duration timeToLive)
      Marks the beginning of the deserialization process for a session.

      This method is used for coordination between multiple requests to indicate that serialization is in progress and prevent concurrent access issues. Implementors can decide if the method should block in case of concurrent requests; potential acquired locks should be released in markDeserializationComplete(String) and markDeserializationFailed(String, Throwable) methods.

      Parameters:
      clusterKey - the distributed storage key identifying the session.
      timeToLive - the maximum amount of time the serialization marker should be preserved in the backend. A zero or negative value means the marker should not be evicted.
      Returns:
      true if there is no pending deserialization process, otherwise false.
    • markDeserializationComplete

      void markDeserializationComplete(String clusterKey)
      Marks the successful completion of the deserialization process for a session.

      This method is called after session data has been successfully deserialized. Any lock that has been acquired by markDeserializationStarted(String, Duration) should be released here.

      Parameters:
      clusterKey - the distributed storage key identifying the session.
    • markDeserializationFailed

      void markDeserializationFailed(String clusterKey, Throwable error)
      Marks the deserialization process as failed for a session.

      This method is called when an error occurs during the serialization process to record the failure and its cause. Any lock that has been acquired by markDeserializationStarted(String, Duration) should be released here.

      Parameters:
      clusterKey - the distributed storage key identifying the session.
      error - the error that caused the serialization to fail.