Package tigase.server.cluster.strategy
Class CacheContenerV2
java.lang.Object
tigase.server.cluster.strategy.CacheContenerV2
- All Implemented Interfaces:
CacheContenerIfc,tigase.sys.OnlineJidsReporter
public class CacheContenerV2
extends Object
implements tigase.sys.OnlineJidsReporter, CacheContenerIfc
- Author:
- Artur Hefczyc Created Mar 15, 2011
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns number of all cached connections (all/total CIDs for all connected users)booleancontainsJid(tigase.xmpp.jid.BareJID jid) booleancontainsJidLocally(tigase.xmpp.jid.BareJID jid) booleancontainsJidLocally(tigase.xmpp.jid.JID jid) tigase.xmpp.jid.JID[]getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid) getConnectionRecord(tigase.xmpp.jid.JID jid) Retrieves aConnectionRecordExtfor the particular, specificJIDgetConnectionRecords(tigase.xmpp.jid.BareJID bareJID) Method retrieves allConnectionRecordExtrecords for the particularBareJIDMethod allows retrieval internal structure underlying cache.List<tigase.xmpp.jid.JID>getNodesForJid(tigase.xmpp.jid.JID jid) Method retrieves all nodes on which particular user has it's connections.booleanintmapSize()Return number of connected usersbooleanAllow obtaining information whether cache needs synching with other nodes.voidremoveAllForNode(tigase.xmpp.jid.JID node) Method removes all cached connections which were related to the given node (e.g.voidsetSync(boolean sync) Set the state of synchronisation.voidupdatePresence(tigase.xml.Element presence, ConnectionRecordExt rec) Method updates given connection in the cache with the information about presence for the given connection.voiduserChangedConnId(tigase.xmpp.jid.BareJID userId, tigase.xmpp.jid.JID oldConnectionId, tigase.xmpp.jid.JID newConnectionId) Method responsible for replacing used conn id by user connection/resource.voidMethod responsible for user disconnection events.voidusersConnected(ConnectionRecordExt... recs) Method responsible for user connection events.
-
Constructor Details
-
CacheContenerV2
public CacheContenerV2()
-
-
Method Details
-
connectionsSize
public int connectionsSize()Returns number of all cached connections (all/total CIDs for all connected users)- Returns:
- number of all cached CIDs
-
containsJid
public boolean containsJid(tigase.xmpp.jid.BareJID jid) - Specified by:
containsJidin interfaceCacheContenerIfc- Specified by:
containsJidin interfacetigase.sys.OnlineJidsReporter
-
containsJidLocally
public boolean containsJidLocally(tigase.xmpp.jid.BareJID jid) - Specified by:
containsJidLocallyin interfacetigase.sys.OnlineJidsReporter
-
containsJidLocally
public boolean containsJidLocally(tigase.xmpp.jid.JID jid) - Specified by:
containsJidLocallyin interfacetigase.sys.OnlineJidsReporter
-
mapSize
public int mapSize()Return number of connected users- Returns:
- number of connected users
-
needsSync
public boolean needsSync()Allow obtaining information whether cache needs synching with other nodes.- Returns:
trueif cache is out of synch,falseotherwise.
-
setSync
public void setSync(boolean sync) Set the state of synchronisation.- Specified by:
setSyncin interfaceCacheContenerIfc- Parameters:
sync- boolean value denoting sync state.
-
removeAllForNode
public void removeAllForNode(tigase.xmpp.jid.JID node) Method removes all cached connections which were related to the given node (e.g. when the node was disconnected) as well as decreases count of all connections stored in cache.- Specified by:
removeAllForNodein interfaceCacheContenerIfc- Parameters:
node-JIDof the node for which cached items will be removed.
-
updatePresence
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
-
userDisconnected
Method responsible for user disconnection events. Removes given connection record from the cache and decrease counter of all connections.- Specified by:
userDisconnectedin interfaceCacheContenerIfc- Parameters:
rec-ConnectionRecordExtfor which presence should be updated
-
usersConnected
Method responsible for user connection events. Adds given connection record to the cache and increases counters of both all connections and number of user JIDs in cache..- Specified by:
usersConnectedin interfaceCacheContenerIfc- 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 replacing used conn id by user connection/resource. In fact it removes connection using old connection id from connection cache, updates internal value of connection id to new connection id and adds it to cache using new connection id as a key.This happens during stream resumption as connection id changes for session for which stream is resumed.
- Parameters:
userId- - bare jid of useroldConnectionId- - connection id which was changednewConnectionId- - connection id which replaced old connection id
-
getConnectionIdsForJid
public tigase.xmpp.jid.JID[] getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid) - Specified by:
getConnectionIdsForJidin interfacetigase.sys.OnlineJidsReporter
-
getConnectionRecord
Retrieves aConnectionRecordExtfor the particular, specificJID- Specified by:
getConnectionRecordin interfaceCacheContenerIfc- Parameters:
jid- for whichConnectionRecordExtshould be retrieved- Returns:
ConnectionRecordExtfor the givenJID
-
getConnectionRecords
Method retrieves allConnectionRecordExtrecords for the particularBareJID- Parameters:
bareJID- for which allConnectionRecordExtshould be retrieved- Returns:
Setcontaining allConnectionRecordExtobjects for the givenJID
-
getInternalData
Method allows retrieval internal structure underlying cache.- Returns:
Objectwith internal structure of underlying cache.
-
getNodesForJid
Method retrieves all nodes on which particular user has it's connections.- Parameters:
jid- for which list of cluster nodes should be returned.- Returns:
- list of cluster nodes on which user has it's connections.
-
hasCompleteJidsInfo
public boolean hasCompleteJidsInfo()- Specified by:
hasCompleteJidsInfoin interfacetigase.sys.OnlineJidsReporter
-