ignite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Cherkasov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (IGNITE-7883) Cluster can have inconsistent affinity configuration
Date Mon, 05 Mar 2018 15:50:00 GMT
Mikhail Cherkasov created IGNITE-7883:
-----------------------------------------

             Summary: Cluster can have inconsistent affinity configuration 
                 Key: IGNITE-7883
                 URL: https://issues.apache.org/jira/browse/IGNITE-7883
             Project: Ignite
          Issue Type: Bug
          Components: cache
    Affects Versions: 2.3
            Reporter: Mikhail Cherkasov
             Fix For: 2.5


A cluster can have inconsistent affinity configuration if you created two nodes, one with
affinity key configuration and other without it(in IgniteCfg or CacheCfg),  both nodes will
work fine with no exceptions, but in the same time they will apply different affinity rules
to keys:

 
{code:java}
public class Test {
    private static int id = 0;

    public static void main(String[] args) {
        Ignite ignite = Ignition.start(getConfiguration(true, false));
        Ignite ignite2 = Ignition.start(getConfiguration(false, false));

        Affinity<Object> affinity = ignite.affinity("TEST");
        Affinity<Object> affinity2 = ignite2.affinity("TEST");
        for (int i = 0; i < 1_000_000; i++) {
            AKey key = new AKey(i);

            if(affinity.partition(key) != affinity2.partition(key))
                System.out.println("FAILED for: " + key);
        }

    }

    @NotNull private static IgniteConfiguration getConfiguration(boolean withAffinityCfg,
boolean client) {
        IgniteConfiguration cfg = new IgniteConfiguration();

        TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder(true);
        finder.setAddresses(Arrays.asList("localhost:47500..47600"));

        cfg.setClientMode(client);

        cfg.setIgniteInstanceName("test" + id++);

        if(withAffinityCfg) {
            CacheConfiguration cacheCfg = new CacheConfiguration("TEST");

            cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
            cacheCfg.setCacheMode(CacheMode.PARTITIONED);

            cacheCfg.setKeyConfiguration(new CacheKeyConfiguration("multiplan.AKey", "a"));

            cfg.setCacheConfiguration(cacheCfg);
        }

        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(finder));

        return cfg;
    }
}

class AKey {

    int a;

    public AKey(int a) {
        this.a = a;
    }

    @Override public String toString() {
        return "AKey{" +
            "b=" + a +
            '}';
    }
}


{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message