tigase.cluster.strategy

## Interface ClusteringStrategyIfc

- All Superinterfaces:
    OnlineJidsReporter
  All Known Implementing Classes:
    SMNonCachingAllNodes

      public interface ClusteringStrategyIfc
      extends OnlineJidsReporter

  Created: May 2, 2009 4:36:03 PM
  Version:
    $Rev$
  Author:
    Artur Hefczyc

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `List<tigase.xmpp.JID>` | `getAllNodes()` The method returns all cluster nodes currently connected to the cluster.
    `ConnectionRecord` | `getConnectionRecord(tigase.xmpp.JID jid)` Returns a ConnectionRecord object associated with this user's full JID if it exists in the cache or null if it does not.
    `Set<ConnectionRecord>` | `getConnectionRecords(tigase.xmpp.BareJID bareJID)` Returns a set with all ConnectionRecords found in the cache for a given user ID, that is BareJID.
    `Map<String,Object>` | `getDefaults(Map<String,Object> params)` This method is used for configuration purpose.
    `Object` | `getInternalCacheData()` Deprecated.
    `List<tigase.xmpp.JID>` | `getNodesForJid(tigase.xmpp.JID jid)` Returns a `List` of all cluster nodes on which the given user session can exist.
    `List<tigase.xmpp.JID>` | `getNodesForPacketForward(tigase.xmpp.JID fromNode, Set<tigase.xmpp.JID> visitedNodes, Packet packet)` The method allows the strategy implementation to control to which cluster nodes forward the given packet.
    `List<tigase.xmpp.JID>` | `getNodesForUserConnect(tigase.xmpp.JID jid)` The method allows the strategy implementation to control to which cluster nodes send the notification about user's new connection event.
    `List<tigase.xmpp.JID>` | `getNodesForUserDisconnect(tigase.xmpp.JID jid)` The method allows the strategy implementation to control to which cluster nodes send the notification about user's disconnection event.
    `void` | `getStatistics(StatisticsList list)` Add the strategy statistics to the List.
    `boolean` | `needsSync()` This method returns `'true'` if it needs online users synchronization upon the node connection to the cluster.
    `void` | `nodeConnected(tigase.xmpp.JID node)` This is a handler method which is called when a new node connects to the cluster.
    `void` | `nodeDisconnected(tigase.xmpp.JID node)` This is a handler method which is called when a node disconnects from the cluster.
    `void` | `presenceUpdate(tigase.xml.Element presence, ConnectionRecord rec)` The method is called on user's presence update received from a remote cluster node.
    `void` | `setProperties(Map<String,Object> props)` Method used to pass configuration parameters to the class.
    `void` | `setSessionManagerHandler(SessionManagerHandler sm)` The method allows to obtain SessionManagerHandler object by the strategy.
    `void` | `userDisconnected(Queue<Packet> results, ConnectionRecord rec)` This is a handler method which is called when a user disconnects from some node in the cluster.
    `void` | `usersConnected(Queue<Packet> results, ConnectionRecord... rec)` This is a handler method which is called when a user connects to some node in the cluster.

    - ### Methods inherited from interface tigase.sys.OnlineJidsReporter

      `containsJid, getConnectionIdsForJid, hasCompleteJidsInfo`

