Class ConsistencyChecks

java.lang.Object
org.jivesoftware.util.cache.ConsistencyChecks

public class ConsistencyChecks extends Object
This class defines methods that verify that the state of a cache and its various supporting data structures (in which some data duplication is expected) is consistent. This code has been taken from the classes that are responsible for maintaining the cache to reduce the code complexity of those classes.
Author:
Guus der Kinderen, guus@goodbytes.nl
  • Constructor Details

    • ConsistencyChecks

      public ConsistencyChecks()
  • Method Details

    • generateReportForRoutingTableServerRoutes

      public static com.google.common.collect.Multimap<String,String> generateReportForRoutingTableServerRoutes(@Nonnull Cache<DomainPair,NodeID> serversCache, @Nonnull Collection<LocalOutgoingServerSession> localServerRoutes, @Nonnull HashMap<NodeID,Set<DomainPair>> s2sDomainPairsByClusterNode)
      Verifies that #serversCache, #localServerRoutingTable and #s2sDomainPairsByClusterNode of RoutingTableImpl are in a consistent state.

      Note that this operation can be costly in terms of resource usage. Use with caution in large / busy systems.

      The returned multi-map can contain up to four keys: info, fail, pass, data. All entry values are a human readable description of a checked characteristic. When the state is consistent, no 'fail' entries will be returned.

      Parameters:
      serversCache - The cache that is used to share data across cluster nodes
      localServerRoutes - The data structure that keeps track of what data was added to the cache by the local cluster node.
      s2sDomainPairsByClusterNode - The data structure that keeps track of what data was added to the cache by the remote cluster nodes.
      Returns:
      A consistency state report.
    • generateReportForRoutingTableComponentRoutes

      public static com.google.common.collect.Multimap<String,String> generateReportForRoutingTableComponentRoutes(@Nonnull Cache<String,HashSet<NodeID>> componentsCache, @Nonnull Collection<RoutableChannelHandler> localComponentRoutes, @Nonnull HashMap<NodeID,Set<String>> componentsByClusterNode)
      Verifies that #componentsCache, #localComponentRoutingTable and #componentsByClusterNode of RoutingTableImpl are in a consistent state.

      Note that this operation can be costly in terms of resource usage. Use with caution in large / busy systems.

      The returned multi-map can contain up to four keys: info, fail, pass, data. All entry values are a human readable description of a checked characteristic. When the state is consistent, no 'fail' entries will be returned.

      Parameters:
      componentsCache - The cache that is used to share data across cluster nodes
      localComponentRoutes - The data structure that keeps track of what data was added to the cache by the local cluster node.
      componentsByClusterNode - The data structure that keeps track of what data was added to the cache by the remote cluster nodes.
      Returns:
      A consistency state report.
    • generateReportForRoutingTableClientRoutes

      public static com.google.common.collect.Multimap<String,String> generateReportForRoutingTableClientRoutes(@Nonnull Cache<String,ClientRoute> usersCache, @Nonnull Collection<LocalClientSession> localClientRoutes, @Nonnull Map<NodeID,Set<String>> routeOwnersByClusterNode)
      Verifies that usersCache, #localClientRoutingTable and routeOwnersByClusterNode of RoutingTableImpl are in a consistent state.

      Note that this operation can be costly in terms of resource usage. Use with caution in large / busy systems.

      The returned multi-map can contain up to four keys: info, fail, pass, data. All entry values are a human readable description of a checked characteristic. When the state is consistent, no 'fail' entries will be returned.

      Parameters:
      usersCache - The cache that is used to share data across cluster nodes
      localClientRoutes - The data structure that keeps track of what data was added to the cache by the local cluster node.
      routeOwnersByClusterNode - The data structure that keeps track of what data was added to the cache by the remote cluster nodes.
      Returns:
      A consistency state report.
    • generateReportForSessionManagerIncomingServerSessions

      public static com.google.common.collect.Multimap<String,String> generateReportForSessionManagerIncomingServerSessions(@Nonnull Cache<StreamID,IncomingServerSessionInfo> incomingServerSessionsCache, @Nonnull Collection<LocalIncomingServerSession> localIncomingServerSessions, @Nonnull Map<NodeID,Set<StreamID>> incomingServerSessionsByClusterNode)
      Verifies that #incomingServerSessionsCache, #localIncomingServerSessions and #incomingServerSessionsByClusterNode of SessionManager are in a consistent state.

      Note that this operation can be costly in terms of resource usage. Use with caution in large / busy systems.

      The returned multi-map can contain up to four keys: info, fail, pass, data. All entry values are a human readable description of a checked characteristic. When the state is consistent, no 'fail' entries will be returned.

      Parameters:
      incomingServerSessionsCache - The cache that is used to share data across cluster nodes
      localIncomingServerSessions - The data structure that keeps track of what data was added to the cache by the local cluster node.
      incomingServerSessionsByClusterNode - The data structure that keeps track of what data was added to the cache by the remote cluster nodes.
      Returns:
      A consistency state report.
    • generateReportForSessionManagerSessionInfos

      public static com.google.common.collect.Multimap<String,String> generateReportForSessionManagerSessionInfos(@Nonnull Cache<String,ClientSessionInfo> sessionInfoCache, @Nonnull Collection<ClientSession> localSessions, @Nonnull Map<NodeID,Set<String>> sessionInfoKeysByClusterNode)
      Verifies that #sessionInfoCache, #localSessionInfos and #sessionInfoKeysByClusterNode of SessionManager are in a consistent state.

      Note that this operation can be costly in terms of resource usage. Use with caution in large / busy systems.

      The returned multi-map can contain up to four keys: info, fail, pass, data. All entry values are a human readable description of a checked characteristic. When the state is consistent, no 'fail' entries will be returned.

      Parameters:
      sessionInfoCache - The cache that is used to share data across cluster nodes. (note that unlike its siblings, this is empty when not clustering!)
      localSessions - The data structure that keeps track of what data was added to the cache by the local cluster node.
      sessionInfoKeysByClusterNode - The data structure that keeps track of what data was added to the cache by the remote cluster nodes.
      Returns:
      A consistency state report.
    • generateReportForUserSessions

      public static com.google.common.collect.Multimap<String,String> generateReportForUserSessions(@Nonnull Cache<String,HashSet<String>> usersSessionsCache, @Nonnull Cache<String,ClientRoute> usersCache)
    • generateReportForMucRooms

      public static com.google.common.collect.Multimap<String,String> generateReportForMucRooms(@Nonnull Cache<String,MUCRoom> clusteredRoomCacheInput, @Nonnull Map<String,MUCRoom> localRoomsInput, @Nonnull Map<NodeID,Set<OccupantManager.Occupant>> occupantsByNodeInput, @Nonnull Map<OccupantManager.Occupant,NodeID> nodeByOccupantInput, @Nonnull Set<OccupantManager.Occupant> federatedOccupantsInput, @Nonnull String mucServiceName)