Interface ClusterTopology

    • Method Detail

      • version

        long version()
        Returns the version of this topology.

        This method provides support for tacking changes of the cluster topology. The value of this property is monotonically incremented each time when the cluster topology changes.

        Note: Version is local to each node and can differ from node to node.

        Returns:
        Version this topology.
      • hash

        ClusterHash hash()
        Returns the SHA-256 hash of all cluster node identifiers of this topology.

        If this topology is filtered then only those nodes that match the filter criteria will be used to compute the hash.

        Returns:
        SHA-256 hash of this topology.
      • localNode

        ClusterNode localNode()
        Returns local node or null if local node is not within this topology.
        Returns:
        Local node or null if local node is not within this topology.
        See Also:
        ClusterNode.isLocal()
      • nodes

        List<ClusterNode> nodes()
        Returns an immutable list of all nodes with consistent ordering based on ClusterNode.compareTo(ClusterNode) method. Returns an empty list if there are no nodes within this topology.
        Returns:
        Immutable list of all nodes with consistent ordering or an empty list if there are no nodes within this topology.
      • first

        ClusterNode first()
        Returns the first node of the nodes() list or null if this topology is empty.
        Returns:
        The first node of the nodes() list or null if this topology is empty.
      • last

        ClusterNode last()
        Returns the last node of the nodes() list or null if this topology is empty.
        Returns:
        The last node of the nodes() list or null if this topology is empty.
      • nodeSet

        Set<ClusterNode> nodeSet()
        Returns an immutable set of all nodes within this topology. Returns an empty set if there are no nodes within this topology.
        Returns:
        Immutable set of all nodes within this topology or an empty list if there are no nodes within this topology.
      • remoteNodes

        List<ClusterNode> remoteNodes()
        Returns an immutable list of remote nodes within this topology ordered by their identifiers. Returns an empty list if there are no remote nodes within this topology.
        Returns:
        Immutable list of remotes node within this topology ordered by their identifiers or an empty list if there are no remote nodes within this topology..
        See Also:
        ClusterNode.isLocal()
      • joinOrder

        NavigableSet<ClusterNode> joinOrder()
        Returns an immutable set of all nodes ordered by their join order. The first element in this set is the oldest node. Returns an empty set if there are no nodes within this topology.
        Returns:
        Immutable set of all nodes ordered by their join order or an empty set if there are no nodes within this topology.
      • contains

        boolean contains​(ClusterNode node)
        Returns true if this topology contains the specified node.
        Parameters:
        node - Node to check.
        Returns:
        true if this topology contains the specified node.
      • contains

        boolean contains​(ClusterNodeId id)
        Returns true if this topology contains a node with the specified identifier.
        Parameters:
        id - Node identifier to check.
        Returns:
        true if this topology contains a node with the specified identifier.
      • get

        ClusterNode get​(ClusterNodeId id)
        Returns the node for the specified identifier or null if there is no such node within this topology.
        Parameters:
        id - Node identifier.
        Returns:
        Node for the specified identifier or null if there is no such node within this topology.
      • size

        int size()
        Returns the number of nodes in this topology.
        Returns:
        Number of nodes in this topology.
      • isEmpty

        boolean isEmpty()
        Returns true if this topology doesn't have any nodes.
        Returns:
        true if this topology doesn't have any nodes.
      • oldest

        ClusterNode oldest()
        Returns the oldest node of this topology. Returns null if this topology is empty.

        The oldest node is the node with the lowest join order.

        Returns:
        Oldest node of this topology or null if this topology is empty.
      • youngest

        ClusterNode youngest()
        Returns the youngest node of this topology. Returns null if this topology is empty.

        The youngest node is the node with the highest join order.

        Returns:
        Youngest node within of this topology or null if this topology is empty.
      • random

        ClusterNode random()
        Returns a random node of this topology. Returns null if this topology is empty.
        Returns:
        Random node or null if this topology is empty.
      • filterAll

        ClusterTopology filterAll​(ClusterFilter filter)
        Returns a copy of this topology that contains only those nodes that match the specified filter. The topology version will be preserved in the returned copy.
        Parameters:
        filter - Filter.
        Returns:
        Copy of this topology that contains only those nodes that match the specified filter.
      • filter

        ClusterTopology filter​(ClusterNodeFilter filter)
        Returns a copy of this topology containing only those nodes that match the specified filter. The topology version will be preserved in the returned copy.
        Parameters:
        filter - Filter.
        Returns:
        Copy of this topology that contains only those nodes that match the specified filter.
      • empty

        static ClusterTopology empty()
        Return an empty cluster topology.
        Returns:
        Empty topology that has its version() equals to 0 and having an empty list of nodes().