Interface ClusterFilterSupport<T extends ClusterFilterSupport<T>>

    • Method Detail

      • filterAll

        T filterAll​(ClusterFilter filter)
        Returns a copy of this instance that will use the specified filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        filter - Filter.
        Returns:
        Filtered instance.
      • filter

        default T filter​(ClusterNodeFilter filter)
        Returns a copy of this instance that will use the specified filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        filter - Filter.
        Returns:
        Filtered instance.
        See Also:
        forRemotes(), forRole(String), forProperty(String), forNode(ClusterNode), forOldest(), forYoungest()
      • forRole

        default T forRole​(String role)
        Returns a copy of this instance that will use ClusterFilters.forRole(String) filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        role - Role (see ClusterNode.hasRole(String)).
        Returns:
        Filtered instance.
      • forProperty

        default T forProperty​(String name)
        Returns a copy of this instance that will use ClusterFilters.forProperty(String) filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        name - Property name (see ClusterNode.hasProperty(String)).
        Returns:
        Filtered instance.
      • forProperty

        default T forProperty​(String name,
                              String value)
        Returns a copy of this instance that will use ClusterFilters.forProperty(String, String) filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        name - Property name (see ClusterNode.property(String)).
        value - Property value.
        Returns:
        Filtered instance.
      • forService

        default T forService​(Class<? extends Service> type)
        Returns a copy of this instance that will use ClusterFilters.forService(Class) filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        type - Service type (see ClusterNode.hasService(Class))
        Returns:
        Filtered instance.
      • forRemotes

        default T forRemotes()
        Returns a copy of this instance that will use ClusterFilters.forRemotes() filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Returns:
        Filtered instance.
      • forNode

        default T forNode​(ClusterNode node)
        Returns a copy of this instance that will use ClusterFilters.forNode(ClusterNode) filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        node - Node.
        Returns:
        Filtered instance.
      • forNode

        default T forNode​(ClusterNodeId id)
        Returns a copy of this instance that will use ClusterFilters.forNode(ClusterNodeId) filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Parameters:
        id - Node.
        Returns:
        Filtered instance.
      • forOldest

        default T forOldest()
        Returns a copy of this instance that will use ClusterFilters.forOldest() filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Returns:
        Filter.
      • forYoungest

        default T forYoungest()
        Returns a copy of this instance that will use ClusterFilters.forYoungest() filter along with all the filter criteria that were inherited from this instance.

        Notice: for performance reasons it is highly recommended to cache and reuse the filtered instance instead of re-building it over and over again.

        
        // Bad!!! (filtering is performed on every iteration).
        for (int i = 0; i < 1000; i++) {
            cluster.forRemotes().forRole("some_role").doSomething();
        }
        
        // Good (filtering is performed only once).
        filtered = cluster.forRemotes().forRole("some_role");
        for (int i = 0; i < 1000; i++) {
            filtered.doSomething();
        }
        

        Returns:
        Filtered instance.