Esempio n. 1
0
        public void TestUseIgniteFromClrThreadsDoesNotLeakJvmThreads()
        {
            var cache = Ignite.GetOrCreateCache <int, int>("c");

            cache.Put(0, 0);

            var threadNamesBefore = GetJavaThreadNames();

            // Wait for Java threads to stabilize.
            Thread.Sleep(TestUtils.DfltBusywaitSleepInterval);
            Assert.IsTrue(TestUtils.WaitForCondition(() =>
            {
                var threadNames   = threadNamesBefore;
                threadNamesBefore = GetJavaThreadNames();
                return(threadNames.SequenceEqual(threadNamesBefore));
            }, 5000));

            // Run Ignite operations on C# threads to cause JNI thread attach.
            TestUtils.RunMultiThreaded(() => cache.Put(1, 1), 10);

            // Verify that all JNI threads are cleaned up and Java thread set is the same.
            var threadNamesAfter = GetJavaThreadNames();
            var message          = GetMessage(threadNamesBefore, threadNamesAfter);

            Assert.AreEqual(threadNamesBefore, threadNamesAfter, message);
            Assert.IsNotEmpty(threadNamesAfter);

            Console.WriteLine("Java Threads: {0}", string.Join(", ", threadNamesAfter));
        }
Esempio n. 2
0
        public async Task TestLocalOperationExecutesSynchronously()
        {
            var cache      = Ignite.GetOrCreateCache <int, int>(TestUtils.TestName);
            var key        = TestUtils.GetPrimaryKey(Ignite, cache.Name);
            var origThread = Thread.CurrentThread;

            await cache.PutAsync(key, key);

            Assert.AreEqual(origThread.ManagedThreadId, Thread.CurrentThread.ManagedThreadId);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the cache.
        /// </summary>
        private ICache <int, int> GetCache()
        {
            var cacheConfiguration = new CacheConfiguration(TestUtils.TestName)
            {
                AtomicityMode = CacheAtomicityMode.Transactional
            };

            var cache = Ignite.GetOrCreateCache <int, int>(cacheConfiguration);

            cache[1] = 1;

            return(cache);
        }
Esempio n. 4
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());
        }
Esempio n. 5
0
        public void TestUseIgniteFromClrThreadsDoesNotLeakJvmThreads()
        {
            var cache = Ignite.GetOrCreateCache <int, int>("c");

            cache.Put(0, 0);

            var threadNamesBefore = GetJavaThreadNames();

            TestUtils.RunMultiThreaded(() => cache.Put(1, 1), 10);

            var threadNamesAfter = GetJavaThreadNames();

            Assert.AreEqual(threadNamesBefore, threadNamesAfter);
            Assert.IsNotEmpty(threadNamesAfter);
        }
Esempio n. 6
0
        public void TestGetOrCreateFromTemplate()
        {
            // Create a cache with random name
            var randomName = "template" + Guid.NewGuid();

            // Can't get non-existent cache with Cache method
            Assert.Throws <ArgumentException>(() => Ignite.GetCache <int, int>(randomName));

            // Create cache and verify template setting.
            var cache = Ignite.GetOrCreateCache <int, int>(randomName);

            Assert.AreEqual(3, cache.GetConfiguration().Backups);

            cache.Put(1, 10);
            Assert.AreEqual(10, cache.Get(1));

            var cache0 = Ignite.GetOrCreateCache <int, int>(randomName);

            Assert.AreEqual(10, cache0.Get(1));

            var cache1 = Ignite.GetCache <int, int>(randomName);

            Assert.AreEqual(10, cache1.Get(1));
        }
 public virtual void GlobalSetup()
 {
     Ignite = Ignition.Start(Utils.GetIgniteConfiguration());
     Cache  = Ignite.GetOrCreateCache <int, int>("c");
 }