org.apache.ignite.util

## Class AttributeNodeFilter

- java.lang.Object
- - org.apache.ignite.util.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.ClusterAttributeNodeFilter">
             <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.ClusterAttributeNodeFilter">
             <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 Summary

Constructors
Constructor and Description
`AttributeNodeFilter(Map<String,Object> attrs)` Creates new node filter with a set of attributes.
`AttributeNodeFilter(String attrName, Object attrVal)` Creates new node filter with a single attribute value.

### Method Summary

Methods
`boolean` `apply(ClusterNode node)` Predicate body.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AttributeNodeFilter

    public AttributeNodeFilter(String attrName,
                       @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

#### apply

    public boolean apply(ClusterNode node)

Predicate body.

Specified by:
  `apply` in interface `IgnitePredicate<ClusterNode>`
Parameters:
  `node` - Predicate parameter.
Returns:
  Return value.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017