public void TestStartGetStop()
        {
            var grid1 = Ignition.Start(TestUtils.GetTestConfiguration(name: "grid1"));

            Assert.AreEqual("grid1", grid1.Name);
            Assert.AreSame(grid1, Ignition.GetIgnite());
            Assert.AreSame(grid1, Ignition.GetAll().Single());

            var grid2 = Ignition.Start(TestUtils.GetTestConfiguration(name: "grid2"));

            Assert.AreEqual("grid2", grid2.Name);
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite());

            var grid3 = Ignition.Start(TestUtils.GetTestConfiguration());

            Assert.IsNull(grid3.Name);

            Assert.AreSame(grid1, Ignition.GetIgnite("grid1"));
            Assert.AreSame(grid1, Ignition.TryGetIgnite("grid1"));

            Assert.AreSame(grid2, Ignition.GetIgnite("grid2"));
            Assert.AreSame(grid2, Ignition.TryGetIgnite("grid2"));

            Assert.AreSame(grid3, Ignition.GetIgnite(null));
            Assert.AreSame(grid3, Ignition.GetIgnite());
            Assert.AreSame(grid3, Ignition.TryGetIgnite(null));
            Assert.AreSame(grid3, Ignition.TryGetIgnite());

            Assert.AreEqual(new[] { grid3, grid1, grid2 }, Ignition.GetAll().OrderBy(x => x.Name).ToArray());

            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("invalid_name"));
            Assert.IsNull(Ignition.TryGetIgnite("invalid_name"));


            Assert.IsTrue(Ignition.Stop("grid1", true));
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("grid1"));

            grid2.Dispose();
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("grid2"));

            grid3.Dispose();
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("grid3"));

            // Restart.
            Ignition.Start(TestUtils.GetTestConfiguration(name: "grid1"));
            Ignition.Start(TestUtils.GetTestConfiguration(name: "grid2"));
            Ignition.Start(TestUtils.GetTestConfiguration());

            foreach (var gridName in new [] { "grid1", "grid2", null })
            {
                Assert.IsNotNull(Ignition.GetIgnite(gridName));
            }

            Ignition.StopAll(true);

            foreach (var gridName in new [] { "grid1", "grid2", null })
            {
                Assert.Throws <IgniteException>(() => Ignition.GetIgnite(gridName));
            }
        }
Exemple #2
0
 /// <summary>
 /// Gets loggers from all server nodes.
 /// </summary>
 protected static IEnumerable <ListLogger> GetLoggers()
 {
     return(Ignition.GetAll()
            .OrderBy(i => i.Name)
            .Select(i => i.Logger)
            .Cast <ListLogger>());
 }
        public void TestTwoServers()
        {
            var cfg1 = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                SpringConfigUrl = @"Config/ssl.xml"
            };

            var cfg2 = new IgniteConfiguration(TestUtils.GetTestConfiguration(name: "grid2"))
            {
                SslContextFactory = GetSslContextFactory()
            };

            var grid1 = Ignition.Start(cfg1);

            Assert.AreEqual("grid1", grid1.Name);
            Assert.AreSame(grid1, Ignition.GetIgnite());
            Assert.AreSame(grid1, Ignition.GetAll().Single());

            var grid2 = Ignition.Start(cfg2);

            Assert.AreEqual("grid2", grid2.Name);
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite());

            Assert.AreSame(grid1, Ignition.GetIgnite("grid1"));
            Assert.AreSame(grid1, Ignition.TryGetIgnite("grid1"));

            Assert.AreSame(grid2, Ignition.GetIgnite("grid2"));
            Assert.AreSame(grid2, Ignition.TryGetIgnite("grid2"));

            Assert.AreEqual(new[] { grid1, grid2 }, Ignition.GetAll().OrderBy(x => x.Name).ToArray());

            Assert.AreEqual(2, grid1.GetCluster().GetNodes().Count);
            Assert.AreEqual(2, grid2.GetCluster().GetNodes().Count);
        }
        public void TestCacheStartFromCodeSkipsInvalidQueryEntityTypes()
        {
            var cfg = new CacheConfiguration
            {
                Name          = TestUtils.TestName,
                QueryEntities = new[]
                {
                    new QueryEntity
                    {
                        KeyTypeName   = "Invalid_Name",
                        ValueTypeName = "Invalid_Name"
                    }
                }
            };

            Ignition.GetIgnite("0").CreateCache <object, object>(cfg);

            foreach (var ignite in Ignition.GetAll())
            {
                var types     = ignite.GetBinary().GetBinaryTypes();
                var qryEntity = ignite.GetCache <object, object>(cfg.Name).GetConfiguration().QueryEntities.Single();

                var keyType = types.FirstOrDefault(t => t.TypeName == qryEntity.KeyTypeName);
                var valType = types.FirstOrDefault(t => t.TypeName == qryEntity.ValueTypeName);

                Assert.IsNull(keyType);
                Assert.IsNull(valType);
            }
        }
