Search in sources :

Example 1 with TopologyValidator

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);
}
Also used : TopologyValidator(org.apache.ignite.configuration.TopologyValidator)

Example 2 with TopologyValidator

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;
}
Also used : CacheTopologyValidatorProvider(org.apache.ignite.plugin.CacheTopologyValidatorProvider) ArrayList(java.util.ArrayList) TopologyValidator(org.apache.ignite.configuration.TopologyValidator)

Example 3 with TopologyValidator

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TopologyValidator(org.apache.ignite.configuration.TopologyValidator) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Aggregations

TopologyValidator (org.apache.ignite.configuration.TopologyValidator)3 ArrayList (java.util.ArrayList)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 CacheTopologyValidatorProvider (org.apache.ignite.plugin.CacheTopologyValidatorProvider)1