Class HazelcastConnector

java.lang.Object
com.vaadin.kubernetes.starter.sessiontracker.backend.HazelcastConnector
All Implemented Interfaces:
BackendConnector

public class HazelcastConnector extends Object implements BackendConnector
  • Constructor Details

    • HazelcastConnector

      public HazelcastConnector(com.hazelcast.core.HazelcastInstance hazelcastInstance)
  • Method Details

    • sendSession

      public void sendSession(SessionInfo sessionInfo)
      Description copied from interface: BackendConnector
      Stores serialized session data in the backend storage.
      Specified by:
      sendSession in interface BackendConnector
      Parameters:
      sessionInfo - the session information containing the cluster key, serialized data, and time-to-live settings.
    • getSession

      public SessionInfo getSession(String clusterKey)
      Description copied from interface: BackendConnector
      Retrieves session data from the backend storage by cluster key.
      Specified by:
      getSession in interface BackendConnector
      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.
    • markSerializationStarted

      public void markSerializationStarted(String clusterKey, Duration timeToLive)
      Description copied from interface: BackendConnector
      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 BackendConnector.markSerializationComplete(String) and BackendConnector.markSerializationFailed(String, Throwable) methods.

      Specified by:
      markSerializationStarted in interface BackendConnector
      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

      public void markSerializationComplete(String clusterKey)
      Description copied from interface: BackendConnector
      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 BackendConnector.markSerializationStarted(String, Duration) should be released here.

      Specified by:
      markSerializationComplete in interface BackendConnector
      Parameters:
      clusterKey - the distributed storage key identifying the session.
    • markSerializationFailed

      public void markSerializationFailed(String clusterKey, Throwable error)
      Description copied from interface: BackendConnector
      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 BackendConnector.markSerializationStarted(String, Duration) should be released here.

      Specified by:
      markSerializationFailed in interface BackendConnector
      Parameters:
      clusterKey - the distributed storage key identifying the session.
      error - the error that caused the serialization to fail.
    • markDeserializationStarted

      public boolean markDeserializationStarted(String clusterKey, Duration timeToLive)
      Description copied from interface: BackendConnector
      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 BackendConnector.markDeserializationComplete(String) and BackendConnector.markDeserializationFailed(String, Throwable) methods.

      Specified by:
      markDeserializationStarted in interface BackendConnector
      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

      public void markDeserializationComplete(String clusterKey)
      Description copied from interface: BackendConnector
      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 BackendConnector.markDeserializationStarted(String, Duration) should be released here.

      Specified by:
      markDeserializationComplete in interface BackendConnector
      Parameters:
      clusterKey - the distributed storage key identifying the session.
    • markDeserializationFailed

      public void markDeserializationFailed(String clusterKey, Throwable error)
      Description copied from interface: BackendConnector
      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 BackendConnector.markDeserializationStarted(String, Duration) should be released here.

      Specified by:
      markDeserializationFailed in interface BackendConnector
      Parameters:
      clusterKey - the distributed storage key identifying the session.
      error - the error that caused the serialization to fail.
    • deleteSession

      public void deleteSession(String clusterKey)
      Description copied from interface: BackendConnector
      Removes session data from the backend storage.
      Specified by:
      deleteSession in interface BackendConnector
      Parameters:
      clusterKey - the distributed storage key identifying the session to delete.