public class

ACMSessionIdResolver

extends Object
implements AutoCloseable
java.lang.Object
   ↳ com.microstrategy.webapi.ACMSessionIdResolver

Class Overview

ACMSessionIdResolver manages the maps that keep track of the relationships between ConfigSessionId, Jwt, Users, ProjectIds, and ProjectSessionIds. Utilizing those maps the ACMSessionIdResolver is able to make decisions as to which IServers should be used to create sessions, given the project and other factors like (1) number of existing sessions, (2) user fencing, and (3) load balancing

Summary

Nested Classes
class ACMSessionIdResolver.ClearInfo  
class ACMSessionIdResolver.ConfigSessionInfo  
class ACMSessionIdResolver.EnumInfo EnumInfo is an immutable struct to hold a copy of the information in the maps. 
class ACMSessionIdResolver.MasterSessionInfo MasterSessionInfo is an immutable struct to hold a copy of the information in the maps. 
class ACMSessionIdResolver.ProjectSessionInfo ProjectSessionInfo is an immutable struct to hold a copy of the information in the maps. 
class ACMSessionIdResolver.ProjectsToConnect ProjectsToConnect is an immutable class so that the Csid and related Psids can be returned from getAllProjectsToConnect() 
class ACMSessionIdResolver.SSCMConfigSessionInfo  
class ACMSessionIdResolver.SSCMProjectSessionInfo  
interface ACMSessionIdResolver.SSCMSessionTypeInfo<T extends IDSSXMLSessionId>  
class ACMSessionIdResolver.ServersToConnect ServersToConnect is an immutable class so that the related Parameters, JWT, and Cluster Nodes can be returned by getServersToConnect() 
interface ACMSessionIdResolver.SessionIdInfo  
class ACMSessionIdResolver.SimultaneousSessionCreationManager<T extends IDSSXMLSessionId>  
class ACMSessionIdResolver.SymmetricReuseSessionReconstructor SymmetricReuseSessionReconstructor reconstructs sessions for the case (1) symmetric, (2) reuse sessions Notice that this is a static inner class that does NOT relying on the outer instance. 
Public Methods
Map<IDSSXMLSessionId.IMasterSessionIdACMSessionIdResolver.ClearInfo> clear()
clear removes all session ids (Master, Configuration and Project Session Ids) from the maps.
void close()
close shuts down the internal scheduler and waits for it to destroy the thread
void createConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId, ACMClusterInfo iClusterInfo)
createConfigSessionId adds a Configuration Session Id under the input Master Session Id
void createConfigSessionIdProjectIds(IDSSXMLSessionId.IConfigSessionId iConfigSessionId, List<String> iPids)
IDSSXMLSessionId.IMasterSessionId createMasterSessionId(IDSSXMLSessionId.IConfigSessionId iConfigSessionId, ACMJwt iJwt, ACMGSSCredential iGSSCredential, ACMCreateSessionParams iCSParams, ACMClusterInfo iClusterInfo, int iIServerSessionIdleTimeout, boolean iIsCloseable)
createMasterSessionId creates a new MasterSessionId from the input ConfigSessionId, Jwt and CreateSession parameters.
void createUseProjectFenceTier(String iUserLogin, List<ACMSessionDistributionHelper.ProjectFenceTier> iProjectFenceTier)
ACMSessionIdResolver.EnumInfo enumSids()
enumCsids will return a copy of all the session ids.
void extendTtlsByIdleTimeout(IDSSXMLSessionId iSessionId)
extendTtlsByIdleTimeout will update the TTL, using Now as the time, for the input Session Id and it's associated Master Session Id.
ACMSessionIdResolver.ProjectsToConnect getAllProjectsToConnect(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, Collection<String> iProjectIds)
getAllProjectsToConnect returns a list of Project Ids that need to be connected for the given existing and valid Master Session Id
IDSSXMLSessionId.IConfigSessionId getConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iMachineName, int iMachinePort)
List<ACMSessionIdResolver.ConfigSessionInfo> getConfigSessionInfos(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
getConfigSessionInfos gets a list of all the Config Session Info objects under the input Master Session Id.
static ACMSessionIdResolver getInstance()
getInstance will return the singleton ACMSessionIdResolver instance.
RWLock getLock()
ACMMasterSessionBundle getMasterSessionBundle(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
IDSSXMLSessionId.IMasterSessionId getMasterSessionId(String iSessionId)
getMasterSessionId finds and returns the Master Session Id associated with the input session id.
List<IDSSXMLSessionId.IMasterSessionId> getMasterSessionIds(String iUserLogin)
boolean getNeedReadUserAffinity()
List<String> getPidsOfConfigSession(IDSSXMLSessionId.IConfigSessionId iConfigSessionId)
@return
IDSSXMLSessionId.IConfigSessionId getPreferredConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
getPreferredConfigSessionId will find an existing config session and return it, or it will create a new one.
IDSSXMLSessionId.IConfigSessionId getPreferredConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, boolean iReturnNullIfNotFound)
getPreferredConfigSessionId will find an existing config session and return it.
String getProjectId(IDSSXMLSessionId.IProjectSessionId iProjectSessionId)
getProjectId gets the Project Id for the input Project Session Id
IDSSXMLSessionId.IProjectSessionId getProjectSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iProjectId)
getProjectSessionId gets an existing Project Session Id for the input Configuration Session Id/Project Id combination.
List<ACMSessionIdResolver.ProjectSessionInfo> getProjectSessionInfos(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
getProjectSessionInfos gets a list of all the Project Session Info objects under the input Master Session Id.
ACMSessionIdResolver.ServersToConnect getServersToConnect(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iProjectId, String iServerName, boolean iUserFencing)
getServersToConnect returns an ordered list of all the IServers that can be used to connect to the Project.
ACMSessionBundle getSessionBundle(IDSSXMLSessionId iSessionId)
getSessionBundle gets the ACMSessionBundle associated with the input session id
IDSSXMLSessionId getSessionId(String iSessionId)
getSessionId gets the Master, Configuration, or Project Session Id.
ACMTimeToLive getTtl(IDSSXMLSessionId iSessionId)
getTtl gets the time-to-live for the input session id
static boolean getUseAsymmetricClustering()
int getUserAffinity()
String getUserLogin(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
@return
List<ACMSessionDistributionHelper.ProjectFenceTier> getUserProjectFenceTier(String iUserLogin)
@return
String printContents()
printContents prints out to a log file all the contents of the maps.
Collection<IDSSXMLSessionId> removeSessionId(IDSSXMLSessionId iSessionId)
removeSessionId removes the Session Ids (Configuration, Project Session Id) from the maps.
void removeUserProjectFenceTier(String iUserLogin)
static IDSSXMLSessionId resolveSessionId(String iSessionID)
resolveSessionId resolves the Session ID.
static IDSSXMLSessionId resolveSessionId(String iSessionID, boolean iReturnNullIfNotFound)
void setTtls(IDSSXMLSessionId iSessionId, Calendar iTTL)
setTtls will update the TTL based on the time passed in for the input Session Id and it's associated Master Session Id.
void setUserAffinity(int iUserAffinity)
synchronized static void start(boolean iUseAsymmetricClustering)
start must be called at the beginning of the application, before sessions are created.
SimultaneousSessionCreationManager<IDSSXMLSessionId.IConfigSessionId> startCreateConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iMachineName, int iPort)
startCreateConfigSessionId begins the process that adds a Config Session Id under the input Master Session Id SimultaneousSessionCreationManager.finish is used to finish the add
SimultaneousSessionCreationManager<IDSSXMLSessionId.IProjectSessionId> startCreateProjectSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iProjectId)
startCreateProjectSessionId begins the process that adds a Project Session Id under the input Master Session Id SimultaneousSessionCreationManager.finish is used to finish the add
static void stop()
stop should be called at the end of the application, after all session creations are complete.
void stopThread()
stopThread will stop the ACMRefreshThread.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.AutoCloseable

