Class AttributeNodeFilter

  • All Implemented Interfaces:
    Serializable, IgnitePredicate<ClusterNode>

    public class AttributeNodeFilter
    extends Object
    implements IgnitePredicate<ClusterNode>
    Implementation of IgnitePredicate<ClusterNode> based on user attributes. This filter can be used in methods like ClusterGroup.forPredicate(IgnitePredicate), CacheConfiguration.setNodeFilter(IgnitePredicate), ServiceConfiguration.setNodeFilter(IgnitePredicate), etc.

    The filter will evaluate to true if a node has all provided attributes set to corresponding values. Here is an example of how you can configure node filter for a cache or a service so that it's deployed only on nodes that have group attribute set to value data:

     <property name="nodeFilter">
         <bean class="org.apache.ignite.util.AttributeNodeFilter">
             <constructor-arg value="group"/>
             <constructor-arg value="data"/>
         </bean>
     </property>
     
    You can also specify multiple attributes for the filter:
     <property name="nodeFilter">
         <bean class="org.apache.ignite.util.AttributeNodeFilter">
             <constructor-arg>
                 <map>
                     <entry key="cpu-group" value="high"/>
                     <entry key="memory-group" value="high"/>
                 </map>
             </constructor-arg>
         </bean>
     </property>
     
    With this configuration a cache or a service will deploy only on nodes that have both cpu-group and memory-group attributes set to value high.
    See Also:
    Serialized Form
    • Constructor Detail

      • AttributeNodeFilter

        public AttributeNodeFilter​(String attrName,
                                   @Nullable
                                   @Nullable Object attrVal)
        Creates new node filter with a single attribute value.
        Parameters:
        attrName - Attribute name.
        attrVal - Attribute value.
      • AttributeNodeFilter

        public AttributeNodeFilter​(Map<String,​Object> attrs)
        Creates new node filter with a set of attributes.
        Parameters:
        attrs - Attributes.
    • Method Detail

      • getAttrs

        public Map<String,​Object> getAttrs()
        Gets attributes.
        Returns:
        Attributes collection.