ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexand Polyakov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (IGNITE-7883) Cluster can have inconsistent affinity configuration
Date Fri, 18 May 2018 11:17:00 GMT

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

Alexand Polyakov updated IGNITE-7883:
-------------------------------------
    Attachment: TC.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.6
>
>         Attachments: TC.png
>
>
> 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)

Mime
View raw message