Public Methods

public Map<IDSSXMLSessionId.IMasterSessionIdACMSessionIdResolver.ClearInfo> clear ()

clear removes all session ids (Master, Configuration and Project Session Ids) from the maps. The set of Session Ids that need to be closed as a result of this action is returned.

This is used to close everything which is good when shutting down or during testing

public void close ()

close shuts down the internal scheduler and waits for it to destroy the thread

public void createConfigSessionId (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId, ACMClusterInfo iClusterInfo)

createConfigSessionId adds a Configuration Session Id under the input Master Session Id

Parameters
iMasterSessionId an existing Master Session Id
iConfigSessionId a new Configuration Session Id to be added to the maps

public void createConfigSessionIdProjectIds (IDSSXMLSessionId.IConfigSessionId iConfigSessionId, List<String> iPids)

public IDSSXMLSessionId.IMasterSessionId createMasterSessionId (IDSSXMLSessionId.IConfigSessionId iConfigSessionId, ACMJwt iJwt, ACMGSSCredential iGSSCredential, ACMCreateSessionParams iCSParams, ACMClusterInfo iClusterInfo, int iIServerSessionIdleTimeout, boolean iIsCloseable)

createMasterSessionId creates a new MasterSessionId from the input ConfigSessionId, Jwt and CreateSession parameters. The MasterSessionId and data are put into the maps. The Jwt is needed so that PMasterSessionIds can be created on different IServers. The create parameters are needed so that the ProjectSessionId and the ConfigSessionId are matched

