You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by cparaskeva <ch...@gmail.com> on 2020/07/15 14:58:02 UTC

Apache Ignite CacheRebalanceMode Is Not Respected By Nodes

The setup: Hello folks I have a simple Apache Ignite setup with two Ignite
instances configured as server nodes over C# and one Ignite instance as a
client node over java.

What is the goal: Populate data on instance 1 and instance 2 but avoid
movement of data between them. In other words data receiced on each node
must stay in node. Then using the java client to run queries against the two
nodes either combined (distributed join) or per node (using affinity).

The issue: With one server node everything works as expected, however on
more than one server nodes, data of the cluster is balancing between the x
member nodes even if I have expliccitly set the CacheRebalanceMode to None
which should disable the rebalance between then nodes. The insert time is
increase by 4x-10x times, function to each node's populated data.

P.S. I have tried change the cache mode from Partitioned to Local where each
node will have isolated the data in it's internal H2 db however in that case
the Java client is unable to detect the nodes or read any data from the
cache of each node.

Java Client Node

        IgniteConfiguration cfg = new IgniteConfiguration();
        // Enable client mode.
        cfg.setClientMode(true);

        // Setting up an IP Finder to ensure the client can locate the
servers.
        TcpDiscoveryMulticastIpFinder ipFinder = new
TcpDiscoveryMulticastIpFinder();
       
ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500..47509"));
        cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));

        // Configure Ignite to connect with .NET nodes
        cfg.setBinaryConfiguration(new BinaryConfiguration()
                        .setNameMapper(new BinaryBasicNameMapper(true))
                        .setCompactFooter(true)

        // Start Ignite in client mode.
        Ignite ignite = Ignition.start(cfg);

        
        IgniteCache<AffinityKey, Trade> cache0 = ignite.cache(CACHE_NAME);
        IgniteCache<AffinityKey, BinaryObject> cache =
cache0.withKeepBinary();
    
        // execute some queries to nodes
C# Server Node


               IIgnite _ignite =
Ignition.Start(IgniteUtils.DefaultIgniteConfig()));

                // Create new cache and configure queries for Trade binary
types.
                // Note that there are no such classes defined.
                var cache0 = _ignite.GetOrCreateCache<AffinityKey,
Trade>("DEALIO");

                // Switch to binary mode to work with data in serialized
form.
                _cache = cache0.WithKeepBinary<AffinityKey,
IBinaryObject>();

               //populate some data ...

        public static IgniteConfiguration DefaultIgniteConfig()
        {
            return new IgniteConfiguration
            {

               
                PeerAssemblyLoadingMode =
PeerAssemblyLoadingMode.CurrentAppDomain,
                BinaryConfiguration = new BinaryConfiguration
                {
                    NameMapper = new BinaryBasicNameMapper { IsSimpleName =
true },
                    CompactFooter = true,
                    TypeConfigurations = new[] {
                        new BinaryTypeConfiguration(typeof(Trade)) {
                            Serializer = new IgniteTradeSerializer()
                        }
                    }
                },
                DiscoverySpi = new TcpDiscoverySpi
                {
                    IpFinder = new TcpDiscoveryMulticastIpFinder
                    {
                        Endpoints = new[] { "127.0.0.1:47500..47509" }
                    },
                    SocketTimeout = TimeSpan.FromSeconds(0.10)
                },
                Logger = new IgniteNLogLogger(),
                CacheConfiguration = new[]{
                    new CacheConfiguration{
                            PartitionLossPolicy=PartitionLossPolicy.Ignore,
                            RebalanceMode=CacheRebalanceMode.None,
                            Name = CACHE_NAME,
                            CacheMode = CacheMode.Partitioned,
                            Backups = 0,
                            QueryEntities = new[] { 
                                new QueryEntity(typeof(AffinityKey),
typeof(Trade))
                            }
                }
            }
            };
        }



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Apache Ignite CacheRebalanceMode Is Not Respected By Nodes

Posted by Denis Magda <dm...@apache.org>.
Here is a detailed instruction for managing data distribution across server
nodes:
https://www.gridgain.com/docs/latest/developers-guide/configuring-caches/managing-data-distribution

-
Denis


On Tue, Jul 21, 2020 at 6:19 PM Evgenii Zhuravlev <e....@gmail.com>
wrote:

