当前位置: 首页>>代码示例>>C#>>正文


C# IgniteConfiguration类代码示例

本文整理汇总了C#中IgniteConfiguration的典型用法代码示例。如果您正苦于以下问题:C# IgniteConfiguration类的具体用法?C# IgniteConfiguration怎么用?C# IgniteConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IgniteConfiguration类属于命名空间,在下文中一共展示了IgniteConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestIgniteStartup

        public void TestIgniteStartup()
        {
            var memoryLog = CreateMemoryLogger();
            var logger = new IgniteLog4NetLogger();

            var cfg = new IgniteConfiguration
            {
                DiscoverySpi = TestUtil.GetLocalDiscoverySpi(),
                Logger = logger
            };

            Func<IEnumerable<string>> getLogs = () => memoryLog.GetEvents().Select(x => x.MessageObject.ToString());

            using (var ignite = Ignition.Start(cfg))
            {
                Assert.IsTrue(getLogs().Contains(
                    string.Format("Starting Ignite.NET {0}", typeof(Ignition).Assembly.GetName().Version)));

                Assert.IsTrue(getLogs().Any(x => x.Contains(">>> Topology snapshot.")));

                Assert.IsInstanceOf<IgniteLog4NetLogger>(ignite.Logger);

                ignite.Logger.Info("Log from user code.");

                Assert.IsTrue(getLogs().Contains("Log from user code."));
            }

            Assert.IsTrue(getLogs().Contains("Grid is stopping."));
        }
开发者ID:juanavelez,项目名称:ignite,代码行数:29,代码来源:Log4NetTest.cs

示例2: TestNoCacheNode

        public void TestNoCacheNode()
        {
            const string cacheName = "cache";

            var cacheNodeCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                SpringConfigUrl = @"Config\cache-local-node.xml",
                GridName = "cacheGrid"
            };

            using (var gridNoCache = Ignition.Start(TestUtils.GetTestConfiguration()))
            {
                Assert.Throws<ArgumentException>(() => gridNoCache.GetCache<int, int>(cacheName));

                var gridWithCache = Ignition.Start(cacheNodeCfg);

                var streamer = gridNoCache.GetDataStreamer<int, int>(cacheName);

                streamer.AddData(1, 2);
                streamer.Flush();

                Ignition.Stop(gridWithCache.Name, true);

                Thread.Sleep(500);  // Wait for node to stop

                var task = streamer.AddData(2, 3);
                streamer.Flush();

                AssertThrowsCacheStopped(task);
            }
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:31,代码来源:DataStreamerTestTopologyChange.cs

示例3: CreateJvmContext

        /// <summary>
        /// Create JVM.
        /// </summary>
        /// <param name="cfg">Configuration.</param>
        /// <param name="cbs">Callbacks.</param>
        /// <returns>Context.</returns>
        internal static void CreateJvmContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs)
        {
            lock (SyncRoot)
            {
                // 1. Warn about possible configuration inconsistency.
                JvmConfiguration jvmCfg = JvmConfig(cfg);

                if (!cfg.SuppressWarnings && _jvmCfg != null)
                {
                    if (!_jvmCfg.Equals(jvmCfg))
                    {
                        Console.WriteLine("Attempting to start Ignite node with different Java " +
                            "configuration; current Java configuration will be ignored (consider " +
                            "starting node in separate process) [oldConfig=" + _jvmCfg +
                            ", newConfig=" + jvmCfg + ']');
                    }
                }

                // 2. Create unmanaged pointer.
                void* ctx = CreateJvm(cfg, cbs);

                cbs.SetContext(ctx);

                // 3. If this is the first JVM created, preserve it.
                if (_ctx == null)
                {
                    _ctx = ctx;
                    _jvmCfg = jvmCfg;
                }
            }
        }
开发者ID:dkarachentsev,项目名称:ignite,代码行数:37,代码来源:IgniteManager.cs

