|
Openfire 3.5.2 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jivesoftware.openfire.container.BasicModule org.jivesoftware.openfire.SessionManager
public class SessionManager
Manages the sessions associated with an account. The information maintained by the Session manager is entirely transient and does not need to be preserved between server restarts.
Field Summary | |
---|---|
static String |
C2S_INFO_CACHE_NAME
|
static String |
CM_CACHE_NAME
|
static String |
COMPONENT_SESSION_CACHE_NAME
|
static String |
ISS_CACHE_NAME
|
static int |
NEVER_KICK
|
Constructor Summary | |
---|---|
SessionManager()
|
Method Summary | |
---|---|
void |
addSession(LocalClientSession session)
Add a new session to be managed. |
void |
broadcast(Message packet)
Broadcasts the given data to all connected sessions. |
void |
broadcastPresenceToOtherResources(JID originatingResource,
Presence presence)
Broadcasts presence updates from the originating user's resource to any of the user's existing available resources (if any). |
void |
changePriority(LocalClientSession session,
int oldPriority)
Change the priority of a session, that was already available, associated with the sender. |
HttpSession |
createClientHttpSession(long rid,
InetAddress address,
StreamID id)
|
LocalClientSession |
createClientSession(Connection conn)
Creates a new ClientSession. |
LocalClientSession |
createClientSession(Connection conn,
StreamID id)
Creates a new ClientSession with the specified streamID. |
LocalComponentSession |
createComponentSession(JID address,
Connection conn)
|
LocalIncomingServerSession |
createIncomingServerSession(Connection conn,
StreamID id)
Creates a session for a remote server. |
LocalConnectionMultiplexerSession |
createMultiplexerSession(Connection conn,
JID address)
Creates a new ConnectionMultiplexerSession. |
int |
getActiveSessionCount(String username)
Returns the number of sessions for a user that are available. |
ComponentSession |
getComponentSession(String domain)
Returns the session of the component whose domain matches the specified domain. |
Collection<ComponentSession> |
getComponentSessions()
Returns a collection with the established sessions from external components. |
int |
getConflictKickLimit()
|
ConnectionMultiplexerSession |
getConnectionMultiplexerSession(JID address)
Returns the session originated from the specified address or null if none was found. |
List<ConnectionMultiplexerSession> |
getConnectionMultiplexerSessions()
Returns all sessions originated from connection managers. |
List<ConnectionMultiplexerSession> |
getConnectionMultiplexerSessions(String domain)
Returns a collection with all the sessions originated from the connection manager whose domain matches the specified domain. |
int |
getConnectionsCount(boolean onlyLocal)
Returns number of client sessions that are connected to the server. |
Collection<String> |
getIncomingServers()
Returns a collection with the hostnames of the remote servers that currently have an incoming server connection to this server. |
LocalIncomingServerSession |
getIncomingServerSession(String streamID)
Returns the incoming server session hosted by this JVM that matches the specified stream ID. |
List<IncomingServerSession> |
getIncomingServerSessions(String hostname)
Returns the list of sessions that were originated by a remote server. |
int |
getIncomingServerSessionsCount(boolean onlyLocal)
Returns number of sessions coming from remote servers. |
static SessionManager |
getInstance()
Returns the instance of SessionManagerImpl being used by the XMPPServer. |
Collection<String> |
getOutgoingServers()
Returns a collection with the hostnames of the remote servers that currently may receive packets sent from this server. |
OutgoingServerSession |
getOutgoingServerSession(String hostname)
Returns a session that was originated from this server to a remote server. |
Collection<String> |
getPreAuthenticatedKeys()
Returns the temporary keys used by the sessions that has not been authenticated yet. |
int |
getServerSessionIdleTime()
|
int |
getServerSessionTimeout()
Returns the number of milliseconds to elapse between clearing of idle server sessions. |
ClientSession |
getSession(JID from)
Returns the session responsible for this JID data. |
int |
getSessionCount(String username)
|
Cache<String,ClientSessionInfo> |
getSessionInfoCache()
|
Collection<ClientSession> |
getSessions()
Returns a list that contains all authenticated client sessions connected to the server. |
Collection<ClientSession> |
getSessions(SessionResultFilter filter)
|
Collection<ClientSession> |
getSessions(String username)
|
int |
getUserSessionsCount(boolean onlyLocal)
Returns number of client sessions that are authenticated with the server. |
Collection<String> |
getValidatedDomains(String streamID)
Returns a collection with all the domains, subdomains and virtual hosts that where validated. |
void |
initialize(XMPPServer server)
Initializes the basic module. |
boolean |
isActiveRoute(String username,
String resource)
|
boolean |
isAnonymousRoute(JID address)
|
boolean |
isAnonymousRoute(String username)
|
boolean |
isMultipleServerConnectionsAllowed()
Returns true if remote servers are allowed to have more than one connection to this server. |
boolean |
isPreAuthenticatedSession(JID address)
Returns true if the specified address belongs to a preauthenticated session. |
void |
joinedCluster()
Notification event indicating that this JVM is now part of a cluster. |
void |
joinedCluster(byte[] nodeID)
Notification event indicating that another JVM is now part of a cluster. |
void |
leftCluster()
Notification event indicating that this JVM is no longer part of the cluster. |
void |
leftCluster(byte[] nodeID)
Notification event indicating that another JVM is no longer part of the cluster. |
void |
markedAsSeniorClusterMember()
Notification event indicating that this JVM is now the senior cluster member. |
StreamID |
nextStreamID()
Returns a randomly created ID to be used in a stream element. |
void |
outgoingServerSessionCreated(LocalOutgoingServerSession session)
Notification message that a new OutgoingServerSession has been created. |
void |
registerIncomingServerSession(String hostname,
LocalIncomingServerSession session)
Registers that a server session originated by a remote server is hosting a given hostname. |
boolean |
removeSession(ClientSession session,
JID fullJID,
boolean anonymous,
boolean forceUnavailable)
Removes a session. |
boolean |
removeSession(LocalClientSession session)
Removes a session. |
void |
sendServerMessage(JID address,
String subject,
String body)
Sends a message with a given subject and body to one or more user sessions related to the specified address. |
void |
sendServerMessage(String subject,
String body)
Sends a message with a given subject and body to all the active user sessions in the server. |
void |
sessionAvailable(LocalClientSession session)
Notification message sent when a client sent an available presence for the session. |
void |
sessionUnavailable(LocalClientSession session)
Notification message sent when a client sent an unavailable presence for the session. |
void |
setConflictKickLimit(int limit)
|
void |
setMultipleServerConnectionsAllowed(boolean allowed)
Sets if remote servers are allowed to have more than one connection to this server. |
void |
setServerSessionIdleTime(int idleTime)
|
void |
setServerSessionTimeout(int timeout)
Sets the number of milliseconds to elapse between clearing of idle server sessions. |
void |
start()
Starts the basic module. |
void |
stop()
Stops the basic module. |
void |
unregisterIncomingServerSession(String hostname,
IncomingServerSession session)
Unregisters the specified remote server session originiated by the specified remote server. |
void |
userBroadcast(String username,
Packet packet)
Broadcasts the given data to all connected sessions for a particular user. |
Methods inherited from class org.jivesoftware.openfire.container.BasicModule |
---|
destroy, getName |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COMPONENT_SESSION_CACHE_NAME
public static final String CM_CACHE_NAME
public static final String ISS_CACHE_NAME
public static final String C2S_INFO_CACHE_NAME
public static final int NEVER_KICK
Constructor Detail |
---|
public SessionManager()
Method Detail |
---|
public static SessionManager getInstance()
SessionManagerImpl
being used by the XMPPServer.
SessionManagerImpl
being used by the XMPPServer.public ConnectionMultiplexerSession getConnectionMultiplexerSession(JID address)
address
- the address of the connection manager (including resource that identifies specific socket)
public List<ConnectionMultiplexerSession> getConnectionMultiplexerSessions()
public List<ConnectionMultiplexerSession> getConnectionMultiplexerSessions(String domain)
domain
- the domain of the connection manager.
public LocalConnectionMultiplexerSession createMultiplexerSession(Connection conn, JID address)
conn
- the connection to create the session from.address
- the JID (may include a resource) of the connection manager's session.
public StreamID nextStreamID()
public LocalClientSession createClientSession(Connection conn)
conn
- the connection to create the session from.
public LocalClientSession createClientSession(Connection conn, StreamID id)
conn
- the connection to create the session from.id
- the streamID to use for the new session.
public HttpSession createClientHttpSession(long rid, InetAddress address, StreamID id) throws UnauthorizedException
UnauthorizedException
public LocalComponentSession createComponentSession(JID address, Connection conn)
public LocalIncomingServerSession createIncomingServerSession(Connection conn, StreamID id) throws UnauthorizedException
conn
- the connection to the remote server.id
- the stream ID used in the stream element when authenticating the server.
IncomingServerSession
.
UnauthorizedException
- if the local server has not been initialized yet.public void outgoingServerSessionCreated(LocalOutgoingServerSession session)
session
- the newly created OutgoingServerSession.public void registerIncomingServerSession(String hostname, LocalIncomingServerSession session)
hostname
- the hostname that is being served by the remote server.session
- the incoming server session to the remote server.public void unregisterIncomingServerSession(String hostname, IncomingServerSession session)
hostname
- the hostname that is being served by the remote server.session
- the session to unregiser.public Collection<String> getValidatedDomains(String streamID)
Content is stored in a clustered cache so that even in the case of the node hosting the sessions is lost we can still have access to this info to be able to perform proper clean up logic.
streamID
- id that uniquely identifies the session.
public void addSession(LocalClientSession session)
session
- the session that was authenticated.public void sessionAvailable(LocalClientSession session)
session
- the session that receieved an available presence.public void broadcastPresenceToOtherResources(JID originatingResource, Presence presence)
originatingResource
- the full JID of the session that sent the presence update.presence
- the presence.public void sessionUnavailable(LocalClientSession session)
session
- the session that received an unavailable presence.public void changePriority(LocalClientSession session, int oldPriority)
session
- The session whose presence priority has been modifiedoldPriority
- The old priority for the sessionpublic boolean isAnonymousRoute(String username)
public boolean isAnonymousRoute(JID address)
public boolean isActiveRoute(String username, String resource)
public ClientSession getSession(JID from)
from
- the sender of the packet.
Session
associated with the JID.public Collection<ClientSession> getSessions()
public Collection<ClientSession> getSessions(SessionResultFilter filter)
public LocalIncomingServerSession getIncomingServerSession(String streamID)
streamID
- the stream ID that identifies the incoming server session hosted by this JVM.
public List<IncomingServerSession> getIncomingServerSessions(String hostname)
hostname
- the name of the remote server.
public OutgoingServerSession getOutgoingServerSession(String hostname)
hostname
- the name of the remote server.
public Collection<ClientSession> getSessions(String username)
public int getConnectionsCount(boolean onlyLocal)
onlyLocal
- true if only sessions connected to this JVM will be considered. Otherwise count cluster wise.
public int getUserSessionsCount(boolean onlyLocal)
onlyLocal
- true if only sessions connected to this JVM will be considered. Otherwise count cluster wise.
public int getIncomingServerSessionsCount(boolean onlyLocal)
onlyLocal
- true if only sessions connected to this JVM will be considered. Otherwise count cluster wise.
public int getActiveSessionCount(String username)
username
- the user.
getConnectionsCount(boolean)
public int getSessionCount(String username)
public Collection<ComponentSession> getComponentSessions()
public ComponentSession getComponentSession(String domain)
domain
- the domain of the component session to look for.
public Collection<String> getIncomingServers()
public Collection<String> getOutgoingServers()
public void broadcast(Message packet)
packet
- the packet to be broadcast.public void userBroadcast(String username, Packet packet) throws PacketException
username
- the user to send the boradcast to.packet
- the packet to be broadcast.
PacketException
- if a packet exception occurs.public boolean removeSession(LocalClientSession session)
session
- the session.
public boolean removeSession(ClientSession session, JID fullJID, boolean anonymous, boolean forceUnavailable)
session
- the session or null when session is derived from fullJID.fullJID
- the address of the session.anonymous
- true if the authenticated user is anonymous.forceUnavailable
- true if an unavailable presence must be created and routed.
public int getConflictKickLimit()
public Collection<String> getPreAuthenticatedKeys()
public boolean isPreAuthenticatedSession(JID address)
address
- the address of the session.
public void setConflictKickLimit(int limit)
public void initialize(XMPPServer server)
BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
initialize
in interface Module
initialize
in class BasicModule
server
- the server hosting this module.public void sendServerMessage(String subject, String body)
subject
- the subject to broadcast.body
- the body to broadcast.public void sendServerMessage(JID address, String subject, String body)
address
- the address that defines the sessions that will receive the message.subject
- the subject to broadcast.body
- the body to broadcast.public void start() throws IllegalStateException
BasicModule
Starts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
start
in interface Module
start
in class BasicModule
IllegalStateException
- If start is called before initialize
successfully returnspublic void stop()
BasicModule
Stops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
stop
in interface Module
stop
in class BasicModule
public boolean isMultipleServerConnectionsAllowed()
It is highly recommended that getServerSessionTimeout()
is enabled so that
dead connections to this server can be easily discarded.
public void setMultipleServerConnectionsAllowed(boolean allowed)
It is highly recommended that getServerSessionTimeout()
is enabled so that
dead connections to this server can be easily discarded.
allowed
- true if remote servers are allowed to have more than one connection to this
server.public void setServerSessionTimeout(int timeout)
timeout
- the number of milliseconds to elapse between clearings.public int getServerSessionTimeout()
public void setServerSessionIdleTime(int idleTime)
public int getServerSessionIdleTime()
public Cache<String,ClientSessionInfo> getSessionInfoCache()
public void joinedCluster()
ClusterEventListener
XMPPServer.getNodeID()
holds the new nodeID value.
When joining the cluster as the senior cluster member the ClusterEventListener.markedAsSeniorClusterMember()
event will be sent right after this event.
At this point the CacheFactory holds clustered caches. That means that modifications to the caches will be reflected in the cluster. The clustered caches were just obtained from the cluster and no local cached data was automatically moved.
joinedCluster
in interface ClusterEventListener
public void joinedCluster(byte[] nodeID)
ClusterEventListener
At this point the CacheFactory of the new node holds clustered caches. That means that modifications to the caches of this JVM will be reflected in the cluster and in particular in the new node.
joinedCluster
in interface ClusterEventListener
nodeID
- ID of the node that joined the cluster.public void leftCluster()
ClusterEventListener
Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the island were this JVM belonged was marked as "old" then all nodes of that island will get the left cluster event and joined cluster events. That means that caches will be reset and thus will need to be repopulated again with fresh data from this JVM. This also includes the case where this JVM was the senior cluster member and when the islands met again then this JVM stopped being the senior member.
At this point the CacheFactory holds local caches. That means that modifications to the caches will only affect this JVM.
leftCluster
in interface ClusterEventListener
public void leftCluster(byte[] nodeID)
ClusterEventListener
Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the island were the other JVM belonged was marked as "old" then all nodes of that island will get the left cluster event and joined cluster events. That means that caches will be reset and thus will need to be repopulated again with fresh data from this JVM. This also includes the case where the other JVM was the senior cluster member and when the islands met again then the other JVM stopped being the senior member.
At this point the CacheFactory of the leaving node holds local caches. That means that modifications to the caches of this JVM will not affect the leaving node but other cluster members.
leftCluster
in interface ClusterEventListener
nodeID
- ID of the node that is left the cluster.public void markedAsSeniorClusterMember()
ClusterEventListener
Moreover, in the case of a "split brain" scenario (ie. separated cluster islands) each
island will have its own senior cluster member. However, when the islands meet again there
could only be one senior cluster member so one of the senior cluster members will stop playing
that role. When that happens the JVM no longer playing that role will receive the
ClusterEventListener.leftCluster()
and ClusterEventListener.joinedCluster()
events.
markedAsSeniorClusterMember
in interface ClusterEventListener
|
Openfire 3.5.2 Javadoc | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |