Package com.microstrategy.webapi
Class ACMSessionIdResolver
- java.lang.Object
-
- com.microstrategy.webapi.ACMSessionIdResolver
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class ACMSessionIdResolver extends java.lang.Object implements java.lang.AutoCloseableACMSessionIdResolver 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classACMSessionIdResolver.ClearInfostatic classACMSessionIdResolver.ConfigSessionInfostatic classACMSessionIdResolver.EnumInfoEnumInfo is an immutable struct to hold a copy of the information in the maps.static classACMSessionIdResolver.MasterSessionInfoMasterSessionInfo is an immutable struct to hold a copy of the information in the maps.static classACMSessionIdResolver.ProjectSessionInfoProjectSessionInfo is an immutable struct to hold a copy of the information in the maps.static classACMSessionIdResolver.ProjectsToConnectProjectsToConnect is an immutable class so that the Csid and related Psids can be returned from getAllProjectsToConnect()classACMSessionIdResolver.SeamlessSessionstatic interfaceACMSessionIdResolver.SessionIdInfostatic classACMSessionIdResolver.SimultaneousSessionCreationManager<T extends IDSSXMLSessionId>static classACMSessionIdResolver.SSCMConfigSessionInfostatic classACMSessionIdResolver.SSCMPreferredConfigSessionInfostatic classACMSessionIdResolver.SSCMProjectSessionInfostatic interfaceACMSessionIdResolver.SSCMSessionTypeInfo<T extends IDSSXMLSessionId>static classACMSessionIdResolver.SymmetricReuseSessionReconstructorSymmetricReuseSessionReconstructor 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.
-
Field Summary
Fields Modifier and Type Field Description static longCOMPARE_PORTSstatic longNO_FAILOVERstatic longONLY_RECONSTRUCT_CONFIG_SESSIONstatic longRECONSTRUCT_SESSIONS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddCrossProjectCache(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId, java.util.Collection<java.lang.String> iPids)addCrossProjectCache sets the project ids that can be used with the iConfigSessionId.voidcleanUpReplacedRememberMeCookie(long iDelayMillis)cleanUpReplacedRememberMeCookiehelper method to clean up a replaced remember me cookie in the mapjava.util.Map<IDSSXMLSessionId.IMasterSessionId,ACMSessionIdResolver.ClearInfo>clear()clear removes all session ids (Master, Configuration and Project Session Ids) from the maps.voidclose()close shuts down the internal scheduler and waits for it to destroy the threadjava.util.Optional<IDSSXMLSessionId.IMasterSessionId>convertToMasterSessionId(IDSSXMLSessionId iSessionId)convertToMasterSessionIdusesiSessionIdto find the Master Session Id.voidcreateConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId, ACMClusterInfo iClusterInfo)createConfigSessionId adds a Configuration Session Id under the input Master Session IdIDSSXMLSessionId.IMasterSessionIdcreateMasterSessionId(IDSSXMLSessionId.IConfigSessionId iConfigSessionId, java.util.Optional<IDSSXMLSessionId.IProjectSessionId> iProjectSessionIdOpt, java.util.Optional<java.lang.String> iProjectIdOpt, 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.IDSSXMLSessionId.IConfigSessionIdcreateNewConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.util.Optional<java.util.HashSet<com.microstrategy.webapi.ACMClusterMapKey.Key>> iNodesToExclude)ACMSessionIdResolver.EnumInfoenumSids()enumCsids will return a copy of all the session ids.voidextendTtlsByIdleTimeout(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.ProjectsToConnectgetAllProjectsToConnect(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.util.Collection<java.lang.String> iProjectIds)getAllProjectsToConnect returns a list of Project Ids that need to be connected for the given existing and valid Master Session IdintgetApplicationType(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)getApplicationTypegets the application type from where the Master Session Id was created.IDSSXMLSessionId.IConfigSessionIdgetConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.String iMachineName, int iMachinePort)java.util.Collection<ACMSessionIdResolver.ConfigSessionInfo>getConfigSessionInfos(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)getConfigSessionInfosgets a collection of config session infos associated with the master session id.
O(N) where N is the number of config sessions associated with this master session idjava.util.Set<java.lang.String>getCrossProjectCache(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId)getCrossProjectCache gets project ids that can be used with the iConfigSessionId.static ACMSessionIdResolvergetInstance()getInstance will return the singleton ACMSessionIdResolver instance.RWLockgetLock()java.util.Collection<ACMClusterInfo>getMachinesWithConfigSessions(java.lang.String iUserL, java.lang.String iClusterName, com.microstrategy.webapi.ACMUserMaps.FILTER iFilter)getMachinesWithConfigSessionsgets a collection ofACMClusterInfoobjects.ACMMasterSessionBundlegetMasterSessionBundle(IDSSXMLSessionId iSessionId)getMasterSessionBundleatomically finds the session id in the Maps and returns the associated master session bundleACMMasterSessionBundlegetMasterSessionBundle(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)getMasterSessionBundleatomically finds the master session id in the Maps and returns the associated master session bundleIDSSXMLSessionId.IMasterSessionIdgetMasterSessionId(java.lang.String iSessionId)getMasterSessionId finds and returns the Master Session Id associated with the input session id.IDSSXMLSessionId.IMasterSessionIdgetMasterSessionIdByRememberMeToken(java.lang.String iToken)get the master session Id using the remember me token past in from clientbooleangetNeedReadUserAffinity()getNeedReadUserAffinity checks if the User Affinity cache is expired or not.IDSSXMLSessionId.IConfigSessionIdgetPreferredConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.util.Optional<java.util.HashSet<com.microstrategy.webapi.ACMClusterMapKey.Key>> iNodesToExclude, boolean iReturnNullIfNotFound)getPreferredConfigSessionId will find an existing config session and return it.longgetProcessFlags()getProcessFlagsis used by the application to set the way session management operates.com.microstrategy.webapi.ACMProjectFenceTierCachegetProjectFenceTierCache()java.lang.StringgetProjectId(IDSSXMLSessionId.IProjectSessionId iProjectSessionId)getProjectId gets the Project Id for the input Project Session IdIDSSXMLSessionId.IProjectSessionIdgetProjectSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.String iProjectId)getProjectSessionId gets an existing Project Session Id for the input Configuration Session Id/Project Id combination.java.util.List<ACMSessionIdResolver.ProjectSessionInfo>getProjectSessionInfos(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)getProjectSessionInfos gets a list of all the Project Session Info objects under the input Master Session Id.intgetRememberMeTimeoutByMasterSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)Returns the remember me periods in seconds associated with the master session Id if master session Id is not found in the map, then return -1java.lang.StringgetRememberMeTokenByMasterSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)get the remember me token to be used by client as cookie using the master session IdACMSessionBundlegetSessionBundle(IDSSXMLSessionId iSessionId)getSessionBundle gets the ACMSessionBundle associated with the input session idIDSSXMLSessionIdgetSessionId(java.lang.String iSessionId)getSessionId gets the Master, Configuration, or Project Session Id.ACMTimeToLivegetTtl(IDSSXMLSessionId iSessionId)getTtl gets the time-to-live for the input session idstatic booleangetUseAsymmetricClustering()booleangetUserAffinity()java.lang.StringgetUserLogin(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)getUserLogingets the user login associated with the master session id.
O(1)booleanisProcessFlagOn(long iFlag)isProcessFlagOnis a convenience method to check if a flag is on or off.java.lang.StringprintContents()printContents prints out to a log file all the contents of the maps.voidremoveCrossProjectCache(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)removeCrossProjectCache removes all the Config SessionIds and projects for the Master Session Id from the internal cachejava.util.Collection<IDSSXMLSessionId>removeSessionId(IDSSXMLSessionId iSessionId)removeSessionId removes the Session Ids (Configuration, Project Session Id) from the maps.java.util.Collection<IDSSXMLSessionId>removeSessionIds(java.util.Collection<IDSSXMLSessionId.IConfigSessionId> iConfigSessionIds)removeSessionIdsfor each Config Session in the passed in iConfigSessionIds collection, removes the Session Ids (Configuration, Project Session Id) from the maps.java.lang.StringresolveClusterName(java.lang.String iNodeName, int iPort)resolveClusterNameresolves the iNodeName and iPort into the associated cluster namestatic IDSSXMLSessionIdresolveSessionId(java.lang.String iSessionID)resolveSessionId resolves the Session ID.static IDSSXMLSessionId.IConfigSessionIdresolveSessionId(java.lang.String iMasterSessionId, java.lang.String iNodeName, int iPort)resolveSessionId resolves a MasterSession ID to a configuration session ID to a specific nodestatic IDSSXMLSessionIdresolveSessionIdNoCreation(java.lang.String iSessionID)voidsetProcessFlags(long iProcessFlags)setProcessFlagsis used by the application to set the way session management operates.voidsetTtls(IDSSXMLSessionId iSessionId, java.util.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.voidsetUserAffinity(boolean iUserAffinity)static voidstart(boolean iUseAsymmetricClustering)Deprecated.ACMSessionIdResolver.SimultaneousSessionCreationManager<IDSSXMLSessionId.IConfigSessionId>startCreateConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.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 addACMSessionIdResolver.SimultaneousSessionCreationManager<IDSSXMLSessionId.IConfigSessionId>startCreatePreferredConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)ACMSessionIdResolver.SimultaneousSessionCreationManager<IDSSXMLSessionId.IProjectSessionId>startCreateProjectSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.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 addstatic voidstop()stop should be called at the end of the application, after all session creations are complete.voidstopThread()stopThread will stop the ACMRefreshThread.java.lang.StringupdateRememberMeToken(java.lang.String iToken, java.lang.String iMasterSessionId)update the master session Id to remember me token map with a new remember me token and return back to the client to use as cookie
-
-
-
Field Detail
-
RECONSTRUCT_SESSIONS
public static final long RECONSTRUCT_SESSIONS
- See Also:
- Constant Field Values
-
COMPARE_PORTS
public static final long COMPARE_PORTS
- See Also:
- Constant Field Values
-
ONLY_RECONSTRUCT_CONFIG_SESSION
public static final long ONLY_RECONSTRUCT_CONFIG_SESSION
- See Also:
- Constant Field Values
-
NO_FAILOVER
public static final long NO_FAILOVER
- See Also:
- Constant Field Values
-
-
Method Detail
-
getProcessFlags
public long getProcessFlags()
getProcessFlagsis used by the application to set the way session management operates. Possible flags include:RECONSTRUCT_SESSIONSwill receive config and project sessions from save/restore and then only reconstruct a config sessionCOMPARE_PORTSwill use the port of IServer to differentiate IServers. This allows more than one IServer to exist on the same ip addressONLY_RECONSTRUCT_CONFIG_SESSIONwill receive config and project sessions from save/restore and then only reconstruct a config session.RECONSTRUCT_SESSIONSflag must also be on.- Returns:
- the process flags which is a bit map
-
isProcessFlagOn
public boolean isProcessFlagOn(long iFlag)
isProcessFlagOnis a convenience method to check if a flag is on or off. It releives the caller from having to do complex bit operations. Possible flags include:RECONSTRUCT_SESSIONSwill receive config and project sessions from save/restore and then only reconstruct a config sessionCOMPARE_PORTSwill use the port of IServer to differentiate IServers. This allows more than one IServer to exist on the same ip addressONLY_RECONSTRUCT_CONFIG_SESSIONwill receive config and project sessions from save/restore and then only reconstruct a config session.RECONSTRUCT_SESSIONSflag must also be on.- Returns:
- true is the flag is on
-
setProcessFlags
public void setProcessFlags(long iProcessFlags)
setProcessFlagsis used by the application to set the way session management operates. Possible flags include:RECONSTRUCT_SESSIONSwill receive config and project sessions from save/restore and then only reconstruct a config sessionCOMPARE_PORTSwill use the port of IServer to differentiate IServers. This allows more than one IServer to exist on the same ip addressONLY_RECONSTRUCT_CONFIG_SESSIONwill receive config and project sessions from save/restore and then only reconstruct a config session.RECONSTRUCT_SESSIONSflag must also be on.- Parameters:
iProcessFlags- is a bit map of the entire set of flags to turn on
-
start
@Deprecated public static void start(boolean iUseAsymmetricClustering)
Deprecated.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()
-
stop
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()
-
getNeedReadUserAffinity
public boolean getNeedReadUserAffinity()
getNeedReadUserAffinity checks if the User Affinity cache is expired or not. If the cache is expired the caller of this method is expected to refresh the cache- Returns:
- true if the
-
getUserAffinity
public boolean getUserAffinity()
-
setUserAffinity
public void setUserAffinity(boolean iUserAffinity)
-
getUseAsymmetricClustering
public static boolean getUseAsymmetricClustering()
-
getInstance
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
-
resolveSessionId
public static IDSSXMLSessionId.IConfigSessionId resolveSessionId(java.lang.String iMasterSessionId, java.lang.String iNodeName, int iPort) throws MSTRWebAPIException
resolveSessionId resolves a MasterSession ID to a configuration session ID to a specific node- Parameters:
iMasterSessionId- the Master Session Id to resolveiNodeName- the Intelligence Server to get the information- Returns:
- the resolved configuration session Id
- Throws:
MSTRWebAPIException
-
resolveSessionId
public static IDSSXMLSessionId resolveSessionId(java.lang.String iSessionID) throws MSTRWebAPIException
resolveSessionId resolves the Session ID. This will transform a Master Session Id into an IServer recognized Session Id (either a config or a project session id). If the Master Session Id has project id information the return will be a Project Session Id to that project. If the Master Session Id does not have project id information the return will be a Config Session Id (the preferred config session).
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 there is no existing Project Session Id or Config Session Id associated with the Master Session Id then this method will create a new one. This allows users to create a Master Session Id and then use it to whatever they want, relying on the system to do lazy creation at the moment session ids are needed. It also allows failover to create new sessions on the fly once an old session was recognized as bad (IServer hosting that session has crashed/hung or the project was unloaded, etc)
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
- Throws:
MSTRWebAPIException- if no sessions can be
-
resolveSessionIdNoCreation
public static IDSSXMLSessionId resolveSessionIdNoCreation(java.lang.String iSessionID)
-
createNewConfigSessionId
public IDSSXMLSessionId.IConfigSessionId createNewConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.util.Optional<java.util.HashSet<com.microstrategy.webapi.ACMClusterMapKey.Key>> iNodesToExclude) throws MSTRWebAPIException
- Throws:
MSTRWebAPIException
-
stopThread
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
-
getLock
public RWLock getLock()
-
enumSids
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
-
getMasterSessionBundle
public ACMMasterSessionBundle getMasterSessionBundle(IDSSXMLSessionId iSessionId) throws MSTRWebAPIException
getMasterSessionBundleatomically finds the session id in the Maps and returns the associated master session bundle- Parameters:
iSessionId- a session id (may be config, project or master)- Returns:
- the master session id bundle. Guaranteed to not be null
- Throws:
MSTRWebAPIException- if the master session bundle is not found
-
getMasterSessionBundle
public ACMMasterSessionBundle getMasterSessionBundle(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
getMasterSessionBundleatomically finds the master session id in the Maps and returns the associated master session bundle- Parameters:
iMasterSessionId- must be a master session id- Returns:
- the master session id bundle. Returns null if not found
-
resolveClusterName
public java.lang.String resolveClusterName(java.lang.String iNodeName, int iPort) throws MSTRWebAPIExceptionresolveClusterNameresolves the iNodeName and iPort into the associated cluster name- Parameters:
iNodeName-iPort-- Returns:
- Cluster name. Guaranteed to not be null
- Throws:
MSTRWebAPIException- is the cluster cannot be found
-
getTtl
public ACMTimeToLive getTtl(IDSSXMLSessionId iSessionId) throws MSTRWebAPIException
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
- Throws:
MSTRWebAPIException
-
getSessionBundle
public ACMSessionBundle getSessionBundle(IDSSXMLSessionId iSessionId) throws MSTRWebAPIException
getSessionBundle gets the ACMSessionBundle associated with the input session id- Parameters:
iSessionId- the session id- Returns:
- the ACMSessionBundle
- Throws:
MSTRWebAPIException
-
createMasterSessionId
public IDSSXMLSessionId.IMasterSessionId createMasterSessionId(IDSSXMLSessionId.IConfigSessionId iConfigSessionId, java.util.Optional<IDSSXMLSessionId.IProjectSessionId> iProjectSessionIdOpt, java.util.Optional<java.lang.String> iProjectIdOpt, ACMJwt iJwt, ACMGSSCredential iGSSCredential, ACMCreateSessionParams iCSParams, ACMClusterInfo iClusterInfo, int iIServerSessionIdleTimeout, boolean iIsCloseable) throws MSTRWebAPIException
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 IdiJwt- the Jwt that was returned with the Configuration Session IdiGSSCredential- the kerberos credentials to the kerberos serveriCSParams- the parameters used to create the Configuration Session IdiClusterInfo-- 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
-
createConfigSessionId
public void createConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId, ACMClusterInfo iClusterInfo) throws MSTRWebAPIException
createConfigSessionId adds a Configuration Session Id under the input Master Session Id- Parameters:
iMasterSessionId- an existing Master Session IdiConfigSessionId- a new Configuration Session Id to be added to the mapsiClusterInfo-- Throws:
MSTRWebAPIException
-
getProjectSessionInfos
public java.util.List<ACMSessionIdResolver.ProjectSessionInfo> getProjectSessionInfos(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
getProjectSessionInfos gets a list of all the Project Session Info objects under the input Master Session Id.- Parameters:
iMasterSessionId-- Returns:
- a guaranteed not null list of Project Session Info objects. Note, the list may be empty
-
getConfigSessionInfos
public java.util.Collection<ACMSessionIdResolver.ConfigSessionInfo> getConfigSessionInfos(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
getConfigSessionInfosgets a collection of config session infos associated with the master session id.
O(N) where N is the number of config sessions associated with this master session id- Parameters:
iMasterSessionId- the master session id- Returns:
- collection of
ConfigSessionInfo. Guaranteed to not be null but may be empty
-
getProjectId
public java.lang.String getProjectId(IDSSXMLSessionId.IProjectSessionId iProjectSessionId) throws MSTRWebAPIException
getProjectId gets the Project Id for the input Project Session Id- Parameters:
iProjectSessionId-- Returns:
- A project Id
- Throws:
MSTRWebAPIException- if the Project Session Id is not found
-
getAllProjectsToConnect
public ACMSessionIdResolver.ProjectsToConnect getAllProjectsToConnect(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.util.Collection<java.lang.String> iProjectIds) throws MSTRWebAPIException
getAllProjectsToConnect returns a list of Project Ids that need to be connected for the given existing and valid Master Session Id- Throws:
MSTRWebAPIException
-
removeSessionId
public java.util.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.- Parameters:
iSessionId-- Returns:
-
removeSessionIds
public java.util.Collection<IDSSXMLSessionId> removeSessionIds(java.util.Collection<IDSSXMLSessionId.IConfigSessionId> iConfigSessionIds)
removeSessionIdsfor each Config Session in the passed in iConfigSessionIds collection, 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.- Parameters:
iConfigSessionIds-- Returns:
-
clear
public java.util.Map<IDSSXMLSessionId.IMasterSessionId,ACMSessionIdResolver.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
-
printContents
public java.lang.String printContents()
printContents prints out to a log file all the contents of the maps. This is useful for debugging- Throws:
MSTRWebAPIException
-
getSessionId
public IDSSXMLSessionId getSessionId(java.lang.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- Parameters:
iSessionId-- Returns:
-
convertToMasterSessionId
public java.util.Optional<IDSSXMLSessionId.IMasterSessionId> convertToMasterSessionId(IDSSXMLSessionId iSessionId)
convertToMasterSessionIdusesiSessionIdto find the Master Session Id. TheiSessionIdmay be a config/project/master session id that is currently alive or even if it had existed before but then had been closed/killed due to a failure and failover.
This allows clients to re-resolve the master session id even when the user has the direct session id to the IServer (project session id or config session id). Only legacy client code will have a reference to the IServer session; all new code should make sure it only has a master session id.
The returned Master Session Id can be used as if it were an IServer session id. Calling resolve() will resolve it into either the config or project session id.- Parameters:
iSessionId-- Returns:
-
getMasterSessionId
public IDSSXMLSessionId.IMasterSessionId getMasterSessionId(java.lang.String iSessionId) throws MSTRWebAPIException
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.- Parameters:
iSessionId-- Returns:
- the Master Session Id of the input iSessionId, or null if not in the maps
- Throws:
MSTRWebAPIException
-
getRememberMeTimeoutByMasterSessionId
public int getRememberMeTimeoutByMasterSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
Returns the remember me periods in seconds associated with the master session Id if master session Id is not found in the map, then return -1- Returns:
-
getRememberMeTokenByMasterSessionId
public java.lang.String getRememberMeTokenByMasterSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
get the remember me token to be used by client as cookie using the master session Id- Parameters:
iMasterSessionId- the master session Id- Returns:
- the remember me token to be used by client as cookie, it returns null if the master session Id is not in the map
-
updateRememberMeToken
public java.lang.String updateRememberMeToken(java.lang.String iToken, java.lang.String iMasterSessionId)update the master session Id to remember me token map with a new remember me token and return back to the client to use as cookie- Parameters:
iToken- the remember me token past in from client- Returns:
- a new remember me token, it returns the old remember me token if the master session Id is not found in the map using the old token
-
getMasterSessionIdByRememberMeToken
public IDSSXMLSessionId.IMasterSessionId getMasterSessionIdByRememberMeToken(java.lang.String iToken)
get the master session Id using the remember me token past in from client- Parameters:
iToken- the remember me token past in from client- Returns:
- the master session Id mapping to the remember me token, it returns null if token is not in the map
-
cleanUpReplacedRememberMeCookie
public void cleanUpReplacedRememberMeCookie(long iDelayMillis)
cleanUpReplacedRememberMeCookiehelper method to clean up a replaced remember me cookie in the map- Parameters:
iDelayMillis- - the time in millisecond since the first access of the remember me cookie
-
extendTtlsByIdleTimeout
public void extendTtlsByIdleTimeout(IDSSXMLSessionId iSessionId) throws MSTRWebAPIException
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- Throws:
MSTRWebAPIException
-
setTtls
public void setTtls(IDSSXMLSessionId iSessionId, java.util.Calendar iTTL) throws MSTRWebAPIException
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 setiTTL- The time the session was last used- Throws:
MSTRWebAPIException
-
getConfigSessionId
public IDSSXMLSessionId.IConfigSessionId getConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.String iMachineName, int iMachinePort)
-
getPreferredConfigSessionId
public IDSSXMLSessionId.IConfigSessionId getPreferredConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.util.Optional<java.util.HashSet<com.microstrategy.webapi.ACMClusterMapKey.Key>> iNodesToExclude, boolean iReturnNullIfNotFound) throws MSTRWebAPIException
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- Parameters:
iMasterSessionId-iReturnNullIfNotFound-- Returns:
- Throws:
MSTRWebAPIException
-
getApplicationType
public int getApplicationType(IDSSXMLSessionId.IMasterSessionId iMasterSessionId) throws MSTRWebAPIException
getApplicationTypegets the application type from where the Master Session Id was created.- Parameters:
iMasterSessionId-- Returns:
- the application type. See
EnumDSSXMLApplicationTypefor possible types. - Throws:
MSTRWebAPIException- if the Master Session Id does not exist
-
getProjectSessionId
public IDSSXMLSessionId.IProjectSessionId getProjectSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.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
-
addCrossProjectCache
public void addCrossProjectCache(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId, java.util.Collection<java.lang.String> iPids)
addCrossProjectCache sets the project ids that can be used with the iConfigSessionId. This method just sets an internal cache that can be used later- Parameters:
iMasterSessionId-iConfigSessionId-iPids-
-
removeCrossProjectCache
public void removeCrossProjectCache(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
removeCrossProjectCache removes all the Config SessionIds and projects for the Master Session Id from the internal cache- Parameters:
iMasterSessionId-
-
getCrossProjectCache
public java.util.Set<java.lang.String> getCrossProjectCache(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, IDSSXMLSessionId.IConfigSessionId iConfigSessionId)
getCrossProjectCache gets project ids that can be used with the iConfigSessionId. The decision of which sessions is made elsewhere, this is just a cache of the decision.- Parameters:
iMasterSessionId-iConfigSessionId-- Returns:
- List of Pids that can be accessed via this config session. Guaranteed to not be null
-
getMachinesWithConfigSessions
public java.util.Collection<ACMClusterInfo> getMachinesWithConfigSessions(java.lang.String iUserL, java.lang.String iClusterName, com.microstrategy.webapi.ACMUserMaps.FILTER iFilter) throws MSTRWebAPIException
getMachinesWithConfigSessionsgets a collection ofACMClusterInfoobjects. The collection represents all the machines that the user has existing config sessions, filtered by the Cluster Name.
It's important to realize that the user may be logged into multiple clusters. And, the user may be logged into the same cluster multiple times.
This collection represents all the nodes where the user currently has config sessions. Any of them are fair game for user affinity.
iFilter controls the efficiency of the algorithm. It is often only required to have one of the machines. Use FILTER.ARBITRARY_ONE to arbitrarily pick one of the machines out of the collection.
When iFilter is ALL: O(M x C) where M is number of master session ids this one user has and C is the number of config session under the master session id. Simplified Session management feature guarantees this will be <= the number of nodes in the cluster. Although this seems inefficient M will tend to be on the order of 1-4 and the number of nodes in the cluster will tend to be on the order of 2-5.
When iFilter is ARBITRARY_ONE: O(1)- Parameters:
iUserL- the User LoginiClusterName- the Cluster NameiFilter- an enum to control the efficiency of the algorithm- Returns:
- the collection of
ACMClusterInfos associated with the UserLogin and cluster. Guaranteed to not be null, may be empty if user is not currently logged in - Throws:
MSTRWebAPIException
-
getUserLogin
public java.lang.String getUserLogin(IDSSXMLSessionId.IMasterSessionId iMasterSessionId) throws MSTRWebAPIException
getUserLogingets the user login associated with the master session id.
O(1)- Parameters:
iMasterSessionId- the master session id- Returns:
- the user login. Guaranteed to not be null.
- Throws:
MSTRWebAPIException- if the user cannot be found
-
getProjectFenceTierCache
public com.microstrategy.webapi.ACMProjectFenceTierCache getProjectFenceTierCache()
-
startCreateProjectSessionId
public ACMSessionIdResolver.SimultaneousSessionCreationManager<IDSSXMLSessionId.IProjectSessionId> startCreateProjectSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.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 IdiProjectId- the GUID that represents the Project Id- Throws:
MSTRWebAPIException
-
startCreateConfigSessionId
public ACMSessionIdResolver.SimultaneousSessionCreationManager<IDSSXMLSessionId.IConfigSessionId> startCreateConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId, java.lang.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 IdiMachineName- the name of the IServeriPort- the port of the IServer- Throws:
MSTRWebAPIException
-
startCreatePreferredConfigSessionId
public ACMSessionIdResolver.SimultaneousSessionCreationManager<IDSSXMLSessionId.IConfigSessionId> startCreatePreferredConfigSessionId(IDSSXMLSessionId.IMasterSessionId iMasterSessionId)
-
close
public void close()
close shuts down the internal scheduler and waits for it to destroy the thread- Specified by:
closein interfacejava.lang.AutoCloseable
-
-