> Hi,
>
> CacheRebalanceMode is responsible for a different thing - it starts to
> work when data need to be rebalanced due to topology(or baseline topology
> change). It's not responsible for data distribution between nodes for put
> operations. So, when you insert data, part of this data belongs to the
> partitions which are not related to the local node.
>
> To achieve what you want, you can just create 2 different caches with
> NodeFilter:
> https://www.javadoc.io/doc/org.apache.ignite/ignite-core/latest/org/apache/ignite/util/AttributeNodeFilter.html
> Using that you can avoid data movement between nodes and your thin client
> will see these caches too.
>
> Evgenii
>
>
>
>
> ср, 15 июл. 2020 г. в 07:58, cparaskeva <ch...@gmail.com>:
>
>> The setup: Hello folks I have a simple Apache Ignite setup with two Ignite
>> instances configured as server nodes over C# and one Ignite instance as a
>> client node over java.
>>
>> What is the goal: Populate data on instance 1 and instance 2 but avoid
>> movement of data between them. In other words data receiced on each node
>> must stay in node. Then using the java client to run queries against the
>> two
>> nodes either combined (distributed join) or per node (using affinity).
>>
>> The issue: With one server node everything works as expected, however on
>> more than one server nodes, data of the cluster is balancing between the x
>> member nodes even if I have expliccitly set the CacheRebalanceMode to None
>> which should disable the rebalance between then nodes. The insert time is
>> increase by 4x-10x times, function to each node's populated data.
>>
>> P.S. I have tried change the cache mode from Partitioned to Local where
>> each
>> node will have isolated the data in it's internal H2 db however in that
>> case
>> the Java client is unable to detect the nodes or read any data from the
>> cache of each node.
>>
>> Java Client Node
>>
>>         IgniteConfiguration cfg = new IgniteConfiguration();
>>         // Enable client mode.
>>         cfg.setClientMode(true);
>>
>>         // Setting up an IP Finder to ensure the client can locate the
>> servers.
>>         TcpDiscoveryMulticastIpFinder ipFinder = new
>> TcpDiscoveryMulticastIpFinder();
>>
>> ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500
>> ..47509"));
>>         cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
>>
>>         // Configure Ignite to connect with .NET nodes
>>         cfg.setBinaryConfiguration(new BinaryConfiguration()
>>                         .setNameMapper(new BinaryBasicNameMapper(true))
>>                         .setCompactFooter(true)
>>
>>         // Start Ignite in client mode.
>>         Ignite ignite = Ignition.start(cfg);
>>
>>
>>         IgniteCache<AffinityKey, Trade> cache0 = ignite.cache(CACHE_NAME);
>>         IgniteCache<AffinityKey, BinaryObject> cache =
>> cache0.withKeepBinary();
>>
>>         // execute some queries to nodes
>> C# Server Node
>>
>>
>>                IIgnite _ignite =
>> Ignition.Start(IgniteUtils.DefaultIgniteConfig()));
>>
>>                 // Create new cache and configure queries for Trade binary
>> types.
>>                 // Note that there are no such classes defined.
>>                 var cache0 = _ignite.GetOrCreateCache<AffinityKey,
>> Trade>("DEALIO");
>>
>>                 // Switch to binary mode to work with data in serialized
>> form.
>>                 _cache = cache0.WithKeepBinary<AffinityKey,
>> IBinaryObject>();
>>
>>                //populate some data ...
>>
>>         public static IgniteConfiguration DefaultIgniteConfig()
>>         {
>>             return new IgniteConfiguration
>>             {
>>
>>
>>                 PeerAssemblyLoadingMode =
>> PeerAssemblyLoadingMode.CurrentAppDomain,
>>                 BinaryConfiguration = new BinaryConfiguration
>>                 {
>>                     NameMapper = new BinaryBasicNameMapper { IsSimpleName
>> =
>> true },
>>                     CompactFooter = true,
>>                     TypeConfigurations = new[] {
>>                         new BinaryTypeConfiguration(typeof(Trade)) {
>>                             Serializer = new IgniteTradeSerializer()
>>                         }
>>                     }
>>                 },
>>                 DiscoverySpi = new TcpDiscoverySpi
>>                 {
>>                     IpFinder = new TcpDiscoveryMulticastIpFinder
>>                     {
>>                         Endpoints = new[] { "127.0.0.1:47500..47509" }
>>                     },
>>                     SocketTimeout = TimeSpan.FromSeconds(0.10)
>>                 },
>>                 Logger = new IgniteNLogLogger(),
>>                 CacheConfiguration = new[]{
>>                     new CacheConfiguration{
>>
>> PartitionLossPolicy=PartitionLossPolicy.Ignore,
>>                             RebalanceMode=CacheRebalanceMode.None,
>>                             Name = CACHE_NAME,
>>                             CacheMode = CacheMode.Partitioned,
>>                             Backups = 0,
>>                             QueryEntities = new[] {
>>                                 new QueryEntity(typeof(AffinityKey),
>> typeof(Trade))
>>                             }
>>                 }
>>             }
>>             };
>>         }
>>
>>
>>
>> --
>> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>>
>

Re: Apache Ignite CacheRebalanceMode Is Not Respected By Nodes

Posted by Evgenii Zhuravlev <e....@gmail.com>.
Hi,

