Exemple #1
0
        /// <summary>
        /// Starts the client.
        /// </summary>
        private static IIgniteClient StartClient()
        {
            var cfg = new IgniteClientConfiguration(JavaServer.GetClientConfiguration())
            {
                Logger = new ListLogger(new ConsoleLogger {
                    MinLevel = LogLevel.Trace
                }),
                EnablePartitionAwareness = true
            };

            return(Ignition.StartClient(cfg));
        }
        public void TestReconnectToOldNodeDisablesPartitionAwareness()
        {
            IIgniteClient client = null;
            var           clientConfiguration = new IgniteClientConfiguration(JavaServer.GetClientConfiguration())
            {
                EnablePartitionAwareness = true,
                Logger = new ListLogger(new ConsoleLogger {
                    MinLevel = LogLevel.Trace
                })
            };

            try
            {
                using (StartNewServer())
                {
                    client = Ignition.StartClient(clientConfiguration);
                    var cache = client.GetOrCreateCache <int, int>(TestContext.CurrentContext.Test.Name);
                    cache.Put(1, 42);
                    Assert.AreEqual(42, cache.Get(1));
                    Assert.IsTrue(client.GetConfiguration().EnablePartitionAwareness);
                }

                Assert.Catch(() => client.GetCacheNames());

                using (StartOldServer())
                {
                    var cache = client.GetOrCreateCache <int, int>(TestContext.CurrentContext.Test.Name);
                    cache.Put(1, 42);
                    Assert.AreEqual(42, cache.Get(1));
                    Assert.IsFalse(client.GetConfiguration().EnablePartitionAwareness);

                    var log = ((ListLogger)client.GetConfiguration().Logger).Entries
                              .FirstOrDefault(e => e.Message.StartsWith("Partition"));

                    Assert.IsNotNull(log);
                    Assert.AreEqual("Partition awareness has been disabled: " +
                                    "server protocol version 1.0.0 is lower than required 1.4.0", log.Message);
                }
            }
            finally
            {
                if (client != null)
                {
                    client.Dispose();
                }
            }
        }