OlympiaServerSessionManager

Overview

The OlympiaServerSessionManager class represents a session manager that stores session data in the Olympia State Server.

Sessions are stored out-of-process and are able to survive a service restart. Session data can be shared between several services of the same type thus allowing to implement load balancing mechanisms like Round Robin etc.

There are two things one should consider before using the OlympiaServerSessionManager component to store session data:

  1. For obvoius reasons, session access performance is considerably lower for the OlympiaServerSessionManager compared to the In-Memory Session Manager, because accessing a session stored on the Olympia Server takes much more time than accessing a session object stored in memory.

  2. Not all data types can be stored in an Olympia session. Supported types are:

  3. Primitive values:

    • Binary
    • Boolean
    • Byte
    • Currency
    • DateTime
    • Decimal
    • Double
    • Guid
    • Int8
    • Int16
    • Int32
    • Int64
    • String
  4. Classes inherited from the ComplexType class. In this case methods ComplexType and ComplexType are used to serialize/deserialize data
  5. All .NET classes marked with the Serializable attribute. In this case .NET serialization facility will be used
  6. Arrays of types listed above

The OlympiaServerSessionManager class uses the SuperTcpClientChannel client channel to communicate with the Olympia Server.

Location


 

constructor

Creates a new instance of the OlympiaServerSessionManager class.

 

constructor

 

OlympiaServerSessionManager()

 

Sub New()

constructor (IContainer)

Creates a new instance of the OlympiaServerSessionManager class and adds the newly created instance to the provided component container.

 

constructor(container: IContainer)

 

OlympiaServerSessionManager(IContainer container)

 

Sub New(container As IContainer)

Parameters:

  • container: Components container

constructor (Boolean)

 

constructor(register: Boolean)

 

OlympiaServerSessionManager(Boolean register)

 

Sub New(register As Boolean)

Parameters:

  • register:

constructor (Boolean, Boolean)  protected    (declared in SessionManager)

 

constructor(register: Boolean; initializeSessionExpirationTimer: Boolean)

 

OlympiaServerSessionManager(Boolean register, Boolean initializeSessionExpirationTimer)

 

Sub New(register As Boolean, initializeSessionExpirationTimer As Boolean)

Parameters:

  • register:
  • initializeSessionExpirationTimer:

ApplicationId

Gets or sets the so-called Application type ID.

This property was introduced to prevent access to sessions not owned by the current server application. Only servers that share the same ApplicationId value have access to the each other's sessions.

 

property ApplicationId: Guid read write;

 

Guid ApplicationId { get; set; }

 

Property ApplicationId() As Guid

Channel

Gets or sets the ClientChannel instance that will be used to communicate with the remote Olympia Server.

The OlympiaServerSessionManager class will clone this ClientChannel instance and use a connection pool internally to communicate with the Olympia Server.

By default, the Olympia Server can be accessed via the SuperTCP channel. See more details in the Accessing Olympia paragraph.

 

property Channel: ClientChannel read write;

 

ClientChannel Channel { get; set; }

 

Property Channel() As ClientChannel

CreateNewSession  protected

Creates a new session instance with the provided Session ID.

At this point, the session is created locally without notifying the Olympia Server.

 

method CreateNewSession(sessionId: Guid): ISession

 

ISession CreateNewSession(Guid sessionId)

 

Function CreateNewSession(sessionId As Guid) As ISession

Parameters:

  • sessionId: Session Id

DestroySession (ISession)    (declared in SessionManager)

 

method DestroySession(session: ISession)

 

void DestroySession(ISession session)

 

Sub DestroySession(session As ISession)

Parameters:

  • session:

DestroySession (Guid)    (declared in SessionManager)

 

method DestroySession(sessionId: Guid)

 

void DestroySession(Guid sessionId)

 

Sub DestroySession(sessionId As Guid)

Parameters:

  • sessionId:

Dispose  protected    (declared in SessionManager)

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing:

EnableLightweightSessions

 

property EnableLightweightSessions: Boolean read write;

 

Boolean EnableLightweightSessions { get; set; }

 

Property EnableLightweightSessions() As Boolean

ExpireSessions