Exemple #5
0
 public void TestAffinityKeyMappedWithQueryEntitySpringXml()
 {
     foreach (var ignite in Ignition.GetAll())
     {
         TestAffinityKeyMappedWithQueryEntity0(ignite, "cache1");
     }
 }
Exemple #6
0
        public void TestClientDiscoveryWithBaselineTopologyChange()
        {
            var cache = Client.GetOrCreateCache <int, int>(TestUtils.TestName);

            AssertClientConnectionCount(Client, 3);
            cache.Put(1, 1);

            // Start new node.
            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());

            AssertClientConnectionCount(Client, 4);
            cache.Put(2, 2);

            // Add new node to baseline.
            var cluster = ignite.GetCluster();

            cluster.SetBaselineTopology(cluster.TopologyVersion);

            AssertClientConnectionCount(Client, 4);
            cache.Put(3, 3);

            // Stop node to remove from baseline (live node can't be removed from baseline).
            ignite.Dispose();

            cluster = Ignition.GetAll().First().GetCluster();
            cluster.SetBaselineTopology(cluster.TopologyVersion);

            AssertClientConnectionCount(Client, 3);
            cache.Put(4, 4);
        }
Exemple #7
0
 /// <summary>
 /// Gets Ignite.
 /// </summary>
 protected static IIgnite GetIgnite(int?idx = null)
 {
     if (idx == null)
     {
         return(Ignition.GetAll().First(i => i.Name == null));
     }
     return(Ignition.GetIgnite(idx.ToString()));
 }
Exemple #8
0
        /** <inheritdoc /> */
        public override void FixtureSetUp()
        {
            base.FixtureSetUp();

            var cluster = Ignition.GetAll().First().GetCluster();

            cluster.SetBaselineAutoAdjustEnabledFlag(false);
            cluster.SetBaselineTopology(cluster.TopologyVersion);
        }
        public void TestCacheStartFromCodeRegistersMetaForQueryEntityTypes()
        {
            var cfg = new CacheConfiguration
            {
                Name          = TestUtils.TestName,
                QueryEntities = new[]
                {
                    new QueryEntity
                    {
                        KeyType   = typeof(Key1),
                        ValueType = typeof(Value1)
                    }
                }
            };

            var cache = Ignition.GetIgnite("0").CreateCache <Key1, Value1>(cfg);

            foreach (var ignite in Ignition.GetAll())
            {
                // Do not use GetBinaryType which always returns something.
                // Use GetBinaryTypes to make sure that types are actually registered.
                var types     = ignite.GetBinary().GetBinaryTypes();
                var qryEntity = ignite.GetCache <object, object>(cfg.Name).GetConfiguration().QueryEntities.Single();

                var keyType = types.Single(t => t.TypeName == qryEntity.KeyTypeName);
                var valType = types.Single(t => t.TypeName == qryEntity.ValueTypeName);

                Assert.AreEqual(typeof(Key1).FullName, qryEntity.KeyTypeName);
                Assert.AreEqual(typeof(Value1).FullName, qryEntity.ValueTypeName);

                Assert.AreEqual("Bar", keyType.AffinityKeyFieldName);
                Assert.IsEmpty(keyType.Fields);

                Assert.IsNull(valType.AffinityKeyFieldName);
                Assert.IsEmpty(valType.Fields);
            }

            // Verify put/get on server and client.
            cache[new Key1 {
                      Foo = "a", Bar = 2
                  }] = new Value1 {
                Name = "x", Value = 1
            };

            using (var client = Ignition.StartClient(new IgniteClientConfiguration("localhost")))
            {
                var clientCache = client.GetCache <Key1, Value1>(cache.Name);
                var val         = clientCache.Get(new Key1 {
                    Foo = "a", Bar = 2
                });

                Assert.AreEqual("x", val.Name);
                Assert.AreEqual(1, val.Value);
            }
        }