示例4: Serialize

        /// <summary>
        /// Serializes specified <see cref="IgniteConfiguration" /> to <see cref="XmlWriter" />.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <param name="writer">The writer.</param>
        /// <param name="rootElementName">Name of the root element.</param>
        public static void Serialize(IgniteConfiguration configuration, XmlWriter writer, string rootElementName)
        {
            IgniteArgumentCheck.NotNull(configuration, "configuration");
            IgniteArgumentCheck.NotNull(writer, "writer");
            IgniteArgumentCheck.NotNullOrEmpty(rootElementName, "rootElementName");

            WriteElement(configuration, writer, rootElementName, typeof(IgniteConfiguration));
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:14,代码来源:IgniteConfigurationXmlSerializer.cs

示例5: TestStartDefault

        public void TestStartDefault()
        {
            var cfg = new IgniteConfiguration {JvmClasspath = TestUtils.CreateTestClasspath()};

            var grid = Ignition.Start(cfg);

            Assert.IsNotNull(grid);

            Assert.AreEqual(1, grid.Cluster.Nodes().Count);
        }
开发者ID:timefree,项目名称:ignite,代码行数:10,代码来源:IgniteStartStopTest.cs

示例6: FixtureSetUp

        public void FixtureSetUp()
        {
            var cfg = new IgniteConfiguration
            {
                DiscoverySpi = TestUtil.GetLocalDiscoverySpi(),
                CacheConfiguration = new [] {new CacheConfiguration("aspNetCache") }
            };

            Ignition.Start(cfg);
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:10,代码来源:AspNetTest.cs

示例7: FixtureSetUp

        public void FixtureSetUp()
        {
            var cfg = new IgniteConfiguration
            {
                DiscoverySpi = TestUtil.GetLocalDiscoverySpi(),
                BinaryConfiguration = new BinaryConfiguration(typeof(Person))
            };

            Ignition.Start(cfg);
        }
开发者ID:dkarachentsev,项目名称:ignite,代码行数:10,代码来源:CacheTest.cs

示例8: TestAllConfigurationProperties

        public void TestAllConfigurationProperties()
        {
            var cfg = new IgniteConfiguration(GetCustomConfig());

            using (var ignite = Ignition.Start(cfg))
            {
                var resCfg = ignite.GetConfiguration();

                var disco = (TcpDiscoverySpi) cfg.DiscoverySpi;
                var resDisco = (TcpDiscoverySpi) resCfg.DiscoverySpi;

                Assert.AreEqual(disco.NetworkTimeout, resDisco.NetworkTimeout);
                Assert.AreEqual(disco.AckTimeout, resDisco.AckTimeout);
                Assert.AreEqual(disco.MaxAckTimeout, resDisco.MaxAckTimeout);
                Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout);
                Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout);

                var ip = (TcpDiscoveryStaticIpFinder) disco.IpFinder;
                var resIp = (TcpDiscoveryStaticIpFinder) resDisco.IpFinder;

                // There can be extra IPv6 endpoints
                Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray());

                Assert.AreEqual(cfg.GridName, resCfg.GridName);
                Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes);
                Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime);
                Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize);
                Assert.AreEqual(cfg.MetricsLogFrequency, resCfg.MetricsLogFrequency);
                Assert.AreEqual(cfg.MetricsUpdateFrequency, resCfg.MetricsUpdateFrequency);
                Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount);
                Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout);
                Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay);
                Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory);
                Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath);
                Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions);
                Assert.IsTrue(File.Exists(resCfg.JvmDllPath));
                Assert.AreEqual(cfg.Localhost, resCfg.Localhost);
                Assert.AreEqual(cfg.IsDaemon, resCfg.IsDaemon);
                Assert.AreEqual(cfg.UserAttributes, resCfg.UserAttributes);

                var atm = cfg.AtomicConfiguration;
                var resAtm = resCfg.AtomicConfiguration;
                Assert.AreEqual(atm.AtomicSequenceReserveSize, resAtm.AtomicSequenceReserveSize);
                Assert.AreEqual(atm.Backups, resAtm.Backups);
                Assert.AreEqual(atm.CacheMode, resAtm.CacheMode);

                var tx = cfg.TransactionConfiguration;
                var resTx = resCfg.TransactionConfiguration;
                Assert.AreEqual(tx.DefaultTimeout, resTx.DefaultTimeout);
                Assert.AreEqual(tx.DefaultTransactionConcurrency, resTx.DefaultTransactionConcurrency);
                Assert.AreEqual(tx.DefaultTransactionIsolation, resTx.DefaultTransactionIsolation);
                Assert.AreEqual(tx.PessimisticTransactionLogLinger, resTx.PessimisticTransactionLogLinger);
                Assert.AreEqual(tx.PessimisticTransactionLogSize, resTx.PessimisticTransactionLogSize);
            }
        }
开发者ID:DoudTechData,项目名称:ignite,代码行数:55,代码来源:IgniteConfigurationTest.cs

示例9: TestSetUp

        /** <inheritdoc /> */
        public override void TestSetUp()
        {
            base.TestSetUp();

            // Start another node without spring config
            if (Ignition.TryGetIgnite("grid2") == null)
            {
                var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) {GridName = "grid2"};
                _ignite = Ignition.Start(cfg);
            }
        }
开发者ID:f7753,项目名称:ignite,代码行数:12,代码来源:AffinityFunctionSpringTest.cs