- - ### Method Detail

    - #### getInternalCacheData

          @Deprecated
          Object getInternalCacheData()

      Deprecated.
      Note! This is not for a common use method. This is for debugging and diagnostic purposes only and maybe removed or changed at any time in the future. It returns a content of an internal cache from the strategy. Regardless of the cache data organization inside the strategy, it is returned here in a common format. It may be a copy or a direct reference to internal data. Therefore this is unmodifiable instance of the cache. Generating results of this structure may be a costly operation, therefore it must not be called frequently.
      Returns:
        an Object with content of an internal cache data.

    - #### getConnectionRecords

          Set<ConnectionRecord> getConnectionRecords(tigase.xmpp.BareJID bareJID)

      Returns a set with all ConnectionRecords found in the cache for a given user ID, that is BareJID. In other words all user's resources/connectionIDs found in the cache associated with user's account.
      Parameters:
        `bareJID` - is an instance of the user's BareJID, that is account ID.
      Returns:
        a Set instance with all ConnectionRecords found for a given BareJID. Note, the result may be null or it maybe an empty Set or non-empty set.

    - #### getConnectionRecord

          ConnectionRecord getConnectionRecord(tigase.xmpp.JID jid)

      Returns a ConnectionRecord object associated with this user's full JID if it exists in the cache or null if it does not. All parts of the user's JID are checked and ConnectionRecord is returned only if there is a match for all parts.
      Parameters:
        `jid` - is an instance of the user's full JID.
      Returns:
        ConnectionRecord instance associated with given user's JID or null if there is no ConnectionRecord in the cache.

    - #### setSessionManagerHandler

          void setSessionManagerHandler(SessionManagerHandler sm)

      The method allows to obtain SessionManagerHandler object by the strategy. The object is mainly used to access local VHosts configuration and check the ID of the local session manager.
      Parameters:
        `sm` - is an instance of the SessionManagerHandler class.

    - #### getAllNodes

          List<tigase.xmpp.JID> getAllNodes()

      The method returns all cluster nodes currently connected to the cluster.
      Returns:
        List of all cluster nodes currently connected to the cluster.

    - #### getDefaults

          Map<String,Object> getDefaults(Map<String,Object> params)

      This method is used for configuration purpose. Following the convention used in the Tigase project this method is supposed to provide configuration defaults. All parameters which exist in configuration file overwrite corresponding default parameters. If some parameters are missing in configuration file defaults are used then. A compiled set of parameters is then passed to `setProperties` method.
      Parameters:
        `params` - a `Map` with properties loaded from init.properties file which should be used for generating defaults.
      Returns:
        a `Map` with all the class default configuration parameters.

    - #### getNodesForJid

          List<tigase.xmpp.JID> getNodesForJid(tigase.xmpp.JID jid)

      Returns a `List` of all cluster nodes on which the given user session can exist. In the simplest scenario it can always return all cluster nodes as in theory the user can connect to any node if it is not on the local node. More specialized implementation can know kind of hashing algorithm which is used for binding a specific user to a specific node or the implementation can keep track of all connected users to all nodes and 'know' where is the user connected at any given time. In theory it can also return `'null'` it it 'knows' the user is off-line.
      Parameters:
        `jid` - is a user full JID.
      Returns:
        List of cluster nodes to which the user can be connected.

    - #### getStatistics

          void getStatistics(StatisticsList list)

      Add the strategy statistics to the List.
      Parameters:
        `list` -

    - #### needsSync

          boolean needsSync()

      This method returns `'true'` if it needs online users synchronization upon the node connection to the cluster. Normally it should return `'false'`. It it return `'true'` then the synchronization starts. All online users from all other nodes would sent in batches and the synchronization can take any amount of time.
      Returns:
        a boolean value whether synchronization is needed.

    - #### nodeConnected

          void nodeConnected(tigase.xmpp.JID node)

      This is a handler method which is called when a new node connects to the cluster.
      Parameters:
        `node` - is a cluster node id.

    - #### nodeDisconnected

          void nodeDisconnected(tigase.xmpp.JID node)

      This is a handler method which is called when a node disconnects from the cluster.
      Parameters:
        `node` - is a cluster node id.

    - #### setProperties

          void setProperties(Map<String,Object> props)

      Method used to pass configuration parameters to the class. Parameters are stored in `Map` which contains compiles set of defaults overwritten by parameters loaded from configuration file. If he implementation took a good care of providing defaults for all parameters no parameter should be missing.
      Parameters:
        `props` - a `Map` with all configuration parameters for the class.

    - #### userDisconnected

          void userDisconnected(Queue<Packet> results,
                              ConnectionRecord rec)

      This is a handler method which is called when a user disconnects from some node in the cluster.
      Parameters:
        `jid` - us a user full JID just disconnected from the cluster.
        `node` - is a cluster node id from which the user disconnected.
        `results` - is a collection of packets which can be generated upon the user disconnection by the implementation.

    - #### usersConnected

          void usersConnected(Queue<Packet> results,
                            ConnectionRecord... rec)

      This is a handler method which is called when a user connects to some node in the cluster.
      Parameters:
        `jids` - is a list of full user JIDs which just connected to the cluster. Normally there is only one JID provided, however, in some cases (during synchronization) there might be more than one.
        `node` - is a cluster node id where the jid is connected to.
        `results` - is a collection of packets which can be generated upon the user connection by the implementation.

    - #### getNodesForPacketForward

          List<tigase.xmpp.JID> getNodesForPacketForward(tigase.xmpp.JID fromNode,
                                                       Set<tigase.xmpp.JID> visitedNodes,
                                                       Packet packet)

      The method allows the strategy implementation to control to which cluster nodes forward the given packet. It may offer a different algorithm for message broadcasting and different for presences, for example.
      Parameters:
        `fromNode` - a source address if the packet was forwarded from a different node, this may be null if the packet was generated on this node.
        `visitedNodes` - a list of cluster nodes through which the packet already traveled, this parameter can be null if the packet was generated on this node
        `packet` - a packet which is supposed to be sent to other node.
      Returns:
        a list of cluster nodes JIDs to which the packet should be sent.

    - #### presenceUpdate

          void presenceUpdate(tigase.xml.Element presence,
                            ConnectionRecord rec)

      The method is called on user's presence update received from a remote cluster node. The clustering strategy may choose to cache the presence locally if necessary.
      Parameters:
        `presence` - Packet received from a remote cluster node.
        `rec` - is an instance of the user's ConnectionRecord.

    - #### getNodesForUserConnect

          List<tigase.xmpp.JID> getNodesForUserConnect(tigase.xmpp.JID jid)

      The method allows the strategy implementation to control to which cluster nodes send the notification about user's new connection event.
      Returns:
        a list of cluster nodes JIDs to which the notification should be sent.

    - #### getNodesForUserDisconnect

          List<tigase.xmpp.JID> getNodesForUserDisconnect(tigase.xmpp.JID jid)

      The method allows the strategy implementation to control to which cluster nodes send the notification about user's disconnection event.
      Returns:
        a list of cluster nodes JIDs to which the notification should be sent.

Copyright © 2013 Tigase. All rights reserved.