Apache Ignite Documentation

GridGain Developer Hub - Apache Ignitetm

Welcome to the Apache Ignite developer hub run by GridGain. Here you'll find comprehensive guides and documentation to help you start working with Apache Ignite as quickly as possible, as well as support if you get stuck.

 

GridGain also provides Community Edition which is a distribution of Apache Ignite made available by GridGain. It is the fastest and easiest way to get started with Apache Ignite. The Community Edition is generally more stable than the Apache Ignite release available from the Apache Ignite website and may contain extra bug fixes and features that have not made it yet into the release on the Apache website.

 

Let's jump right in!

 

Documentation     Ask a Question     Download

 

Javadoc     Scaladoc     Examples

Topology Validation

Topology validator is used to verify that cluster topology is valid for further cache operations.

The topology validator is invoked every time the cluster topology changes (either a new node joined or an existing node failed or left). If the topology validator is not configured, then the cluster topology is always considered to be valid.

Whenever the TopologyValidator.validate(Collection) method returns true, then the topology is considered valid for a certain cache and all operations on this cache will be allowed to proceed. Otherwise, all update operations on the cache are restricted with the following exceptions:

  • CacheException will be thrown for all update operations (put, remove, etc) attempts.
  • IgniteException will be thrown for the transaction commit attempt.

After returning false and declaring the topology not valid, the topology validator can return to normal state whenever the next topology change happens.

Example

...
for (CacheConfiguration cCfg : iCfg.getCacheConfiguration()) {
    if (cCfg.getName() != null) {
        if (cCfg.getName().equals(CACHE_NAME_1))
            cCfg.setTopologyValidator(new TopologyValidator() {
                @Override public boolean validate(Collection<ClusterNode> nodes) {
                    return nodes.size() == 2;
                }
            });
        else if (cCfg.getName().equals(CACHE_NAME_2))
            cCfg.setTopologyValidator(new TopologyValidator() {
                @Override public boolean validate(Collection<ClusterNode> nodes) {
                    return nodes.size() >= 2;
                }
            });
    }
}
...

In this example update operations will be allowed to cache with name:

  • CACHE_NAME_1 where the cluster contains exactly 2 nodes
  • CACHE_NAME_2 where the cluster contain at least 2 nodes.

Configuration
The topology validator can be configured either from code or XML via the CacheConfiguration.setTopologyValidator(TopologyValidator) method.

Updated about a year ago

Topology Validation


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.