This method is empty, because the Olympia Server itself handles session timeouts.

 

method ExpireSessions

 

void ExpireSessions()

 

Sub ExpireSessions()

GetAllSessions

Retrieves identifiers of active sessions from the Olympia Server.

Only sessions stored with a valid ApplicationId are enumerated.

 

method GetAllSessions: IList<Guid>

 

IList<Guid> GetAllSessions()

 

Function GetAllSessions() As IList<Guid>

GetExistingSession    (declared in SessionManager)

Returns existing session with provided Id or null in case the session cannot be found. Depending on the updateTime parameter value updates the session's LastaccessedTime attribute.

 

method GetExistingSession(sessionId: Guid; updateTime: Boolean): ISession

 

ISession GetExistingSession(Guid sessionId, Boolean updateTime)

 

Function GetExistingSession(sessionId As Guid, updateTime As Boolean) As ISession

Parameters:

  • sessionId: Session Id
  • updateTime: Flag indicating whether session's LastAccessedTime attribute should be updated

GetSession    (declared in SessionManager)

Returns session with provided Id. If there is no session stored with the provided Id then new session is created.

 

method GetSession(sessionId: Guid): ISession

 

ISession GetSession(Guid sessionId)

 

Function GetSession(sessionId As Guid) As ISession

Parameters:

  • sessionId: Session Id

IsOutOfProcess

Gets a flag indicating that session manager uses out-of-process session storage.

Returns true.

 

property IsOutOfProcess: Boolean read;

 

Boolean IsOutOfProcess { get; }

 

ReadOnly Property IsOutOfProcess() As Boolean

LocateExistingSession  protected

Retrieves the session with the provided ID from the Olympia Server. Returns null if the Olympia Server doesn't store a session with the provided ID.

 

method LocateExistingSession(sessionId: Guid; updateTime: Boolean): ISession

 

ISession LocateExistingSession(Guid sessionId, Boolean updateTime)

 

Function LocateExistingSession(sessionId As Guid, updateTime As Boolean) As ISession

Parameters:

  • sessionId: Session Id
  • updateTime:

MaxPoolSize

Gets or sets the maximum size of the connection pool used to communicate with the Olympia Server.

 

property MaxPoolSize: Int32 read write;

 

Int32 MaxPoolSize { get; set; }

 

Property MaxPoolSize() As Int32

OnSessionCreated    (declared in SessionManager)

Gets triggered after a new Session has been created. You can use it to perform initialization functions or fill the session with default values.

 

event OnSessionCreated: SessionEventHandler;
delegate: method OnSessionCreated(sender: Object; e: SessionEventArgs)

 

delegate SessionEventHandler OnSessionCreated()
delegate: void OnSessionCreated(Object sender, SessionEventArgs e)

 

Event OnSessionCreated As SessionEventHandler
delegate: Sub OnSessionCreated(sender As Object, e As SessionEventArgs)

OnSessionDestroyed    (declared in SessionManager)

Gets triggered after a new Session has been manually destroyed. You can use it to perform cleanup for a specific session id.

Note: The session has already been Disposed when the OnSessionDestroyed event fires. This event will not fire for sessions that expire.

 

event OnSessionDestroyed: SessionIDEventHandler;
delegate: method OnSessionDestroyed(sender: Object; e: SessionIDEventArgs)

 

delegate SessionIDEventHandler OnSessionDestroyed()
delegate: void OnSessionDestroyed(Object sender, SessionIDEventArgs e)

 

Event OnSessionDestroyed As SessionIDEventHandler
delegate: Sub OnSessionDestroyed(sender As Object, e As SessionIDEventArgs)

OnSessionExpired    (declared in SessionManager)

Gets triggered after a new Session has been expired. You can use it to perform cleanup and/or inspect the values of the expired session.

Note: The session has already been Disposed when the OnSessionExpired event fires. This event will not fire for sessions that are manually destroyed.

 

event OnSessionExpired: SessionEventHandler;
delegate: method OnSessionExpired(sender: Object; e: SessionEventArgs)

 

delegate SessionEventHandler OnSessionExpired()
delegate: void OnSessionExpired(Object sender, SessionEventArgs e)

 

