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 Details

  • Constructor Details

    • OnlineUsersCachingStrategy

      public OnlineUsersCachingStrategy()
  • Method Details

    • containsJid

      public boolean containsJid(tigase.xmpp.jid.BareJID jid)
      Specified by:
      containsJid in interface tigase.sys.OnlineJidsReporter
      Overrides:
      containsJid in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • handleLocalPacket

      public void handleLocalPacket(tigase.server.Packet packet, tigase.xmpp.XMPPResourceConnection conn)
      Specified by:
      handleLocalPacket in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      handleLocalPacket in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • handleLocalUserLogout

      public void handleLocalUserLogout(tigase.xmpp.jid.BareJID userId, tigase.xmpp.XMPPResourceConnection conn)
      Specified by:
      handleLocalUserLogout in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      handleLocalUserLogout in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • handleLocalResourceBind

      public void handleLocalResourceBind(tigase.xmpp.XMPPResourceConnection conn)
      Specified by:
      handleLocalResourceBind in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      handleLocalResourceBind in class tigase.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 interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      handleLocalUserChangedConnId in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • nodeConnected

      public void nodeConnected(tigase.xmpp.jid.JID node)
      Specified by:
      nodeConnected in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      nodeConnected in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • nodeDisconnected

      public void nodeDisconnected(tigase.xmpp.jid.JID node)
      Specified by:
      nodeDisconnected in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      nodeDisconnected in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • presenceUpdate

      public 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.
      Parameters:
      presence - Element containing presence information
      rec - ConnectionRecordExt for which presence should be updated
    • toString

      public String toString()
      Overrides:
      toString in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • userDisconnected

      public void userDisconnected(ConnectionRecordExt rec)
      Method responsible for user disconnection events. Calls userDisconnected() on particular cache implementation.
      Parameters:
      rec - ConnectionRecordExt for which presence should be updated
    • usersConnected

      public void usersConnected(ConnectionRecordExt... recs)
      Method responsible for user connection events. Calls usersConnected() 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 user
      oldConnectionId - - connection id which was changed
      newConnectionId - - connection id which replaced old connection id
    • getCluster

      public tigase.cluster.api.ClusterControllerIfc getCluster()
      Method returns implementation ClusterControllerIfc currently used.
      Returns:
      a value of ClusterControllerIfc
    • getConnectionIdsForJid

      public tigase.xmpp.jid.JID[] getConnectionIdsForJid(tigase.xmpp.jid.BareJID jid)
      Specified by:
      getConnectionIdsForJid in interface tigase.sys.OnlineJidsReporter
      Overrides:
      getConnectionIdsForJid in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getConnectionRecord

      public ConnectionRecordExt getConnectionRecord(tigase.xmpp.jid.JID jid)
      Specified by:
      getConnectionRecord in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      getConnectionRecord in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getConnectionRecordInstance

      public ConnectionRecordExt getConnectionRecordInstance()
      Specified by:
      getConnectionRecordInstance in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      getConnectionRecordInstance in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getConnectionRecords

      public Set<ConnectionRecordExt> getConnectionRecords(tigase.xmpp.jid.BareJID bareJID)
      Specified by:
      getConnectionRecords in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      getConnectionRecords in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getConnectionRecordsByCreationTime

      public List<ConnectionRecordExt> getConnectionRecordsByCreationTime(tigase.xmpp.jid.BareJID bareJID)
      Specified by:
      getConnectionRecordsByCreationTime in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
    • getDefaults

      public Map<String,Object> getDefaults(Map<String,Object> params)
      Specified by:
      getDefaults in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      getDefaults in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getInfo

      public String getInfo()
      Specified by:
      getInfo in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      getInfo in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getCacheContener

      public CacheContenerIfc getCacheContener()
      Retrieves CacheContener 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 class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getNodesForUserConnect

      public 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.
      Parameters:
      jid - JID of user that has connected
      Returns:
      a List of all nodes JID to which information about user connecting should be sent.
    • getNodesForUserDisconnect

      public 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.
      Parameters:
      jid - JID of user that has disconnected
      Returns:
      a List of all nod JID to which information about user disconnecting should be sent.
    • getSM

      public tigase.cluster.api.SessionManagerClusteredIfc getSM()
      Method allows retrieval of a particular SessionManagerClusteredIfc implementation currently used.
      Overrides:
      getSM in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
      Returns:
      SessionManagerClusteredIfc implementation currently used.
    • everyMinute

      public void everyMinute()
      Specified by:
      everyMinute in interface tigase.stats.StatisticHolder
      Overrides:
      everyMinute in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • getStatistics

      public void getStatistics(tigase.stats.StatisticsList list)
      Specified by:
      getStatistics in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      getStatistics in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • hasCompleteJidsInfo

      public boolean hasCompleteJidsInfo()
      Specified by:
      hasCompleteJidsInfo in interface tigase.sys.OnlineJidsReporter
      Overrides:
      hasCompleteJidsInfo in class tigase.cluster.strategy.DefaultClusteringStrategyAbstract<ConnectionRecordExt>
    • setProperties

      public void setProperties(Map<String,Object> props)
      Specified by:
      setProperties in interface tigase.cluster.strategy.ClusteringStrategyIfc<ConnectionRecordExt>
      Overrides:
      setProperties in class tigase.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.