Class LocalMUCRoomManager

  • public class LocalMUCRoomManager
    extends Object
    Each instance of this class takes responsibility of maintaining the in-memory representation of MUCRooms for exactly one instance of MultiUserChatService, which is expected to be the sole invoking entity. This instance that is provided as an argument to the constructor. This class makes extensive use of the 'package' access modifier to reflect this. It is the responsibility of invoking codes that changes applied to instances managed by this class are made available to other users (eg: cluster nodes). To achieve this, the sync(MUCRoom) method must be used. Changes to an instance that are not synced will not be reflected in subsequent instances returned by the various getters in this class (behavior can differ based on the deployment model of Openfire: clustered environments are more susceptible to data loss than a single-server Openfire instance. To control (cluster-wide) access to instances, a MUCRoom-based Lock instance can be obtained through getLock(String).
    wuchang 2016-1-14, Guus der Kinderen,
    • Method Detail

      • restoreCacheContentAfterJoin

        public Set<OccupantManager.Occupant> restoreCacheContentAfterJoin​(@Nonnull
                                                                          OccupantManager occupantManager)
        When the local node is joining or leaving a cluster, CacheFactory will swap the implementation used to instantiate caches. This causes the cache content to be 'reset': it will no longer contain the data that's provided by the local node. This method restores data that's provided by the local node in the cache. It is expected to be invoked right after joining the cluster. This method checks whether local occupant nicknames clash with remote ones. If a clash is detected, both occupants are kicked out of the room. (ClusterEventListener.joinedCluster() or leaving
        occupantManager - The occupant manager that contains local occupant registration.
        The set of local occupants that is in the room after processing. This is the original set of local occupants of the room minus any occupants that were kicked out.
      • detectAndRemoveLostRooms

        public Set<String> detectAndRemoveLostRooms()
        This method detects rooms that we know of 'locally' (in the data structure that supports the room cache), but which are not (no longer) in the cache. When a cluster node crashes out of the cluster (eg: network interruption), it has been observed that the cache can 'break'. Presumably, the affected cache entry wasn't "physically" stored on the server, and as the network connection is gone, a backup cannot be obtained either. This method attempts to identify, remove and return rooms that are lost in these cases, which is intended to be used (only) when processing a "cluster break" event.
        room names that were known to the local server, but not (any more) in the clustered cache.
      • recomputeNonPersistentRoomCount

        public long recomputeNonPersistentRoomCount()
        Iterates over all MUC rooms (in the cache, non-cached rooms are obviously not non-persistent) and counts the number of non-persistent rooms. This method is more resource intensive, but perhaps more accurate, than getNonPersistentRoomCount().
        The count of non-persistent MUC rooms.
      • getNonPersistentRoomCount

        public long getNonPersistentRoomCount()
        Returns a count of all rooms that are non-persistent. The statistic returned by this method is based on a derived value. It is not based on a direct re-evaluation of each room. This method is not as resource intensive, but perhaps less accurate, than recomputeNonPersistentRoomCount().
        The count of non-persistent MUC rooms.