예제 #1
0
        public void TestFailedConnection()
        {
            var cfg = new IgniteConfiguration
            {
                SpringConfigUrl = "config\\reconnect-test.xml",
                JvmClasspath    = TestUtils.CreateTestClasspath(),
                JvmOptions      = TestUtils.TestJavaOptions()
            };

            var proc = new Process.IgniteProcess(
                "-springConfigUrl=" + cfg.SpringConfigUrl, "-J-ea", "-J-Xcheck:jni", "-J-Xms512m", "-J-Xmx512m",
                "-J-DIGNITE_QUIET=false");

            Ignition.ClientMode = true;

            using (var ignite = Ignition.Start(cfg))
            {
                var reconnected  = 0;
                var disconnected = 0;
                ignite.ClientDisconnected += (sender, args) => { disconnected++; };
                ignite.ClientReconnected  += (sender, args) => { reconnected += args.HasClusterRestarted ? 10 : 1; };

                Assert.IsTrue(ignite.GetCluster().ClientReconnectTask.IsCompleted);

                var cache = ignite.CreateCache <int, int>(CacheName);

                cache[1] = 1;

                // Suspend external process to cause disconnect
                proc.Suspend();

                var ex = Assert.Throws <CacheException>(() => cache.Get(1));

                Assert.IsTrue(ex.ToString().Contains(
                                  "javax.cache.CacheException: class org.apache.ignite.IgniteClientDisconnectedException: " +
                                  "Operation has been cancelled (client node disconnected)"));

                var inner = (ClientDisconnectedException)ex.InnerException;

                Assert.IsNotNull(inner);

                var clientReconnectTask = inner.ClientReconnectTask;

                Assert.AreEqual(ignite.GetCluster().ClientReconnectTask, clientReconnectTask);
                Assert.AreEqual(1, disconnected);
                Assert.AreEqual(0, reconnected);

                // Resume process to reconnect
                proc.Resume();

                Assert.IsFalse(clientReconnectTask.Result);

                Assert.AreEqual(1, cache[1]);
                Assert.AreEqual(1, disconnected);

                Thread.Sleep(100);  // Wait for event handler
                Assert.AreEqual(1, reconnected);
            }
        }
예제 #2
0
        public void SetUp()
        {
            const string springConfigUrl = "config\\compute\\compute-grid1.xml";
            
            // ReSharper disable once UnusedVariable
            var proc = new IgniteProcess(
                "-jvmClasspath=" + TestUtils.CreateTestClasspath(),
                "-springConfigUrl=" + Path.GetFullPath(springConfigUrl),
                "-J-ea",
                "-J-Xcheck:jni",
                "-J-Xms512m",
                "-J-Xmx512m",
                "-J-DIGNITE_QUIET=false"
                );

            _grid = Ignition.Start(new IgniteConfiguration
            {
                JvmClasspath = TestUtils.CreateTestClasspath(),
                JvmOptions = TestUtils.TestJavaOptions(),
                SpringConfigUrl = springConfigUrl
            });

            Assert.IsTrue(_grid.WaitTopology(2, 30000));
        }
예제 #3
0
        /// <summary>
        /// Tests the example with standalone Apache.Ignite.exe nodes.
        /// </summary>
        /// <param name="example">The example to run.</param>
        /// <param name="clientMode">Client mode flag.</param>
        private static void TestRemoteNodes(Example example, bool clientMode)
        {
            // Exclude LifecycleExample
            if (string.IsNullOrEmpty(example.ConfigPath))
            {
                Assert.AreEqual("LifecycleExample", example.Name);

                return;
            }

            var configPath = Path.Combine(PathUtil.IgniteHome, PathUtil.DevPrefix, example.ConfigPath);

            // Try with multiple standalone nodes
            for (var i = 0; i < 2; i++)
            {
                // Start a grid to monitor topology
                // Stop it after topology check so we don't interfere with example
                Ignition.ClientMode = false;

                using (var ignite = Ignition.StartFromApplicationConfiguration(
                    "igniteConfiguration", configPath))
                {
                    var args = new List<string> { "-configFileName=" + configPath};

                    if (example.NeedsTestDll)
                        args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location);

                    var proc = new IgniteProcess(args.ToArray());

                    Assert.IsTrue(ignite.WaitTopology(i + 2));
                    Assert.IsTrue(proc.Alive);
                }

                Ignition.ClientMode = clientMode;

                // Run twice to catch issues with standalone node state
                example.Run();
                example.Run();
            }
        }
예제 #4
0
        /// <summary>
        /// Tests the example with standalone Apache.Ignite.exe nodes.
        /// </summary>
        /// <param name="example">The example to run.</param>
        /// <param name="clientMode">Client mode flag.</param>
        private static void TestRemoteNodes(Example example, bool clientMode)
        {
            // Exclude LifecycleExample
            if (string.IsNullOrEmpty(example.SpringConfigUrl))
            {
                Assert.AreEqual("LifecycleExample", example.Name);

                return;
            }

            // First node to start in current process defines JVM options.
            var gridConfig = new IgniteConfiguration
            {
                SpringConfigUrl = example.SpringConfigUrl,
                JvmOptions =
                    new[]
                    {
                        "-Xms512m", "-Xmx1024m", "-Xdebug", "-Xnoagent", "-Djava.compiler=NONE",
                        "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005"
                    }
            };

            // Try with multiple standalone nodes
            for (var i = 0; i < 2; i++)
            {
                // Start a grid to monitor topology
                // Stop it after topology check so we don't interfere with example
                Ignition.ClientMode = false;

                using (var ignite = Ignition.Start(gridConfig))
                {
                    var args = new List<string> {"-springConfigUrl=" + example.SpringConfigUrl};

                    if (example.NeedsTestDll)
                        args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location);

                    var proc = new IgniteProcess(args.ToArray());

                    Assert.IsTrue(ignite.WaitTopology(i + 2, 30000));
                    Assert.IsTrue(proc.Alive);
                }

                Ignition.ClientMode = clientMode;

                // Run twice to catch issues with standalone node state
                example.Run();
                example.Run();
            }
        }
예제 #5
0
        public void InitClient()
        {
            TestUtils.KillProcesses();

            if (_fork)
            {
                Grid1 = Ignition.Start(Configuration("config\\compute\\compute-standalone.xml"));

                _proc2 = Fork("config\\compute\\compute-standalone.xml");

                while (true)
                {
                    if (!_proc2.Alive)
                        throw new Exception("Process 2 died unexpectedly: " + _proc2.Join());

                    if (Grid1.GetCluster().GetNodes().Count < 2)
                        Thread.Sleep(100);
                    else
                        break;
                }

                _proc3 = Fork("config\\compute\\compute-standalone.xml");

                while (true)
                {
                    if (!_proc3.Alive)
                        throw new Exception("Process 3 died unexpectedly: " + _proc3.Join());

                    if (Grid1.GetCluster().GetNodes().Count < 3)
                        Thread.Sleep(100);
                    else
                        break;
                }
            }
            else
            {
                Grid1 = Ignition.Start(Configuration("config\\compute\\compute-grid1.xml"));
                _grid2 = Ignition.Start(Configuration("config\\compute\\compute-grid2.xml"));
                _grid3 = Ignition.Start(Configuration("config\\compute\\compute-grid3.xml"));
            }
        }