Parameters
iConfigSessionId a valid Configuration Session Id
iJwt the Jwt that was returned with the Configuration Session Id
iGSSCredential the kerberos credentials to the kerberos server
iCSParams the parameters used to create the Configuration Session Id
Returns
  • a new Master Session Id
Throws
MSTRWebAPIException
Note, to make a Master Session Id, you must first have a Configuration Session Id that is valid to an actual IServer.
MSTRWebAPIException

public void createUseProjectFenceTier (String iUserLogin, List<ACMSessionDistributionHelper.ProjectFenceTier> iProjectFenceTier)

public ACMSessionIdResolver.EnumInfo enumSids ()

enumCsids will return a copy of all the session ids. It's a copy so you can freely walk through the structure without a lock

public void extendTtlsByIdleTimeout (IDSSXMLSessionId iSessionId)

extendTtlsByIdleTimeout will update the TTL, using Now as the time, for the input Session Id and it's associated Master Session Id. The trick here is that the idle timeout is only known by the MAPs, that's because the idle timeout may be different for different clusters of IServers; thus its not a globally known value.

Parameters
iSessionId The session id associated with the session being set

public ACMSessionIdResolver.ProjectsToConnect getAllProjectsToConnect (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, Collection<String> iProjectIds)

getAllProjectsToConnect returns a list of Project Ids that need to be connected for the given existing and valid Master Session Id

public IDSSXMLSessionId.IConfigSessionId getConfigSessionId (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iMachineName, int iMachinePort)

public List<ACMSessionIdResolver.ConfigSessionInfo> getConfigSessionInfos (IDSSXMLSessionId.IMasterSessionId iMasterSessionId)

getConfigSessionInfos gets a list of all the Config Session Info objects under the input Master Session Id. Guaranteed to not be null, but it may be empty

Returns
  • a guaranteed not null list of Config Session Info objects. Note, the list may be empty

public static ACMSessionIdResolver getInstance ()

getInstance will return the singleton ACMSessionIdResolver instance. It must be a singleton, that way all the session ids are managed together

Returns
  • the singletone instance of the ACMSessionIdResolver

public RWLock getLock ()

public ACMMasterSessionBundle getMasterSessionBundle (IDSSXMLSessionId.IMasterSessionId iMasterSessionId)

public IDSSXMLSessionId.IMasterSessionId getMasterSessionId (String iSessionId)

getMasterSessionId finds and returns the Master Session Id associated with the input session id. If the input session id is already a Master it is returned. If the input session id is a project or configuration session id, it's associated Master is returned. If the input session id is not found, which can happen if the session id was created using the old CreateSession methods, then null is returned.

Returns
  • the Master Session Id of the input iSessionId, or null if not in the maps

public List<IDSSXMLSessionId.IMasterSessionId> getMasterSessionIds (String iUserLogin)

Parameters
iUserLogin the user login
Returns
  • a collection of master session ids indexed by user login

public boolean getNeedReadUserAffinity ()

public List<String> getPidsOfConfigSession (IDSSXMLSessionId.IConfigSessionId iConfigSessionId)

@return

public IDSSXMLSessionId.IConfigSessionId getPreferredConfigSessionId (IDSSXMLSessionId.IMasterSessionId iMasterSessionId)

getPreferredConfigSessionId will find an existing config session and return it, or it will create a new one. Guaranteed to not return null. If a failure to create a new connection occurs, this method will throw a MSTRWebAPIException@return

public IDSSXMLSessionId.IConfigSessionId getPreferredConfigSessionId (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, boolean iReturnNullIfNotFound)

getPreferredConfigSessionId will find an existing config session and return it. If iReturnNullIfNotFound is true and no session currently exists, it will return null. If iReturnNullIfNotFound is false, then this method behaves exactly like getPreferredConfigSessionId@return

public String getProjectId (IDSSXMLSessionId.IProjectSessionId iProjectSessionId)

getProjectId gets the Project Id for the input Project Session Id

Returns
  • A project Id
Throws
MSTRWebAPIException if the Project Session Id is not found

public IDSSXMLSessionId.IProjectSessionId getProjectSessionId (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iProjectId)

getProjectSessionId gets an existing Project Session Id for the input Configuration Session Id/Project Id combination. If its not found, null is returned

public List<ACMSessionIdResolver.ProjectSessionInfo> getProjectSessionInfos (IDSSXMLSessionId.IMasterSessionId iMasterSessionId)

getProjectSessionInfos gets a list of all the Project Session Info objects under the input Master Session Id.