示例10: Deserialize

        /// <summary>
        /// Deserializes <see cref="IgniteConfiguration"/> from specified <see cref="XmlReader"/>.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns>Resulting <see cref="IgniteConfiguration"/>.</returns>
        public static IgniteConfiguration Deserialize(XmlReader reader)
        {
            IgniteArgumentCheck.NotNull(reader, "reader");

            var cfg = new IgniteConfiguration();

            if (reader.NodeType == XmlNodeType.Element || reader.Read())
                ReadElement(reader, cfg);

            return cfg;
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:16,代码来源:IgniteConfigurationXmlSerializer.cs

示例11: TestDisconnectedException

        public void TestDisconnectedException()
        {
            var cfg = new IgniteConfiguration
            {
                SpringConfigUrl = "config\\reconnect-test.xml",
                JvmClasspath = TestUtils.CreateTestClasspath(),
                JvmOptions = TestUtils.TestJavaOptions()
            };

            var proc = StartServerProcess(cfg);

            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>("c");

                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;

                var clientReconnectTask = inner.ClientReconnectTask;

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

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

                clientReconnectTask.Wait();

                Assert.AreEqual(1, cache[1]);
                Assert.AreEqual(1, disconnected);
                Assert.AreEqual(1, reconnected);
            }
        }
开发者ID:kjniemi,项目名称:ignite,代码行数:53,代码来源:ReconnectTest.cs

示例12: TestClusterRestart

        public void TestClusterRestart()
        {
            var serverCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                CacheConfiguration = new[] {new CacheConfiguration(CacheName)}
            };

            var clientCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                GridName = "client",
                ClientMode = true
            };

            var server = Ignition.Start(serverCfg);
            var client = Ignition.Start(clientCfg);

            ClientReconnectEventArgs eventArgs = null;

            client.ClientReconnected += (sender, args) => { eventArgs = args; };

            var cache = client.GetCache<int, int>(CacheName);

            cache[1] = 1;

            Ignition.Stop(server.Name, true);

            var cacheEx = Assert.Throws<CacheException>(() => cache.Get(1));
            var ex = cacheEx.InnerException as ClientDisconnectedException;

            Assert.IsNotNull(ex);

            // Start the server and wait for reconnect.
            Ignition.Start(serverCfg);
            Assert.IsTrue(ex.ClientReconnectTask.Result);

            // Check the event args.
            Thread.Sleep(1);  // Wait for event handler

            Assert.IsNotNull(eventArgs);
            Assert.IsTrue(eventArgs.HasClusterRestarted);

            // Refresh the cache instance and check that it works.
            var cache1 = client.GetCache<int, int>(CacheName);
            Assert.AreEqual(0, cache1.GetSize());

            cache1[1] = 2;
            Assert.AreEqual(2, cache1[1]);

            // Check that old cache instance does not work.
            var cacheEx1 = Assert.Throws<InvalidOperationException>(() => cache.Get(1));
            Assert.AreEqual("Cache has been closed or destroyed: " + CacheName, cacheEx1.Message);
        }
开发者ID:vladisav,项目名称:ignite,代码行数:52,代码来源:ReconnectTest.cs

示例13: TestStartWithConfigPath

        public void TestStartWithConfigPath()
        {
            var cfg = new IgniteConfiguration
            {
                SpringConfigUrl = "config/default-config.xml",
                JvmClasspath = TestUtils.CreateTestClasspath()
            };

            var grid = Ignition.Start(cfg);

            Assert.IsNotNull(grid);

            Assert.AreEqual(1, grid.Cluster.Nodes().Count);
        }
开发者ID:timefree,项目名称:ignite,代码行数:14,代码来源:IgniteStartStopTest.cs

示例14: TestDisabledSwapSpace

        public void TestDisabledSwapSpace()
        {
            var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration());

            using (var ignite = Ignition.Start(cfg))
            {
                // NoopSwapSpaceSpi is used by default.
                Assert.IsNull(ignite.GetConfiguration().SwapSpaceSpi);

                var ex = Assert.Throws<CacheException>(
                    () => ignite.CreateCache<int, int>(new CacheConfiguration {EnableSwap = true}));

                Assert.IsTrue(ex.Message.EndsWith("has not swap SPI configured"));
            }
        }
开发者ID:vladisav,项目名称:ignite,代码行数:15,代码来源:CacheSwapSpaceTest.cs

示例15: Resolve

        /// <summary>
        /// Calculate Ignite home.
        /// </summary>
        /// <param name="cfg">Configuration.</param>
        /// <returns></returns>
        public static string Resolve(IgniteConfiguration cfg)
        {
            var home = cfg == null ? null : cfg.IgniteHome;

            if (string.IsNullOrWhiteSpace(home))
                home = Environment.GetEnvironmentVariable(EnvIgniteHome);
            else if (!IsIgniteHome(new DirectoryInfo(home)))
                throw new IgniteException(string.Format("IgniteConfiguration.IgniteHome is not valid: '{0}'", home));

            if (string.IsNullOrWhiteSpace(home))
                home = Resolve();
            else if (!IsIgniteHome(new DirectoryInfo(home)))
                throw new IgniteException(string.Format("{0} is not valid: '{1}'", EnvIgniteHome, home));

            return home;
        }
开发者ID:RazmikMkrtchyan,项目名称:ignite,代码行数:21,代码来源:IgniteHome.cs


注:本文中的IgniteConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。