Event OnSessionExpired As SessionEventHandler
delegate: Sub OnSessionExpired(sender As Object, e As SessionEventArgs)

ReleaseSession

Releases the previously acquired session. The session data is serialized and sent to the Olympia Server.

In most cases, this method is called automatically when a service is deactivated.

 

method ReleaseSession(session: ISession)

 

void ReleaseSession(ISession session)

 

Sub ReleaseSession(session As ISession)

Parameters:

  • session: Session instance

SessionCount  protected

Gets the number of sessions stored in the Olympia Server.

Only sessions stored with a valid ApplicationId are counted.

 

property SessionCount: Int32 read;

 

Int32 SessionCount { get; }

 

ReadOnly Property SessionCount() As Int32

SessionsExpired

This method implements the IOlympiaSessionManagerEvents interface.

It is called when the OlympiaServerSessionManager instance is notified via a server event that one or more sessions have been marked as expired by the Olympia Server.

This method raises an OnSessionExpired event with session identifiers retrieved via the aExpiredSessionIDs parameter.

This method shouldn't be called directly.

 

method SessionsExpired(expiredSessions: array of Guid)

 

void SessionsExpired(Guid[] expiredSessions)

 

Sub SessionsExpired(expiredSessions As Guid())

Parameters:

  • expiredSessions: List of expired sessions Ids sent from the Olympia State Server.

Timeout    (declared in SessionManager)

Determines the timeout (in seconds) after which sessions will be discarded if they have not been accessed. The default value is 600 seconds (10 minutes).

 

property Timeout: Int32 read write;

 

Int32 Timeout { get; set; }

 

Property Timeout() As Int32

TriggerOnSessionCreated  protected    (declared in SessionManager)

 

method TriggerOnSessionCreated(e: SessionEventArgs)

 

void TriggerOnSessionCreated(SessionEventArgs e)

 

Sub TriggerOnSessionCreated(e As SessionEventArgs)

Parameters:

  • e:

TriggerOnSessionDestroyed  protected    (declared in SessionManager)

 

method TriggerOnSessionDestroyed(e: SessionIDEventArgs)

 

void TriggerOnSessionDestroyed(SessionIDEventArgs e)

 

Sub TriggerOnSessionDestroyed(e As SessionIDEventArgs)

Parameters:

  • e:

TriggerOnSessionExpired  protected    (declared in SessionManager)

 

method TriggerOnSessionExpired(e: SessionEventArgs)

 

void TriggerOnSessionExpired(SessionEventArgs e)

 

Sub TriggerOnSessionExpired(e As SessionEventArgs)

Parameters:

  • e:

 

ApplicationId

Gets or sets the so-called Application type ID.

This property was introduced to prevent access to sessions not owned by the current server application. Only servers that share the same ApplicationId value have access to the each other's sessions.

 

property ApplicationId: Guid read write;

 

Guid ApplicationId { get; set; }

 

Property ApplicationId() As Guid

Channel

Gets or sets the ClientChannel instance that will be used to communicate with the remote Olympia Server.

The OlympiaServerSessionManager class will clone this ClientChannel instance and use a connection pool internally to communicate with the Olympia Server.

By default, the Olympia Server can be accessed via the SuperTCP channel. See more details in the Accessing Olympia paragraph.

 

property Channel: ClientChannel read write;

 

ClientChannel Channel { get; set; }

 

Property Channel() As ClientChannel

EnableLightweightSessions

 

property EnableLightweightSessions: Boolean read write;

 

Boolean EnableLightweightSessions { get; set; }

 

Property EnableLightweightSessions() As Boolean

IsOutOfProcess

Gets a flag indicating that session manager uses out-of-process session storage.

Returns true.

 

property IsOutOfProcess: Boolean read;

 

Boolean IsOutOfProcess { get; }

 

ReadOnly Property IsOutOfProcess() As Boolean

MaxPoolSize

Gets or sets the maximum size of the connection pool used to communicate with the Olympia Server.

 

property MaxPoolSize: Int32 read write;

 

Int32 MaxPoolSize { get; set; }

 

Property MaxPoolSize() As Int32

SessionCount  protected

