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
Modifier and TypeFieldDescriptionprotected static tigase.licence.LicenceChecker
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class tigase.cluster.strategy.DefaultClusteringStrategyAbstract
cluster, comp, eventBus, prefix, sm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
containsJid
(tigase.xmpp.jid.BareJID jid) void
RetrievesCacheContener
instance used by this ACS instance.tigase.cluster.api.ClusterControllerIfc
Method returns implementationClusterControllerIfc
currently 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.SessionManagerClusteredIfc
getSM()
Method allows retrieval of a particularSessionManagerClusteredIfc
implementation currently used.void
getStatistics
(tigase.stats.StatisticsList list) void
handleLocalPacket
(tigase.server.Packet packet, tigase.xmpp.XMPPResourceConnection conn) void
handleLocalResourceBind
(tigase.xmpp.XMPPResourceConnection conn) void
handleLocalUserChangedConnId
(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn, tigase.xmpp.jid.JID oldConnId, tigase.xmpp.jid.JID newConnId) void
handleLocalUserLogout
(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn) boolean
void
nodeConnected
(tigase.xmpp.jid.JID node) void
nodeDisconnected
(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 boolean
presenceStatusUpdate
(tigase.server.Packet packet) Method evaluates whether given packet is a valid presence update, i.e.void
presenceUpdate
(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 void
requestSync
(tigase.xmpp.jid.JID node) Send synchronization request to a given cluster node.void
setProperties
(Map<String, Object> props) toString()
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.void
Method responsible for user disconnection events.void
usersConnected
(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:
containsJid
in interfacetigase.sys.OnlineJidsReporter
- Overrides:
containsJid
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
handleLocalPacket
public void handleLocalPacket(tigase.server.Packet packet, tigase.xmpp.XMPPResourceConnection conn) - Specified by:
handleLocalPacket
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
handleLocalPacket
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
handleLocalUserLogout
public void handleLocalUserLogout(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn) - Specified by:
handleLocalUserLogout
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
handleLocalUserLogout
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
handleLocalResourceBind
public void handleLocalResourceBind(tigase.xmpp.XMPPResourceConnection conn) - Specified by:
handleLocalResourceBind
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
handleLocalResourceBind
in 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:
handleLocalUserChangedConnId
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
handleLocalUserChangedConnId
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
nodeConnected
public void nodeConnected(tigase.xmpp.jid.JID node) - Specified by:
nodeConnected
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
nodeConnected
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
nodeDisconnected
public void nodeDisconnected(tigase.xmpp.jid.JID node) - Specified by:
nodeDisconnected
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
nodeDisconnected
in 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
-Element
containing presence informationrec
-ConnectionRecordExt
for which presence should be updated
-
toString
- Overrides:
toString
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
userDisconnected
Method responsible for user disconnection events. CallsuserDisconnected()
on particular cache implementation.- Parameters:
rec
-ConnectionRecordExt
for which presence should be updated
-
usersConnected
Method responsible for user connection events. CallsusersConnected()
on particular cache implementation.- Parameters:
recs
-ConnectionRecordExt
for 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 implementationClusterControllerIfc
currently used.- Returns:
- a value of
ClusterControllerIfc
-
getConnectionIdsForJid
public tigase.xmpp.jid.JID[] getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid) - Specified by:
getConnectionIdsForJid
in interfacetigase.sys.OnlineJidsReporter
- Overrides:
getConnectionIdsForJid
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecord
- Specified by:
getConnectionRecord
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
getConnectionRecord
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecordInstance
- Specified by:
getConnectionRecordInstance
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
getConnectionRecordInstance
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecords
- Specified by:
getConnectionRecords
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
getConnectionRecords
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getConnectionRecordsByCreationTime
public List<ConnectionRecordExt> getConnectionRecordsByCreationTime(tigase.xmpp.jid.BareJID bareJID) - Specified by:
getConnectionRecordsByCreationTime
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
-
getDefaults
- Specified by:
getDefaults
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
getDefaults
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getInfo
- Specified by:
getInfo
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
getInfo
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getCacheContener
RetrievesCacheContener
instance used by this ACS instance.- Returns:
CacheContener
instance 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:
getNodesForPacketForward
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getNodesForUserConnect
Method returns list of all nodes to which information about user connecting should be sent.- Parameters:
jid
-JID
of user that has connected- Returns:
- a
List
of all nodesJID
to 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
-JID
of user that has disconnected- Returns:
- a
List
of all nodJID
to which information about user disconnecting should be sent.
-
getSM
public tigase.cluster.api.SessionManagerClusteredIfc getSM()Method allows retrieval of a particularSessionManagerClusteredIfc
implementation currently used.- Overrides:
getSM
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
- Returns:
SessionManagerClusteredIfc
implementation currently used.
-
everyMinute
public void everyMinute()- Specified by:
everyMinute
in interfacetigase.stats.StatisticHolder
- Overrides:
everyMinute
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
getStatistics
public void getStatistics(tigase.stats.StatisticsList list) - Specified by:
getStatistics
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
getStatistics
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
hasCompleteJidsInfo
public boolean hasCompleteJidsInfo()- Specified by:
hasCompleteJidsInfo
in interfacetigase.sys.OnlineJidsReporter
- Overrides:
hasCompleteJidsInfo
in classtigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
-
setProperties
- Specified by:
setProperties
in interfacetigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
- Overrides:
setProperties
in 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.NotAuthorizedException
tigase.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:
true
if the packet is a valid presence update,false
otherwise
-
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.
-