Package tigase.server.cluster.strategy
Class OnlineUsersCachingStrategy
java.lang.Object
tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
tigase.server.cluster.strategy.OnlineUsersCachingStrategy
- All Implemented Interfaces:
tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>,tigase.licence.LicencedComponent,tigase.stats.StatisticHolder,tigase.sys.OnlineJidsReporter
public class OnlineUsersCachingStrategy
extends tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
implements tigase.licence.LicencedComponent
Created: Jun 27, 2009 9:42:40 PM
- Version:
- $Rev$
- Author:
- Artur Hefczyc
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static tigase.licence.LicenceCheckerstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class tigase.cluster.strategy.DefaultClusteringStrategyAbstract
cluster, comp, eventBus, prefix, sm -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsJid(tigase.xmpp.jid.BareJID jid) voidRetrievesCacheContenerinstance used by this ACS instance.tigase.cluster.api.ClusterControllerIfcMethod returns implementationClusterControllerIfccurrently used.tigase.xmpp.jid.JID[]getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid) getConnectionRecord(tigase.xmpp.jid.JID jid) getConnectionRecords(tigase.xmpp.jid.BareJID bareJID) getConnectionRecordsByCreationTime(tigase.xmpp.jid.BareJID bareJID) getDefaults(Map<String, Object> params) getInfo()List<tigase.xmpp.jid.JID>getNodesForPacketForward(tigase.xmpp.jid.JID fromNode, Set<tigase.xmpp.jid.JID> visitedNodes, tigase.server.Packet packet) List<tigase.xmpp.jid.JID>getNodesForUserConnect(tigase.xmpp.jid.JID jid) Method returns list of all nodes to which information about user connecting should be sent.List<tigase.xmpp.jid.JID>getNodesForUserDisconnect(tigase.xmpp.jid.JID jid) Method returns list of all nodes to which information about user disconnecting should be sent.tigase.cluster.api.SessionManagerClusteredIfcgetSM()Method allows retrieval of a particularSessionManagerClusteredIfcimplementation currently used.voidgetStatistics(tigase.stats.StatisticsList list) voidhandleLocalPacket(tigase.server.Packet packet, tigase.xmpp.XMPPResourceConnection conn) voidhandleLocalResourceBind(tigase.xmpp.XMPPResourceConnection conn) voidhandleLocalUserChangedConnId(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn, tigase.xmpp.jid.JID oldConnId, tigase.xmpp.jid.JID newConnId) voidhandleLocalUserLogout(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn) booleanvoidnodeConnected(tigase.xmpp.jid.JID node) voidnodeDisconnected(tigase.xmpp.jid.JID node) prepareConnectionParams(tigase.xmpp.XMPPResourceConnection conn) A utility method used to prepare a Map of data with user session data before it can be sent over to another cluster node.protected booleanpresenceStatusUpdate(tigase.server.Packet packet) Method evaluates whether given packet is a valid presence update, i.e. is of correct type and has proper addressing.voidpresenceUpdate(tigase.xml.Element presence, ConnectionRecordExt rec) If presence caching is enabled method updates given connection in the cache with the information about presence for the given connection.protected voidrequestSync(tigase.xmpp.jid.JID node) Send synchronization request to a given cluster node.voidsetProperties(Map<String, Object> props) toString()voiduserChangedConnId(tigase.xmpp.jid.BareJID userId, tigase.xmpp.jid.JID oldConnectionId, tigase.xmpp.jid.JID newConnectionId) Method responsible for changing connection id for session for which connection id was changed, ie. due to stream resumption.voidMethod responsible for user disconnection events.voidusersConnected(ConnectionRecordExt... recs) Method responsible for user connection events.Methods inherited from class tigase.cluster.strategy.DefaultClusteringStrategyAbstract
addCommandListener, containsJidLocally, containsJidLocally, everyHour, everySecond, fireEvent, getNodesConnected, getNodesForIqResponse, getStatistics, handleLocalPresenceSet, handleLocalUserLogin, isIqResponseToNode, isSuitableForForward, processPacket, sendToNextNode, setClusterController, setStatisticsPrefix, statisticExecutedIn
-
Field Details
-
ONLINE_PRESENCE_CACHE_PROP_KEY
- See Also:
-
REQUEST_SYNCONLINE_CMD
- See Also:
-
RESPOND_SYNCONLINE_CMD
- See Also:
-
STRATEGY_STATS_CMD
- See Also:
-
USER_CONNECTED_CMD
- See Also:
-
USER_CONN_ID_CHANGED_CMD
- See Also:
-
USER_DISCONNECTED_CMD
- See Also:
-
USER_PRESENCE_CMD
- See Also:
-
licenceChecker
protected static tigase.licence.LicenceChecker licenceChecker
-
-
Constructor Details
-
OnlineUsersCachingStrategy
public OnlineUsersCachingStrategy()
-
-
Method Details
-
containsJid
public boolean containsJid(tigase.xmpp.jid.BareJID jid) - Specified by:
containsJidin interfacetigase.sys.OnlineJidsReporter- Overrides:
containsJidin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
handleLocalPacket
public void handleLocalPacket(tigase.server.Packet packet, tigase.xmpp.XMPPResourceConnection conn) - Specified by:
handleLocalPacketin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
handleLocalPacketin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
handleLocalUserLogout
public void handleLocalUserLogout(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn) - Specified by:
handleLocalUserLogoutin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
handleLocalUserLogoutin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
handleLocalResourceBind
public void handleLocalResourceBind(tigase.xmpp.XMPPResourceConnection conn) - Specified by:
handleLocalResourceBindin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
handleLocalResourceBindin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
handleLocalUserChangedConnId
public void handleLocalUserChangedConnId(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn, tigase.xmpp.jid.JID oldConnId, tigase.xmpp.jid.JID newConnId) - Specified by:
handleLocalUserChangedConnIdin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
handleLocalUserChangedConnIdin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
nodeConnected
public void nodeConnected(tigase.xmpp.jid.JID node) - Specified by:
nodeConnectedin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
nodeConnectedin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
nodeDisconnected
public void nodeDisconnected(tigase.xmpp.jid.JID node) - Specified by:
nodeDisconnectedin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
nodeDisconnectedin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
presenceUpdate
If presence caching is enabled method updates given connection in the cache with the information about presence for the given connection.- Parameters:
presence-Elementcontaining presence informationrec-ConnectionRecordExtfor which presence should be updated
-
toString
- Overrides:
toStringin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
userDisconnected
Method responsible for user disconnection events. CallsuserDisconnected()on particular cache implementation.- Parameters:
rec-ConnectionRecordExtfor which presence should be updated
-
usersConnected
Method responsible for user connection events. CallsusersConnected()on particular cache implementation.- Parameters:
recs-ConnectionRecordExtfor which presence should be updated
-
userChangedConnId
public void userChangedConnId(tigase.xmpp.jid.BareJID userId, tigase.xmpp.jid.JID oldConnectionId, tigase.xmpp.jid.JID newConnectionId) Method responsible for changing connection id for session for which connection id was changed, ie. due to stream resumption.- Parameters:
userId- - bare jid of useroldConnectionId- - connection id which was changednewConnectionId- - connection id which replaced old connection id
-
getCluster
public tigase.cluster.api.ClusterControllerIfc getCluster()Method returns implementationClusterControllerIfccurrently used.- Returns:
- a value of
ClusterControllerIfc
-
getConnectionIdsForJid
public tigase.xmpp.jid.JID[] getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid) - Specified by:
getConnectionIdsForJidin interfacetigase.sys.OnlineJidsReporter- Overrides:
getConnectionIdsForJidin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecord
- Specified by:
getConnectionRecordin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
getConnectionRecordin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecordInstance
- Specified by:
getConnectionRecordInstancein interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
getConnectionRecordInstancein classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecords
- Specified by:
getConnectionRecordsin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
getConnectionRecordsin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecordsByCreationTime
public List<ConnectionRecordExt> getConnectionRecordsByCreationTime(tigase.xmpp.jid.BareJID bareJID) - Specified by:
getConnectionRecordsByCreationTimein interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
-
getDefaults
- Specified by:
getDefaultsin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
getDefaultsin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getInfo
- Specified by:
getInfoin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
getInfoin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getCacheContener
RetrievesCacheContenerinstance used by this ACS instance.- Returns:
CacheContenerinstance used by this ACS instance.
-
getNodesForPacketForward
public List<tigase.xmpp.jid.JID> getNodesForPacketForward(tigase.xmpp.jid.JID fromNode, Set<tigase.xmpp.jid.JID> visitedNodes, tigase.server.Packet packet) - Overrides:
getNodesForPacketForwardin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getNodesForUserConnect
Method returns list of all nodes to which information about user connecting should be sent.- Parameters:
jid-JIDof user that has connected- Returns:
- a
Listof all nodesJIDto which information about user connecting should be sent.
-
getNodesForUserDisconnect
Method returns list of all nodes to which information about user disconnecting should be sent.- Parameters:
jid-JIDof user that has disconnected- Returns:
- a
Listof all nodJIDto which information about user disconnecting should be sent.
-
getSM
public tigase.cluster.api.SessionManagerClusteredIfc getSM()Method allows retrieval of a particularSessionManagerClusteredIfcimplementation currently used.- Overrides:
getSMin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>- Returns:
SessionManagerClusteredIfcimplementation currently used.
-
everyMinute
public void everyMinute()- Specified by:
everyMinutein interfacetigase.stats.StatisticHolder- Overrides:
everyMinutein classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getStatistics
public void getStatistics(tigase.stats.StatisticsList list) - Specified by:
getStatisticsin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
getStatisticsin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
hasCompleteJidsInfo
public boolean hasCompleteJidsInfo()- Specified by:
hasCompleteJidsInfoin interfacetigase.sys.OnlineJidsReporter- Overrides:
hasCompleteJidsInfoin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
setProperties
- Specified by:
setPropertiesin interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>- Overrides:
setPropertiesin classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
prepareConnectionParams
protected Map<String,String> prepareConnectionParams(tigase.xmpp.XMPPResourceConnection conn) throws tigase.xmpp.NotAuthorizedException, tigase.xmpp.NoConnectionIdException A utility method used to prepare a Map of data with user session data before it can be sent over to another cluster node. This is supposed to contain all the user's session essential information which directly identify user's resource and network connection. This information allows to detect two different user's connection made for the same resource. This may happen if both connections are established to different nodes.- Parameters:
conn- is user's XMPPResourceConnection for which Map structure is prepare.a Map structure with all user's connection essential data.
- Returns:
- a value of
Map<String,String> - Throws:
tigase.xmpp.NotAuthorizedExceptiontigase.xmpp.NoConnectionIdException
-
presenceStatusUpdate
protected boolean presenceStatusUpdate(tigase.server.Packet packet) Method evaluates whether given packet is a valid presence update, i.e. is of correct type and has proper addressing.- Parameters:
packet- to be validated- Returns:
trueif the packet is a valid presence update,falseotherwise
-
requestSync
protected void requestSync(tigase.xmpp.jid.JID node) Send synchronization request to a given cluster node. In a response the remote node should return a list of JIDs for online users on this node.- Parameters:
node- is a JID of the target cluster node.
-