Gets the number of sessions stored in the Olympia Server.

Only sessions stored with a valid ApplicationId are counted.

 

property SessionCount: Int32 read;

 

Int32 SessionCount { get; }

 

ReadOnly Property SessionCount() As Int32

Timeout    (declared in SessionManager)

Determines the timeout (in seconds) after which sessions will be discarded if they have not been accessed. The default value is 600 seconds (10 minutes).

 

property Timeout: Int32 read write;

 

Int32 Timeout { get; set; }

 

Property Timeout() As Int32

 

constructor

Creates a new instance of the OlympiaServerSessionManager class.

 

constructor

 

OlympiaServerSessionManager()

 

Sub New()

constructor (IContainer)

Creates a new instance of the OlympiaServerSessionManager class and adds the newly created instance to the provided component container.

 

constructor(container: IContainer)

 

OlympiaServerSessionManager(IContainer container)

 

Sub New(container As IContainer)

Parameters:

  • container: Components container

constructor (Boolean)

 

constructor(register: Boolean)

 

OlympiaServerSessionManager(Boolean register)

 

Sub New(register As Boolean)

Parameters:

  • register:

constructor (Boolean, Boolean)  protected    (declared in SessionManager)

 

constructor(register: Boolean; initializeSessionExpirationTimer: Boolean)

 

OlympiaServerSessionManager(Boolean register, Boolean initializeSessionExpirationTimer)

 

Sub New(register As Boolean, initializeSessionExpirationTimer As Boolean)

Parameters:

  • register:
  • initializeSessionExpirationTimer:

CreateNewSession  protected

Creates a new session instance with the provided Session ID.

At this point, the session is created locally without notifying the Olympia Server.

 

method CreateNewSession(sessionId: Guid): ISession

 

ISession CreateNewSession(Guid sessionId)

 

Function CreateNewSession(sessionId As Guid) As ISession

Parameters:

  • sessionId: Session Id

DestroySession (ISession)    (declared in SessionManager)

 

method DestroySession(session: ISession)

 

void DestroySession(ISession session)

 

Sub DestroySession(session As ISession)

Parameters:

  • session:

DestroySession (Guid)    (declared in SessionManager)

 

method DestroySession(sessionId: Guid)

 

void DestroySession(Guid sessionId)

 

Sub DestroySession(sessionId As Guid)

Parameters:

  • sessionId:

Dispose  protected    (declared in SessionManager)

 

method Dispose(disposing: Boolean)

 

void Dispose(Boolean disposing)

 

Sub Dispose(disposing As Boolean)

Parameters:

  • disposing:

ExpireSessions

This method is empty, because the Olympia Server itself handles session timeouts.

 

method ExpireSessions

 

void ExpireSessions()

 

Sub ExpireSessions()

GetAllSessions

Retrieves identifiers of active sessions from the Olympia Server.

Only sessions stored with a valid ApplicationId are enumerated.

 

method GetAllSessions: IList<Guid>

 

IList<Guid> GetAllSessions()

 

Function GetAllSessions() As IList<Guid>

GetExistingSession    (declared in SessionManager)

Returns existing session with provided Id or null in case the session cannot be found. Depending on the updateTime parameter value updates the session's LastaccessedTime attribute.

 

method GetExistingSession(sessionId: Guid; updateTime: Boolean): ISession

 

ISession GetExistingSession(Guid sessionId, Boolean updateTime)

 

Function GetExistingSession(sessionId As Guid, updateTime As Boolean) As ISession

Parameters:

  • sessionId: Session Id
  • updateTime: Flag indicating whether session's LastAccessedTime attribute should be updated

GetSession    (declared in SessionManager)

Returns session with provided Id. If there is no session stored with the provided Id then new session is created.

 

method GetSession(sessionId: Guid): ISession

 

ISession GetSession(Guid sessionId)

 

Function GetSession(sessionId As Guid) As ISession

Parameters:

  • sessionId: Session Id

LocateExistingSession  protected

Retrieves the session with the provided ID from the Olympia Server. Returns null if the Olympia Server doesn't store a session with the provided ID.

 

method LocateExistingSession(sessionId: Guid; updateTime: Boolean): ISession

 

ISession LocateExistingSession(Guid sessionId, Boolean updateTime)

 

Function LocateExistingSession(sessionId As Guid, updateTime As Boolean) As ISession

Parameters:

  • sessionId: Session Id
  • updateTime:

ReleaseSession

Releases the previously acquired session. The session data is serialized and sent to the Olympia Server.

In most cases, this method is called automatically when a service is deactivated.

 

method ReleaseSession(session: ISession)

 

void ReleaseSession(ISession session)

 

Sub ReleaseSession(session As ISession)

Parameters:

  • session: Session instance

SessionsExpired

This method implements the IOlympiaSessionManagerEvents interface.

It is called when the OlympiaServerSessionManager instance is notified via a server event that one or more sessions have been marked as expired by the Olympia Server.

This method raises an OnSessionExpired event with session identifiers retrieved via the aExpiredSessionIDs parameter.

This method shouldn't be called directly.

 

method SessionsExpired(expiredSessions: array of Guid)

 

void SessionsExpired(Guid[] expiredSessions)

 

Sub SessionsExpired(expiredSessions As Guid())

Parameters:

  • expiredSessions: List of expired sessions Ids sent from the Olympia State Server.

TriggerOnSessionCreated  protected    (declared in SessionManager)

 

method TriggerOnSessionCreated(e: SessionEventArgs)

 

void TriggerOnSessionCreated(SessionEventArgs e)

 

Sub TriggerOnSessionCreated(e As SessionEventArgs)

Parameters:

  • e:

TriggerOnSessionDestroyed  protected    (declared in SessionManager)

 

method TriggerOnSessionDestroyed(e: SessionIDEventArgs)

 

void TriggerOnSessionDestroyed(SessionIDEventArgs e)

 

Sub TriggerOnSessionDestroyed(e As SessionIDEventArgs)

Parameters:

  • e:

TriggerOnSessionExpired  protected    (declared in SessionManager)

 

method TriggerOnSessionExpired(e: SessionEventArgs)

 

void TriggerOnSessionExpired(SessionEventArgs e)

 

Sub TriggerOnSessionExpired(e As SessionEventArgs)

Parameters:

  • e:

 

OnSessionCreated    (declared in SessionManager)

Gets triggered after a new Session has been created. You can use it to perform initialization functions or fill the session with default values.

 

event OnSessionCreated: SessionEventHandler;
delegate: method OnSessionCreated(sender: Object; e: SessionEventArgs)

 

delegate SessionEventHandler OnSessionCreated()
delegate: void OnSessionCreated(Object sender, SessionEventArgs e)

 

Event OnSessionCreated As SessionEventHandler
delegate: Sub OnSessionCreated(sender As Object, e As SessionEventArgs)

OnSessionDestroyed    (declared in SessionManager)

Gets triggered after a new Session has been manually destroyed. You can use it to perform cleanup for a specific session id.

Note: The session has already been Disposed when the OnSessionDestroyed event fires. This event will not fire for sessions that expire.

 

event OnSessionDestroyed: SessionIDEventHandler;
delegate: method OnSessionDestroyed(sender: Object; e: SessionIDEventArgs)

 

delegate SessionIDEventHandler OnSessionDestroyed()
delegate: void OnSessionDestroyed(Object sender, SessionIDEventArgs e)

 

Event OnSessionDestroyed As SessionIDEventHandler
delegate: Sub OnSessionDestroyed(sender As Object, e As SessionIDEventArgs)

OnSessionExpired    (declared in SessionManager)

Gets triggered after a new Session has been expired. You can use it to perform cleanup and/or inspect the values of the expired session.

Note: The session has already been Disposed when the OnSessionExpired event fires. This event will not fire for sessions that are manually destroyed.

 

event OnSessionExpired: SessionEventHandler;
delegate: method OnSessionExpired(sender: Object; e: SessionEventArgs)

 

delegate SessionEventHandler OnSessionExpired()
delegate: void OnSessionExpired(Object sender, SessionEventArgs e)

 

Event OnSessionExpired As SessionEventHandler
delegate: Sub OnSessionExpired(sender As Object, e As SessionEventArgs)