@Component(value="cuba_UserSessions") public class UserSessions extends java.lang.Object implements UserSessionsAPI
Modifier and Type | Class and Description |
---|---|
static class |
UserSessions.UserSessionInfo |
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.util.UUID,UserSessions.UserSessionInfo> |
cache |
protected ClusterManagerAPI |
clusterManager |
protected int |
expirationTimeout |
protected Metadata |
metadata |
protected UserSession |
NO_USER_SESSION |
protected int |
sendTimeout |
protected ServerConfig |
serverConfig |
protected TimeSource |
timeSource |
protected int |
touchTimeout |
protected UserSessionLog |
userSessionLog |
NAME
Constructor and Description |
---|
UserSessions() |
Modifier and Type | Method and Description |
---|---|
void |
add(UserSession session)
INTERNAL.
|
protected UserSessionEntity |
createUserSessionEntity(UserSession session,
long since,
long lastUsedTs) |
java.util.List<java.util.UUID> |
findUserSessionsByAttribute(java.lang.String attributeName,
java.lang.Object attributeValue) |
UserSession |
get(java.util.UUID id)
Get user session from cache.
|
UserSession |
getAndRefresh(java.util.UUID id)
Get user session from cache, updating its "last used" timestamp.
|
UserSession |
getAndRefresh(java.util.UUID id,
boolean propagate)
Get user session from cache, updating its "last used" timestamp and optionally propagating the new timestamp
to the cluster.
|
UserSession |
getAndRefreshNN(java.util.UUID id)
Get user session from cache, updating its "last used" timestamp.
|
UserSession |
getAndRefreshNN(java.util.UUID id,
boolean propagate)
Get user session from cache, updating its "last used" timestamp and optionally propagating the new timestamp
to the cluster.
|
int |
getExpirationTimeoutSec()
INTERNAL.
|
UserSession |
getNN(java.util.UUID id)
Get user session from cache.
|
int |
getSendTimeoutSec()
INTERNAL.
|
protected UserSessions.UserSessionInfo |
getSessionInfo(java.util.UUID id) |
protected java.util.stream.Stream<UserSessions.UserSessionInfo> |
getSessionInfoStream() |
java.util.stream.Stream<UserSessionEntity> |
getUserSessionEntitiesStream()
Stream of non-persistent entities representing active user sessions.
|
java.util.Collection<UserSessionEntity> |
getUserSessionInfo() |
java.util.stream.Stream<UserSession> |
getUserSessionsStream()
Stream of active user sessions.
|
protected UserSession |
internalGet(java.util.UUID id,
boolean touch,
boolean propagate) |
void |
killSession(java.util.UUID id)
INTERNAL.
|
void |
processEviction()
INTERNAL.
|
void |
propagate(java.util.UUID id)
INTERNAL.
|
protected void |
putSessionInfo(java.util.UUID id,
UserSessions.UserSessionInfo info) |
protected void |
receiveClusterMessage(UserSessions.UserSessionInfo message) |
protected void |
receiveClusterState(byte[] state) |
void |
remove(UserSession session)
INTERNAL.
|
protected UserSessions.UserSessionInfo |
removeSessionInfo(java.util.UUID id) |
protected byte[] |
sendClusterState() |
void |
setClusterManager(ClusterManagerAPI clusterManager) |
void |
setConfiguration(Configuration configuration) |
void |
setExpirationTimeoutSec(int value)
INTERNAL.
|
void |
setSendTimeoutSec(int timeout)
INTERNAL.
|
protected long |
toMillis(int seconds) |
protected java.util.Map<java.util.UUID,UserSessions.UserSessionInfo> cache
protected volatile int expirationTimeout
protected volatile int sendTimeout
protected volatile int touchTimeout
protected ClusterManagerAPI clusterManager
protected UserSession NO_USER_SESSION
protected ServerConfig serverConfig
@Inject protected TimeSource timeSource
@Inject protected Metadata metadata
@Inject protected UserSessionLog userSessionLog
@Inject public void setConfiguration(Configuration configuration)
@Inject public void setClusterManager(ClusterManagerAPI clusterManager)
protected void receiveClusterMessage(UserSessions.UserSessionInfo message)
protected void receiveClusterState(byte[] state)
protected byte[] sendClusterState()
public void add(UserSession session)
UserSessionsAPI
add
in interface UserSessionsAPI
public void remove(UserSession session)
UserSessionsAPI
remove
in interface UserSessionsAPI
@Nullable public UserSession get(java.util.UUID id)
UserSessionsAPI
get
in interface UserSessionFinder
get
in interface UserSessionsAPI
id
- session idpublic UserSession getNN(java.util.UUID id)
UserSessionsAPI
getNN
in interface UserSessionsAPI
id
- session id@Nullable public UserSession getAndRefresh(java.util.UUID id)
UserSessionsAPI
getAndRefresh
in interface UserSessionsAPI
id
- session idpublic UserSession getAndRefreshNN(java.util.UUID id)
UserSessionsAPI
getAndRefreshNN
in interface UserSessionsAPI
id
- session id@Nullable public UserSession getAndRefresh(java.util.UUID id, boolean propagate)
UserSessionsAPI
getAndRefresh
in interface UserSessionsAPI
id
- session idpropagate
- whether to propagate the new "last used" timestamp to the clusterpublic UserSession getAndRefreshNN(java.util.UUID id, boolean propagate)
UserSessionsAPI
getAndRefreshNN
in interface UserSessionsAPI
id
- session idpropagate
- whether to propagate the new "last used" timestamp to the cluster@Nullable protected UserSession internalGet(java.util.UUID id, boolean touch, boolean propagate)
public void propagate(java.util.UUID id)
UserSessionsAPI
propagate
in interface UserSessionsAPI
id
- session id. If session with this id is not found, does nothing.public int getExpirationTimeoutSec()
UserSessionsAPI
getExpirationTimeoutSec
in interface UserSessionsAPI
UserSessionsAPI.setExpirationTimeoutSec(int)
public void setExpirationTimeoutSec(int value)
UserSessionsAPI
setExpirationTimeoutSec
in interface UserSessionsAPI
value
- timeout in secondspublic int getSendTimeoutSec()
UserSessionsAPI
getSendTimeoutSec
in interface UserSessionsAPI
UserSessionsAPI.setSendTimeoutSec(int)
public void setSendTimeoutSec(int timeout)
UserSessionsAPI
UserSessionsAPI.getAndRefresh(java.util.UUID)
,
the user session is sent to the cluster only after the specified timeout.setSendTimeoutSec
in interface UserSessionsAPI
timeout
- in secondspublic java.util.Collection<UserSessionEntity> getUserSessionInfo()
getUserSessionInfo
in interface UserSessionsAPI
protected UserSessionEntity createUserSessionEntity(UserSession session, long since, long lastUsedTs)
public java.util.stream.Stream<UserSessionEntity> getUserSessionEntitiesStream()
UserSessionsAPI
getUserSessionEntitiesStream
in interface UserSessionsAPI
public java.util.stream.Stream<UserSession> getUserSessionsStream()
UserSessionsAPI
getUserSessionsStream
in interface UserSessionsAPI
public void killSession(java.util.UUID id)
UserSessionsAPI
killSession
in interface UserSessionsAPI
id
- session idpublic java.util.List<java.util.UUID> findUserSessionsByAttribute(java.lang.String attributeName, java.lang.Object attributeValue)
findUserSessionsByAttribute
in interface UserSessionsAPI
public void processEviction()
UserSessionsAPI
processEviction
in interface UserSessionsAPI
protected UserSessions.UserSessionInfo getSessionInfo(java.util.UUID id)
protected void putSessionInfo(java.util.UUID id, UserSessions.UserSessionInfo info)
@Nullable protected UserSessions.UserSessionInfo removeSessionInfo(java.util.UUID id)
protected java.util.stream.Stream<UserSessions.UserSessionInfo> getSessionInfoStream()
protected long toMillis(int seconds)