Пример #1
0
        private static void PerformClientReconnect(IIgnite client)
        {
            var disconnectedEvt = new ManualResetEventSlim(false);

            client.ClientDisconnected += (sender, args) => { disconnectedEvt.Set(); };

            var reconnectedEvt = new ManualResetEventSlim(false);
            ClientReconnectEventArgs reconnectEventArgs = null;

            client.ClientReconnected += (sender, args) =>
            {
                reconnectEventArgs = args;
                reconnectedEvt.Set();
            };

            var gridName = string.Format("%{0}%", client.Name);

            TestUtilsJni.SuspendThreads(gridName);
            Thread.Sleep(9000);
            TestUtilsJni.ResumeThreads(gridName);

            Assert.Catch(() => client.CreateCache <int, int>("_fail").Put(1, 1));

            var disconnected = disconnectedEvt.Wait(TimeSpan.FromSeconds(3));

            Assert.IsTrue(disconnected);

            Assert.Catch(() => client.CreateCache <int, int>("_fail").Put(1, 1));
            var reconnected = reconnectedEvt.Wait(TimeSpan.FromSeconds(15));

            Assert.IsTrue(reconnected);
            Assert.IsFalse(reconnectEventArgs.HasClusterRestarted);
        }
Пример #2
0
        public async Task TestAsyncAwaitContinuationIsExecutedWithConfiguredExecutor()
        {
            var cache = Ignite.GetOrCreateCache <int, int>(TestUtils.TestName);
            var key   = TestUtils.GetPrimaryKey(Ignite2, cache.Name);

            // This causes deadlock if async continuation is executed on the striped thread.
            await cache.PutAsync(key, 1);

            cache.Replace(key, 2);

            Assert.AreEqual(2, cache.Get(key));
            StringAssert.DoesNotContain("sys-stripe-", TestUtilsJni.GetJavaThreadName());
        }
Пример #3
0
        public async Task TestSynchronousExecutorRunsContinuationsOnStripedPool()
        {
            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration(name: "client"))
            {
                AsyncContinuationExecutor = AsyncContinuationExecutor.UnsafeSynchronous,
                ClientMode = true
            };

            using (var client = Ignition.Start(cfg))
            {
                var cache = client.GetOrCreateCache <int, int>(TestUtils.TestName);

                await cache.PutAsync(1, 1);

                StringAssert.StartsWith("sys-stripe-", TestUtilsJni.GetJavaThreadName());

                Assert.AreEqual(AsyncContinuationExecutor.UnsafeSynchronous,
                                client.GetConfiguration().AsyncContinuationExecutor);

                // Jump away from striped pool to avoid deadlock on node stop.
                await Task.Yield();
            }
        }
Пример #4
0
        public async Task TestComputeExecuteAsyncContinuation()
        {
            await Ignite.GetCompute().ExecuteAsync(new StringLengthEmptyTask(), "abc");

            StringAssert.StartsWith("Thread-", TestUtilsJni.GetJavaThreadName());
        }
Пример #5
0
        public async Task TestComputeRunAsyncContinuation()
        {
            await Ignite.GetCompute().RunAsync(new ComputeAction());

            StringAssert.StartsWith("Thread-", TestUtilsJni.GetJavaThreadName());
        }
 public void FixtureTearDown()
 {
     TestUtilsJni.StopIgnite("server");
 }
 public void FixtureSetUp()
 {
     TestUtils.EnsureJvmCreated();
     TestUtilsJni.StartIgnite("server");
 }