use of org.apache.ignite.configuration.TopologyValidator in project ignite by apache.
the class GridDhtTopologyFutureAdapter method validateCacheGroup.
/**
* @param grp Cache group.
* @param topNodes Topology nodes.
* @return Validation result.
*/
protected final CacheGroupValidation validateCacheGroup(CacheGroupContext grp, Collection<ClusterNode> topNodes) {
Collection<Integer> lostParts = grp.isLocal() ? Collections.<Integer>emptyList() : grp.topology().lostPartitions();
boolean valid = true;
if (!grp.systemCache()) {
for (TopologyValidator validator : grp.topologyValidators()) {
if (!validator.validate(topNodes)) {
valid = false;
break;
}
}
}
return new CacheGroupValidation(valid, lostParts);
}
use of org.apache.ignite.configuration.TopologyValidator in project ignite by apache.
the class CacheGroupContext method topologyValidators.
/**
* @param ccfg Cache configuration.
* @param plugins Ignite plugin processor.
* @return Comprehensive collection of topology validators for the cache based on its configuration
* and plugin extensions.
*/
private Collection<TopologyValidator> topologyValidators(CacheConfiguration<?, ?> ccfg, IgnitePluginProcessor plugins) {
List<TopologyValidator> res = new ArrayList<>();
TopologyValidator ccfgTopValidator = ccfg.getTopologyValidator();
if (ccfgTopValidator != null)
res.add(ccfgTopValidator);
CacheTopologyValidatorProvider[] topValidatorProviders = plugins.extensions(CacheTopologyValidatorProvider.class);
if (F.isEmpty(topValidatorProviders))
return res;
for (CacheTopologyValidatorProvider topValidatorProvider : topValidatorProviders) {
TopologyValidator validator = topValidatorProvider.topologyValidator(cacheOrGroupName());
if (validator != null)
res.add(validator);
}
return res;
}
use of org.apache.ignite.configuration.TopologyValidator in project ignite by apache.
the class CacheValidatorMetricsTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
cfg.setActiveOnStart(false);
CacheConfiguration cCfg1 = new CacheConfiguration().setName(CACHE_NAME_1).setCacheMode(CacheMode.PARTITIONED).setBackups(0).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setPartitionLossPolicy(PartitionLossPolicy.READ_ONLY_SAFE);
CacheConfiguration cCfg2 = new CacheConfiguration().setName(CACHE_NAME_2).setCacheMode(CacheMode.REPLICATED).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setTopologyValidator(new TopologyValidator() {
@Override
public boolean validate(Collection<ClusterNode> nodes) {
return nodes.size() == 2;
}
});
cfg.setCacheConfiguration(cCfg1, cCfg2);
return cfg;
}
Aggregations