Returns
  • a guaranteed not null list of Project Session Info objects. Note, the list may be empty

public ACMSessionIdResolver.ServersToConnect getServersToConnect (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iProjectId, String iServerName, boolean iUserFencing)

getServersToConnect returns an ordered list of all the IServers that can be used to connect to the Project. You should connect to these from the first one being the most preferable. All IServers that cannot be used (does not have the project, or are fenced out) will not be in this list getServerToConnect@return

Parameters
iMasterSessionId the Master Session Id to be used to gather the information
iProjectId the GUID project Id
iServerName One IServer Name in the cluster
iUserFencing true means to utilize User Fencing

public ACMSessionBundle getSessionBundle (IDSSXMLSessionId iSessionId)

getSessionBundle gets the ACMSessionBundle associated with the input session id

Parameters
iSessionId the session id
Returns
  • the ACMSessionBundle

public IDSSXMLSessionId getSessionId (String iSessionId)

getSessionId gets the Master, Configuration, or Project Session Id. If the Session Id does not exist in the maps, then null is returned

public ACMTimeToLive getTtl (IDSSXMLSessionId iSessionId)

getTtl gets the time-to-live for the input session id

Parameters
iSessionId the session id to retrieve the time-to-live
Returns
  • the time-to-live

public static boolean getUseAsymmetricClustering ()

public int getUserAffinity ()

public String getUserLogin (IDSSXMLSessionId.IMasterSessionId iMasterSessionId)

@return

public List<ACMSessionDistributionHelper.ProjectFenceTier> getUserProjectFenceTier (String iUserLogin)

@return

public String printContents ()

printContents prints out to a log file all the contents of the maps. This is useful for debugging

public Collection<IDSSXMLSessionId> removeSessionId (IDSSXMLSessionId iSessionId)

removeSessionId removes the Session Ids (Configuration, Project Session Id) from the maps. The set of Session Ids that need to be closed as a result of this action is returned.

If the Session Id is a Master Session Id, then we may need to close all the associated Configuration and Project Session Ids too. That is why the removeSessionId() methods return a collection

public void removeUserProjectFenceTier (String iUserLogin)

public static IDSSXMLSessionId resolveSessionId (String iSessionID)

resolveSessionId resolves the Session ID. This will transform a Master Session Id into a Project Session Id if the Master Session Id has project id information. If this is an old fashioned session id (created with CreateSession or CreateSessionEx), it will simply return it; this maintains backward compatibility. If iReturnNullIfNotFound is false then if the master session id does not have the configuration or project session needed, then this method will create a new one. If iReturnNullIfNotFound is true, then this method will return null if the configuration or project session do not already exist

Parameters
iSessionID the session Id to resolve
Returns
  • the resolved session Id

public static IDSSXMLSessionId resolveSessionId (String iSessionID, boolean iReturnNullIfNotFound)

public void setTtls (IDSSXMLSessionId iSessionId, Calendar iTTL)

setTtls will update the TTL based on the time passed in for the input Session Id and it's associated Master Session Id. This is useful in the update thread where the actual time last used is gotten from the IServer directly and we now want to synch up

Parameters
iSessionId The session id associated with the session being set
iTTL The time the session was last used

public void setUserAffinity (int iUserAffinity)

public static synchronized void start (boolean iUseAsymmetricClustering)

start must be called at the beginning of the application, before sessions are created. This constructs the resources required for session creation. For example, an internal thread is created for managing the sessions.

In Web this is called by WebContextListener.contextInitialized()

public SimultaneousSessionCreationManager<IDSSXMLSessionId.IConfigSessionId> startCreateConfigSessionId (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iMachineName, int iPort)

startCreateConfigSessionId begins the process that adds a Config Session Id under the input Master Session Id SimultaneousSessionCreationManager.finish is used to finish the add

Parameters
iMasterSessionId an existing Master Session Id
iMachineName the name of the IServer
iPort the port of the IServer

public SimultaneousSessionCreationManager<IDSSXMLSessionId.IProjectSessionId> startCreateProjectSessionId (IDSSXMLSessionId.IMasterSessionId iMasterSessionId, String iProjectId)

startCreateProjectSessionId begins the process that adds a Project Session Id under the input Master Session Id SimultaneousSessionCreationManager.finish is used to finish the add

Parameters
iMasterSessionId an existing Master Session Id
iProjectId the GUID that represents the Project Id

public static void stop ()

stop should be called at the end of the application, after all session creations are complete. This will free the resources for session creation. For example, the internal thread is closed.

In Web this is called by WebContextListener.contextDestroyed()

public void stopThread ()

stopThread will stop the ACMRefreshThread. Use this at shut down. stopThread will internally call wakeThread so there is no need to call both