Package tigase.server.cluster.strategy

# Class CacheContener

java.lang.Object
tigase.server.cluster.strategy.CacheContener

All Implemented Interfaces:
  `CacheContenerIfc`, `tigase.sys.OnlineJidsReporter`

public class CacheContener extends Object implements tigase.sys.OnlineJidsReporter, CacheContenerIfc

Author:
  Artur Hefczyc Created Mar 15, 2011

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CacheContener()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `connectionsSize()`
  Returns number of all cached connections (all/total CIDs for all connected users)
  `boolean`
  `containsJid(tigase.xmpp.jid.BareJID jid)`
  `boolean`
  `containsJidLocally(tigase.xmpp.jid.BareJID jid)`
  `boolean`
  `containsJidLocally(tigase.xmpp.jid.JID jid)`
  `tigase.xmpp.jid.JID[]`
  `getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid)`
  `ConnectionRecordExt`
  `getConnectionRecord(tigase.xmpp.jid.JID jid)`
  Retrieves a `ConnectionRecordExt` for the particular, specific `JID`
  `Set<ConnectionRecordExt>`
  `getConnectionRecords(tigase.xmpp.jid.BareJID bareJID)`
  Method retrieves all `ConnectionRecordExt` records for the particular `BareJID`
  `Object`
  `getInternalData()`
  Method 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.
  `boolean`
  `hasCompleteJidsInfo()`
  `int`
  `mapSize()`
  Return number of connected users
  `boolean`
  `needsSync()`
  Allow obtaining information whether cache needs synching with other nodes.
  `void`
  `removeAllForNode(tigase.xmpp.jid.JID node)`
  Method removes all cached connections which were related to the given node (e.g.
  `void`
  `setSync(boolean sync)`
  Set the state of synchronisation.
  `void`
  `updatePresence(tigase.xml.Element presence, ConnectionRecordExt rec)`
  Method updates given connection in the cache with the information about presence for the given connection.
  `void`
  `userDisconnected(ConnectionRecordExt rec)`
  Method responsible for user disconnection events.
  `void`
  `usersConnected(ConnectionRecordExt... recs)`
  Method responsible for user connection events.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CacheContener

    public CacheContener()

- ## 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:
      `containsJid` in interface `CacheContenerIfc`
    Specified by:
      `containsJid` in interface `tigase.sys.OnlineJidsReporter`

  - ### containsJidLocally

    public boolean containsJidLocally(tigase.xmpp.jid.BareJID jid)
    Specified by:
      `containsJidLocally` in interface `tigase.sys.OnlineJidsReporter`

  - ### containsJidLocally

    public boolean containsJidLocally(tigase.xmpp.jid.JID jid)
    Specified by:
      `containsJidLocally` in interface `tigase.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:
      `true` if cache is out of synch, `false` otherwise.

  - ### setSync

    public void setSync(boolean sync)
    Set the state of synchronisation.
    Specified by:
      `setSync` in interface `CacheContenerIfc`
    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:
      `removeAllForNode` in interface `CacheContenerIfc`
    Parameters:
      `node` - `JID` of the node for which cached items will be removed.

  - ### updatePresence

    public void updatePresence(tigase.xml.Element presence, ConnectionRecordExt rec)
    Method updates given connection in the cache with the information about presence for the given connection.
    Parameters:
      `presence` - `Element` containing presence information
      `rec` - `ConnectionRecordExt` for which presence should be updated

  - ### userDisconnected

    public void userDisconnected(ConnectionRecordExt rec)
    Method responsible for user disconnection events. Removes given connection record from the cache and decrease counter of all connections.
    Specified by:
      `userDisconnected` in interface `CacheContenerIfc`
    Parameters:
      `rec` - `ConnectionRecordExt` for which presence should be updated

  - ### usersConnected

    public void usersConnected(ConnectionRecordExt... recs)
    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:
      `usersConnected` in interface `CacheContenerIfc`
    Parameters:
      `recs` - `ConnectionRecordExt` for which presence should be updated

  - ### getConnectionIdsForJid

    public tigase.xmpp.jid.JID[] getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid)
    Specified by:
      `getConnectionIdsForJid` in interface `tigase.sys.OnlineJidsReporter`

  - ### getConnectionRecord

    public ConnectionRecordExt getConnectionRecord(tigase.xmpp.jid.JID jid)
    Retrieves a `ConnectionRecordExt` for the particular, specific `JID`
    Specified by:
      `getConnectionRecord` in interface `CacheContenerIfc`
    Parameters:
      `jid` - for which `ConnectionRecordExt` should be retrieved
    Returns:
      `ConnectionRecordExt` for the given `JID`

  - ### getConnectionRecords

    public Set<ConnectionRecordExt> getConnectionRecords(tigase.xmpp.jid.BareJID bareJID)
    Method retrieves all `ConnectionRecordExt` records for the particular `BareJID`
    Parameters:
      `bareJID` - for which all `ConnectionRecordExt` should be retrieved
    Returns:
      `Set` containing all `ConnectionRecordExt` objects for the given `JID`

  - ### getInternalData

    public Object getInternalData()
    Method allows retrieval internal structure underlying cache.
    Returns:
      `Object` with internal structure of underlying cache.

  - ### getNodesForJid

    public List<tigase.xmpp.jid.JID> getNodesForJid(tigase.xmpp.jid.JID jid)
    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:
      `hasCompleteJidsInfo` in interface `tigase.sys.OnlineJidsReporter`