Exemple #10
0
        public void TestClientNodeReconnectWithClusterRestartStopsPlatformCache()
        {
            InitNodes(1);
            var clientCache = InitClientAndCache();
            var client      = Ignition.GetAll().Single(c => c.GetConfiguration().ClientMode);

            var keys = Enumerable.Range(1, 100).ToList();

            keys.ForEach(k => clientCache[k] = new Foo(k));
            Assert.AreEqual(keys.Count, clientCache.GetLocalSize(CachePeekMode.Platform));
            Assert.IsNotNull(clientCache.GetConfiguration().NearConfiguration);

            // Stop the only server node, client goes into disconnected mode.
            var evt = new ManualResetEventSlim(false);

            client.ClientDisconnected += (sender, args) => evt.Set();

            StopNode(0);
            Assert.IsTrue(evt.Wait(TimeSpan.FromSeconds(10)), "ClientDisconnected event should be fired");

            var reconnectTask = client.GetCluster().ClientReconnectTask;

            // Start server again, client reconnects.
            InitNodes(1);
            Assert.IsTrue(reconnectTask.Wait(TimeSpan.FromSeconds(10)));

            // Platform cache is empty.
            Assert.AreEqual(0, clientCache.GetLocalSize(CachePeekMode.Platform));
            Assert.IsEmpty(clientCache.GetLocalEntries(CachePeekMode.Platform));
            Assert.Throws <KeyNotFoundException>(() => clientCache.LocalPeek(1, CachePeekMode.Platform));

            // Cache still works for new entries, platform cache is being bypassed.
            var serverCache = _cache[0];

            serverCache[1] = new Foo(11);
            Assert.AreEqual(11, clientCache[1].Bar);

            serverCache[1] = new Foo(22);

            var foo = clientCache[1];

            Assert.AreEqual(22, foo.Bar);
            Assert.AreNotSame(foo, clientCache[1]);

            // This is a full cluster restart, so client platform cache is stopped.
            Assert.IsNull(clientCache.GetConfiguration().NearConfiguration);

            var ex = Assert.Throws <CacheException>(() =>
                                                    client.GetOrCreateNearCache <int, Foo>(clientCache.Name, new NearCacheConfiguration()));

            StringAssert.Contains("cache with the same name without near cache is already started", ex.Message);
        }
Exemple #11
0
        public void TestIisBehavior()
        {
            var ignite = Ignition.Start(GetConfig());

            var cache = ignite.CreateCache <int, int>(new CacheConfiguration
            {
                Name      = CacheName,
                CacheMode = CacheMode.Replicated  // Use Replicated to avoid data loss due to node stop.
            });

            cache[1] = 1;

            // Check same domain.
            new DomainRunner().RunTest();

            var type = typeof(DomainRunner);

            Assert.IsNotNull(type.FullName);

            // Start and stop domains.
            for (var i = 0; i < 10; i++)
            {
                var domain = CreateDomain(i);

                var runner = (DomainRunner)domain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);
                runner.RunTest();

                // Verify node start.
                var expectedNodeCount = Math.Min(i + 3, 7);
                Assert.AreEqual(expectedNodeCount, ignite.GetCluster().GetNodes().Count);

                // Current AppDomain does not see other instances.
                Assert.AreEqual(2, Ignition.GetAll().Count);

                if (i > 3)
                {
                    var oldDomain = _domains[i - 3];
                    _domains[i - 3] = null;

                    AppDomain.Unload(oldDomain);

                    // Verify node exit.
                    TestUtils.WaitForCondition(
                        () => ignite.GetCluster().GetNodes().Count == expectedNodeCount - 1, 5000);
                }
            }

            UnloadDomains();

            // Verify node exit: only two nodes from current domain should be there.
            TestUtils.WaitForCondition(() => ignite.GetCluster().GetNodes().Count == 2, 5000);
        }
        public void TestStartUniqueName()
        {
            var cfg = TestUtils.GetTestConfiguration();

            cfg.AutoGenerateIgniteInstanceName = true;

            Ignition.Start(cfg);
            Assert.IsNotNull(Ignition.GetIgnite());

            Ignition.Start(cfg);
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite());
            Assert.AreEqual(2, Ignition.GetAll().Count);
        }
        public void TestCacheStartIgniteConfigurationRegistersMetaForQueryEntityTypes()
        {
            foreach (var ignite in Ignition.GetAll())
            {
                var types     = ignite.GetBinary().GetBinaryTypes();
                var qryEntity = ignite.GetCache <object, object>(CacheName2).GetConfiguration().QueryEntities.Single();

                var keyType = types.Single(t => t.TypeName == qryEntity.KeyTypeName);

                Assert.AreEqual(typeof(Key3).FullName, qryEntity.KeyTypeName);
                Assert.AreEqual("Aff", keyType.AffinityKeyFieldName);
            }
        }