CacheRebalanceMode is responsible for a different thing - it starts to work
when data need to be rebalanced due to topology(or baseline topology
change). It's not responsible for data distribution between nodes for put
operations. So, when you insert data, part of this data belongs to the
partitions which are not related to the local node.

To achieve what you want, you can just create 2 different caches with
NodeFilter:
https://www.javadoc.io/doc/org.apache.ignite/ignite-core/latest/org/apache/ignite/util/AttributeNodeFilter.html
Using that you can avoid data movement between nodes and your thin client
will see these caches too.

Evgenii




ср, 15 июл. 2020 г. в 07:58, cparaskeva <ch...@gmail.com>:

> The setup: Hello folks I have a simple Apache Ignite setup with two Ignite
> instances configured as server nodes over C# and one Ignite instance as a
> client node over java.
>
> What is the goal: Populate data on instance 1 and instance 2 but avoid
> movement of data between them. In other words data receiced on each node
> must stay in node. Then using the java client to run queries against the
> two
> nodes either combined (distributed join) or per node (using affinity).
>
> The issue: With one server node everything works as expected, however on
> more than one server nodes, data of the cluster is balancing between the x
> member nodes even if I have expliccitly set the CacheRebalanceMode to None
> which should disable the rebalance between then nodes. The insert time is
> increase by 4x-10x times, function to each node's populated data.
>
> P.S. I have tried change the cache mode from Partitioned to Local where
> each
> node will have isolated the data in it's internal H2 db however in that
> case
> the Java client is unable to detect the nodes or read any data from the
> cache of each node.
>
> Java Client Node
>
>         IgniteConfiguration cfg = new IgniteConfiguration();
>         // Enable client mode.
>         cfg.setClientMode(true);
>
>         // Setting up an IP Finder to ensure the client can locate the
> servers.
>         TcpDiscoveryMulticastIpFinder ipFinder = new
> TcpDiscoveryMulticastIpFinder();
>
> ipFinder.setAddresses(Collections.singletonList("127.0.0.1:47500
> ..47509"));
>         cfg.setDiscoverySpi(new TcpDiscoverySpi().setIpFinder(ipFinder));
>
>         // Configure Ignite to connect with .NET nodes
>         cfg.setBinaryConfiguration(new BinaryConfiguration()
>                         .setNameMapper(new BinaryBasicNameMapper(true))
>                         .setCompactFooter(true)
>
>         // Start Ignite in client mode.
>         Ignite ignite = Ignition.start(cfg);
>
>
>         IgniteCache<AffinityKey, Trade> cache0 = ignite.cache(CACHE_NAME);
>         IgniteCache<AffinityKey, BinaryObject> cache =
> cache0.withKeepBinary();
>
>         // execute some queries to nodes
> C# Server Node
>
>
>                IIgnite _ignite =
> Ignition.Start(IgniteUtils.DefaultIgniteConfig()));
>
>                 // Create new cache and configure queries for Trade binary
> types.
>                 // Note that there are no such classes defined.
>                 var cache0 = _ignite.GetOrCreateCache<AffinityKey,
> Trade>("DEALIO");
>
>                 // Switch to binary mode to work with data in serialized
> form.
>                 _cache = cache0.WithKeepBinary<AffinityKey,
> IBinaryObject>();
>
>                //populate some data ...
>
>         public static IgniteConfiguration DefaultIgniteConfig()
>         {
>             return new IgniteConfiguration
>             {
>
>
>                 PeerAssemblyLoadingMode =
> PeerAssemblyLoadingMode.CurrentAppDomain,
>                 BinaryConfiguration = new BinaryConfiguration
>                 {
>                     NameMapper = new BinaryBasicNameMapper { IsSimpleName =
> true },
>                     CompactFooter = true,
>                     TypeConfigurations = new[] {
>                         new BinaryTypeConfiguration(typeof(Trade)) {
>                             Serializer = new IgniteTradeSerializer()
>                         }
>                     }
>                 },
>                 DiscoverySpi = new TcpDiscoverySpi
>                 {
>                     IpFinder = new TcpDiscoveryMulticastIpFinder
>                     {
>                         Endpoints = new[] { "127.0.0.1:47500..47509" }
>                     },
>                     SocketTimeout = TimeSpan.FromSeconds(0.10)
>                 },
>                 Logger = new IgniteNLogLogger(),
>                 CacheConfiguration = new[]{
>                     new CacheConfiguration{
>                             PartitionLossPolicy=PartitionLossPolicy.Ignore,
>                             RebalanceMode=CacheRebalanceMode.None,
>                             Name = CACHE_NAME,
>                             CacheMode = CacheMode.Partitioned,
>                             Backups = 0,
>                             QueryEntities = new[] {
>                                 new QueryEntity(typeof(AffinityKey),
> typeof(Trade))
>                             }
>                 }
>             }
>             };
>         }
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>