Interface Session


public interface Session
Variant user session. Provides a way to maintain user state across multiple state requests. Variant sessions are managed by Variant Server and are completely distinct from those that may be managed by the host application. However, Variant server relies on the host application to provide session ID tracking via an implementation of the SessionIdTracker interface. Variant sessions are discarded by Variant server after a configurable session timeout period of inactivity. Once a session has expired, most methods of this class will throw a SessionExpiredException.
Since:
0.5
  • Method Details

    • getId

      String getId()

      This session's unique identifier. Generated as a random 128-bit number converted to the hexadecimal notation.

      Since:
      0.7
    • getTimestamp

      Instant getTimestamp()

      This session's creation time stamp.

      Since:
      0.7
    • getConnection

      Connection getConnection()

      The connection object, which originally created this session.

      Returns:
      An object of type Connection. Cannot be null.
      Since:
      0.7
    • getSchema

      Schema getSchema()
      The variation schema, associated with this session. This is the schema that was live at the time when this session was created. May not be the current live generation of this schema.
      Returns:
      An object of type Schema. Cannot be null.
      Since:
      0.9
    • targetForState

      StateRequest targetForState(State state)

      Target this session for a given state.

      Returns:
      An object of type StateRequest, which may be further examined for more information about the outcome of this operation. Cannot be null
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.5
    • getTimeoutMillis

      long getTimeoutMillis()

      Session timeout interval, as set by the server. The server will dispose of this session after this many milliseconds of inactivity.

      Since:
      0.7
    • getTraversedStates

      Map<State,Integer> getTraversedStates()

      The collection of states, traversed by this session so far, and their respective visit counts. For each state S, the visit count is incremented by one whenever the session is targeted for the state S, and there exists a variation V, which a) is instrumented on state S, b) is online, and c) this session qualified for.

      Returns:
      A map, whose entries are keyed by State and values are the Integer visit counts of that state. Cannot be null, but may be empty.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.7
    • getTraversedVariations

      Set<Variation> getTraversedVariations()

      The set of variations, traversed by this session so far. A variation V is traversed by a session when the session is targeted for a state instrumented by V, V is online, and the session is qualified for V.

      Returns:
      A set of object of type Variation. Cannot be null, but may be empty.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.7
    • getDisqualifiedVariations

      Set<Variation> getDisqualifiedVariations()

      The set of variations for which this session has been disqualified. Whenever a session is disqualified for a variation, it remains disqualified for it for the life of the session, even if the condition that disqualified it may no longer hold.

      Returns:
      A set of objects of type Variation. Cannot be null, but may be empty.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.7
    • getLiveExperiences

      Set<Variation.Experience> getLiveExperiences()

      The set of live experiences to which this session has been targeted. This list is different from he similarly named StateRequest.getLiveExperiences() in that it is cumulative of all the state requests performed by this session.

      Returns:
      A set of object of type Variation.Experience. Cannot be null, but may be empty.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.9
    • getLiveExperience

      Optional<Variation.Experience> getLiveExperience(Variation variation)

      The live experience in a given variation.

      Returns:
      An Optional containing the requested experience if the Set, returned by getLiveExperiences(), contains one for the given variation, or empty otherwise.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.9
    • getLiveExperience

      Optional<Variation.Experience> getLiveExperience(String variationName)

      The live experience in a given variation, by variation name.

      Returns:
      An Optional containing the requested experience if the Set, returned by getLiveExperiences(), contains one for the given variation, or empty otherwise. one from the given variation.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.9
    • getStateRequest

      Optional<? extends StateRequest> getStateRequest()

      The most recent state request, which may be still in progress or already committed.

      Returns:
      An Optional, containing the most recent state request, or empty if this session has not yet been targeted for a state.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.5
    • triggerTraceEvent

      void triggerTraceEvent(TraceEvent event)
      Trigger a custom trace event.
      Parameters:
      event - An implementation of TraceEvent, to be triggered.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.7
    • getAttributes

      SessionAttributes getAttributes()
      This session's attributes.
      Returns:
      An object of type SessionAttributeMap.
      Throws:
      SessionExpiredException
      UnknownSchemaException
      Since:
      0.6