Exemple #14
0
        public void TestServicesWithCustomClusterGroupInvokeOnSpecifiedNodes()
        {
            ServerServices.DeployNodeSingleton(ServiceName, new TestService());

            foreach (var ignite in Ignition.GetAll())
            {
                var node         = ignite.GetCluster().GetLocalNode();
                var clusterGroup = Client.GetCluster().ForPredicate(n => n.Id == node.Id);
                var svc          = clusterGroup.GetServices();

                Assert.AreSame(clusterGroup, svc.ClusterGroup);
                Assert.AreEqual(node.Id, clusterGroup.GetNodes().Single().Id);

                var actualNodeId = svc.GetServiceProxy <ITestService>(ServiceName).GetNodeId();
                Assert.AreEqual(node.Id, actualNodeId);
            }
        }
Exemple #15
0
        public void TestIgniteStartsWithDefaultConfig()
        {
            var ignite = Ignition.Start(TestUtils.GetTestConfiguration());
            Assert.IsNotNull(ignite);
            Assert.AreEqual(ignite, Ignition.GetIgnite());

            // Second node.
            var ignite2 = Ignition.Start(TestUtils.GetTestConfiguration(name: "ignite-2"));
            Assert.AreEqual(2, Ignition.GetAll().Count);

            // Stop node.
            Ignition.Stop(ignite.Name, true);
            Assert.AreEqual(ignite2, Ignition.GetIgnite());

            // Stop all.
            Ignition.StopAll(true);
            Assert.AreEqual(0, Ignition.GetAll().Count);
        }
        /// <summary>
        /// Asserts client connection count.
        /// </summary>
        protected static void AssertClientConnectionCount(IIgniteClient client, int count)
        {
            var res = TestUtils.WaitForCondition(() =>
            {
                // Perform any operation to cause topology update.
                try
                {
                    client.GetCacheNames();
                }
                catch (Exception)
                {
                    // Ignore.
                }

                return(count == client.GetConnections().Count());
            }, 9000);

            if (!res)
            {
                Assert.Fail("Client connection count mismatch: expected {0}, but was {1}",
                            count, client.GetConnections().Count());
            }

            var cluster = Ignition.GetAll().First().GetCluster();

            foreach (var connection in client.GetConnections())
            {
                var server = cluster.GetNode(connection.NodeId);
                Assert.IsNotNull(server);

                var remoteEndPoint = (IPEndPoint)connection.RemoteEndPoint;
                Assert.AreEqual(server.GetAttribute <int>("clientListenerPort"), remoteEndPoint.Port);

                var ipAddresses = server.Addresses
                                  .Select(a => a.Split('%').First()) // Trim IPv6 scope.
                                  .Select(IPAddress.Parse)
                                  .ToArray();

                CollectionAssert.Contains(ipAddresses, remoteEndPoint.Address);

                var localEndPoint = (IPEndPoint)connection.LocalEndPoint;
                CollectionAssert.Contains(new[] { IPAddress.Loopback, IPAddress.IPv6Loopback }, localEndPoint.Address);
            }
        }
