You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexand Polyakov (JIRA)" <ji...@apache.org> on 2019/01/27 17:01:01 UTC

[jira] [Updated] (IGNITE-7883) Cluster can have inconsistent affinity configuration

     [ https://issues.apache.org/jira/browse/IGNITE-7883?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexand Polyakov updated IGNITE-7883:
-------------------------------------
    Attachment:     (was: TC recheck 04.png)

> 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
>            Assignee: Alexand Polyakov
>            Priority: Major
>             Fix For: 2.8
>
>         Attachments: TC recheck 01.png, TC recheck 02.png, TC.png
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> 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}
> package affinity;
> import org.apache.ignite.Ignite;
> import org.apache.ignite.Ignition;
> import org.apache.ignite.cache.CacheAtomicityMode;
> import org.apache.ignite.cache.CacheKeyConfiguration;
> import org.apache.ignite.cache.CacheMode;
> import org.apache.ignite.cache.affinity.Affinity;
> import org.apache.ignite.configuration.CacheConfiguration;
> import org.apache.ignite.configuration.IgniteConfiguration;
> import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
> import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
> import java.util.Arrays;
> 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);
>         }
>         System.out.println("DONE");
>     }
>     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++);
>         CacheConfiguration cacheCfg = new CacheConfiguration("TEST");
>         cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
>         cacheCfg.setCacheMode(CacheMode.PARTITIONED);
>         if(withAffinityCfg) {
>             cacheCfg.setKeyConfiguration(new CacheKeyConfiguration("affinity.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{" +
>                 "a=" + a +
>                 '}';
>     }
> }
> {code}



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