Exemple #17
0
        public void TestTwoServers()
        {
            var cfg1 = new IgniteConfiguration
            {
                SpringConfigUrl = @"config/start-test-grid1-ssl.xml",
                JvmOptions      = TestUtils.TestJavaOptions(),
                JvmClasspath    = TestUtils.CreateTestClasspath(),
            };

            var cfg2 = new IgniteConfiguration
            {
                SpringConfigUrl   = @"config/start-test-grid2.xml",
                JvmOptions        = TestUtils.TestJavaOptions(),
                JvmClasspath      = TestUtils.CreateTestClasspath(),
                SslContextFactory = GetSslContextFactory()
            };

            var grid1 = Ignition.Start(cfg1);

            Assert.AreEqual("grid1", grid1.Name);
            Assert.AreSame(grid1, Ignition.GetIgnite());
            Assert.AreSame(grid1, Ignition.GetAll().Single());

            var grid2 = Ignition.Start(cfg2);

            Assert.AreEqual("grid2", grid2.Name);
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite());

            Assert.AreSame(grid1, Ignition.GetIgnite("grid1"));
            Assert.AreSame(grid1, Ignition.TryGetIgnite("grid1"));

            Assert.AreSame(grid2, Ignition.GetIgnite("grid2"));
            Assert.AreSame(grid2, Ignition.TryGetIgnite("grid2"));

            Assert.AreEqual(new[] { grid1, grid2 }, Ignition.GetAll().OrderBy(x => x.Name).ToArray());

            Assert.AreEqual(2, grid1.GetCluster().GetNodes().Count);
            Assert.AreEqual(2, grid2.GetCluster().GetNodes().Count);

            Ignition.StopAll(true);
        }
Exemple #18
0
        public void TestBackupFilterPlacesBackupsToDifferentRacks()
        {
            var ign = Ignition.GetAll().First();

            var cacheCfg1 = new CacheConfiguration("c1")
            {
                Backups = 1
            };

            var cacheCfg2 = new CacheConfiguration("c2")
            {
                Backups          = 1,
                AffinityFunction = new RendezvousAffinityFunction
                {
                    Partitions           = 12,
                    AffinityBackupFilter = new ClusterNodeAttributeAffinityBackupFilter
                    {
                        AttributeNames = new[] { Rack }
                    }
                }
            };

            var cache1 = ign.CreateCache <int, int>(cacheCfg1);
            var cache2 = ign.CreateCache <int, int>(cacheCfg2);

            var aff  = ign.GetAffinity(cache1.Name);
            var aff2 = ign.GetAffinity(cache2.Name);

            var placement1 = GetPlacementString(aff.MapPartitionToPrimaryAndBackups(1));
            var placement2 = GetPlacementString(aff2.MapPartitionToPrimaryAndBackups(1));

            Assert.AreEqual(
                "Primary: Node 1 in Rack 0, Backup: Node 0 in Rack 0",
                placement1,
                "Without backup filter both backups are in the same rack.");

            Assert.AreEqual(
                "Primary: Node 1 in Rack 0, Backup: Node 2 in Rack 1",
                placement2,
                "With backup filter backups are in different racks.");
        }
        public void TestCacheStartFromSpringRegistersMetaForQueryEntityTypes()
        {
            foreach (var ignite in Ignition.GetAll())
            {
                // Do not use GetBinaryType which always returns something.
                // Use GetBinaryTypes to make sure that types are actually registered.
                var types     = ignite.GetBinary().GetBinaryTypes();
                var qryEntity = ignite.GetCache <object, object>(CacheName).GetConfiguration().QueryEntities.Single();

                var keyType = types.Single(t => t.TypeName == qryEntity.KeyTypeName);
                var valType = types.Single(t => t.TypeName == qryEntity.ValueTypeName);

                Assert.AreEqual(typeof(Key2).FullName, qryEntity.KeyTypeName);
                Assert.AreEqual(typeof(Value2).FullName, qryEntity.ValueTypeName);

                Assert.AreEqual("AffKey", keyType.AffinityKeyFieldName);
                Assert.IsEmpty(keyType.Fields);

                Assert.IsNull(valType.AffinityKeyFieldName);
                Assert.IsEmpty(valType.Fields);
            }
        }
        private int GetPrimaryNodeIdx <T>(T key)
        {
            var idx = 0;

            // GetAll is not ordered - sort the same way as _loggers.
            var ignites = Ignition.GetAll().OrderBy(i => i.Name);

            foreach (var ignite in ignites)
            {
                var aff       = ignite.GetAffinity(_cache.Name);
                var localNode = ignite.GetCluster().GetLocalNode();

                if (aff.IsPrimary(localNode, key))
                {
                    return(idx);
                }

                idx++;
            }

            throw new InvalidOperationException("Can't determine primary node");
        }
Exemple #21
0
        public void TestPartitionAwarenessRoutesRequestsToNewlyJoinedNodes()
        {
            if (GetType() == typeof(ClientClusterDiscoveryTestsBaselineTopology))
            {
                // Fixed baseline means that rebalance to a new node won't happen.
                return;
            }

            var ignite = Ignition.GetAll().First();
            var cache  = ignite.CreateCache <int, int>("c");

            using (var ignite2 = Ignition.Start(GetIgniteConfiguration()))
            {
                var client = GetClient();
                AssertClientConnectionCount(client, 4);

                var clientCache = client.GetCache <int, int>(cache.Name);
                var logger      = (ListLogger)ignite2.Logger;
                var aff         = ignite2.GetAffinity(cache.Name);
                var localNode   = ignite2.GetCluster().GetLocalNode();

                TestUtils.WaitForTrueCondition(() => aff.GetAllPartitions(localNode).Length > 0, 5000);

                var key = TestUtils.GetPrimaryKey(ignite2, cache.Name);

                TestUtils.WaitForTrueCondition(() =>
                {
                    clientCache.Put(key, key);

                    var log = logger.Entries.LastOrDefault(
                        e => e.Message.Contains("client.cache.ClientCachePutRequest"));

                    return(log != null);
                }, 3000);
            }
        }
Exemple #22
0
        public void TestTearDown()
        {
            ServerServices.CancelAll();

            TestUtils.AssertHandleRegistryIsEmpty(1000, Ignition.GetAll().ToArray());
        }
        public void TestStartGetStop()
        {
            var cfgs = new List <string> {
                "config\\start-test-grid1.xml", "config\\start-test-grid2.xml", "config\\start-test-grid3.xml"
            };

            var cfg = new IgniteConfiguration
            {
                SpringConfigUrl = cfgs[0],
                JvmOptions      = TestUtils.TestJavaOptions(),
                JvmClasspath    = TestUtils.CreateTestClasspath()
            };

            var grid1 = Ignition.Start(cfg);

            Assert.AreEqual("grid1", grid1.Name);
            Assert.AreSame(grid1, Ignition.GetIgnite());
            Assert.AreSame(grid1, Ignition.GetAll().Single());

            cfg.SpringConfigUrl = cfgs[1];

            var grid2 = Ignition.Start(cfg);

            Assert.AreEqual("grid2", grid2.Name);
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite());

            cfg.SpringConfigUrl = cfgs[2];

            var grid3 = Ignition.Start(cfg);

            Assert.IsNull(grid3.Name);

            Assert.AreSame(grid1, Ignition.GetIgnite("grid1"));
            Assert.AreSame(grid1, Ignition.TryGetIgnite("grid1"));

            Assert.AreSame(grid2, Ignition.GetIgnite("grid2"));
            Assert.AreSame(grid2, Ignition.TryGetIgnite("grid2"));

            Assert.AreSame(grid3, Ignition.GetIgnite(null));
            Assert.AreSame(grid3, Ignition.GetIgnite());
            Assert.AreSame(grid3, Ignition.TryGetIgnite(null));
            Assert.AreSame(grid3, Ignition.TryGetIgnite());

            Assert.AreEqual(new[] { grid3, grid1, grid2 }, Ignition.GetAll().OrderBy(x => x.Name).ToArray());

            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("invalid_name"));
            Assert.IsNull(Ignition.TryGetIgnite("invalid_name"));


            Assert.IsTrue(Ignition.Stop("grid1", true));
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("grid1"));

            grid2.Dispose();
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("grid2"));

            grid3.Dispose();
            Assert.Throws <IgniteException>(() => Ignition.GetIgnite("grid3"));

            foreach (var cfgName in cfgs)
            {
                cfg.SpringConfigUrl = cfgName;
                cfg.JvmOptions      = TestUtils.TestJavaOptions();

                Ignition.Start(cfg);
            }

            foreach (var gridName in new List <string> {
                "grid1", "grid2", null
            })
            {
                Assert.IsNotNull(Ignition.GetIgnite(gridName));
            }

            Ignition.StopAll(true);

            foreach (var gridName in new List <string> {
                "grid1", "grid2", null
            })
            {
                Assert.Throws <IgniteException>(() => Ignition.GetIgnite(gridName));
            }
        }
Exemple #24
0
 /// <summary>
 /// Gets the cache.
 /// </summary>
 protected static ICache <int, T> GetCache <T>()
 {
     return(Ignition.GetAll().First().GetOrCreateCache <int, T>(CacheName));
 }