public void TestInvalidTimeouts() { var cfg = new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { AckTimeout = TimeSpan.FromMilliseconds(-5), JoinTimeout = TimeSpan.MinValue, }, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), }; Assert.Throws <IgniteException>(() => Ignition.Start(cfg)); }
/// <summary> /// Start grid. /// </summary> /// <param name="cfgPath">Spring configuration path.</param> /// <returns>Grid.</returns> private static IIgnite Start(string cfgPath) { TestUtils.JvmDebug = true; IgniteConfiguration cfg = new IgniteConfiguration(); cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = cfgPath; cfg.LifecycleHandlers = new List <ILifecycleHandler> { new Bean(), new Bean() }; return(Ignition.Start(cfg)); }
/// <summary> /// Gets the Ignite configuration. /// </summary> private static IgniteConfiguration Configuration(string springConfigUrl) { return(new IgniteConfiguration { SpringConfigUrl = springConfigUrl, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), BinaryConfiguration = new BinaryConfiguration { TypeConfigurations = new List <BinaryTypeConfiguration> { new BinaryTypeConfiguration(typeof(RemoteEventBinarizableFilter)) } } }); }
/// <summary> /// Gets the custom configuration. /// </summary> private static IgniteConfiguration GetCustomConfig() { return(new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { NetworkTimeout = TimeSpan.FromSeconds(1), AckTimeout = TimeSpan.FromSeconds(2), MaxAckTimeout = TimeSpan.FromSeconds(3), SocketTimeout = TimeSpan.FromSeconds(4), JoinTimeout = TimeSpan.FromSeconds(5), IpFinder = new TcpDiscoveryStaticIpFinder { Endpoints = new[] { "127.0.0.1:47500", "127.0.0.1:47501" } } }, GridName = "gridName1", IncludedEventTypes = EventType.SwapspaceAll, MetricsExpireTime = TimeSpan.FromMinutes(7), MetricsHistorySize = 125, MetricsLogFrequency = TimeSpan.FromMinutes(8), MetricsUpdateFrequency = TimeSpan.FromMinutes(9), NetworkSendRetryCount = 54, NetworkTimeout = TimeSpan.FromMinutes(10), NetworkSendRetryDelay = TimeSpan.FromMinutes(11), WorkDirectory = Path.GetTempPath(), JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath(), Localhost = "127.0.0.1", IsDaemon = true, UserAttributes = Enumerable.Range(1, 10).ToDictionary(x => x.ToString(), x => (object)x), AtomicConfiguration = new AtomicConfiguration { CacheMode = CacheMode.Replicated, Backups = 2, AtomicSequenceReserveSize = 200 }, TransactionConfiguration = new TransactionConfiguration { DefaultTransactionConcurrency = TransactionConcurrency.Optimistic, DefaultTimeout = TimeSpan.FromSeconds(25), DefaultTransactionIsolation = TransactionIsolation.Serializable, PessimisticTransactionLogLinger = TimeSpan.FromHours(1), PessimisticTransactionLogSize = 240 } }); }
public void TestProcessorInit() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid1.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath() }; // Start local node var grid = Ignition.Start(cfg); // Start remote node in a separate process // ReSharper disable once UnusedVariable var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + Path.GetFullPath(cfg.SpringConfigUrl), "-J-Xms512m", "-J-Xmx512m"); var cts = new CancellationTokenSource(); var token = cts.Token; // Spam message subscriptions on a separate thread // to test race conditions during processor init on remote node var listenTask = Task.Factory.StartNew(() => { var filter = new MessageListener(); while (!token.IsCancellationRequested) { var listenId = grid.GetMessaging().RemoteListen(filter); grid.GetMessaging().StopRemoteListen(listenId); } // ReSharper disable once FunctionNeverReturns }); // Wait for remote node to join Assert.IsTrue(grid.WaitTopology(2)); // Wait some more for initialization Thread.Sleep(1000); // Cancel listen task and check that it finishes cts.Cancel(); Assert.IsTrue(listenTask.Wait(5000)); }
/// <summary> /// Starts the grid. /// </summary> private static IIgnite StartGrid(string gridName = null) { return(Ignition.Start(new IgniteConfiguration { SpringConfigUrl = "config\\native-client-test-cache.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath(), GridName = gridName, BinaryConfiguration = new BinaryConfiguration { TypeConfigurations = new[] { new BinaryTypeConfiguration(typeof(BinarizableEntry)) } } })); }
public void TestDisconnectedException() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\compute\\compute-grid1.xml", JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions() }; var proc = StartServerProcess(cfg); Ignition.ClientMode = true; using (var ignite = Ignition.Start(cfg)) { Assert.IsTrue(ignite.GetCluster().ClientReconnectTask.IsCompleted); var cache = ignite.GetCache <int, int>(null); cache[1] = 1; // Suspend external process to cause disconnect proc.Suspend(); var ex = Assert.Throws <CacheException>(() => cache.Get(1)); var inner = (ClientDisconnectedException)ex.InnerException; var clientReconnectTask = inner.ClientReconnectTask; Assert.AreEqual(ignite.GetCluster().ClientReconnectTask, clientReconnectTask); // Resume process to reconnect proc.Resume(); clientReconnectTask.Wait(); Assert.AreEqual(1, cache[1]); } }
public void TestFixtureSetUp() { TestUtils.KillProcesses(); var grid = Ignition.Start(new IgniteConfiguration { SpringConfigUrl = "config\\compute\\compute-standalone.xml", JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), BinaryConfiguration = new BinaryConfiguration { TypeConfigurations = new List <BinaryTypeConfiguration> { new BinaryTypeConfiguration(typeof(Binarizable)) } } }); _cache = grid.GetCache <object, object>(null); _compute = grid.GetCompute(); }
public void TestClientMode() { var servCfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid1.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath() }; var clientCfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid2.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath() }; try { using (var serv = Ignition.Start(servCfg)) // start server-mode ignite first { Assert.IsFalse(serv.GetCluster().GetLocalNode().IsClient); Ignition.ClientMode = true; using (var grid = Ignition.Start(clientCfg)) { Assert.IsTrue(grid.GetCluster().GetLocalNode().IsClient); UseIgnite(grid); } } } finally { Ignition.ClientMode = false; } }
public void TestStartTheSameName() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid1.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath() }; var grid1 = Ignition.Start(cfg); Assert.AreEqual("grid1", grid1.Name); try { Ignition.Start(cfg); Assert.Fail("Start should fail."); } catch (IgniteException e) { Console.WriteLine("Expected exception: " + e); } }
/// <summary> /// Gets the custom configuration. /// </summary> private static IgniteConfiguration GetCustomConfig() { // CacheConfiguration is not tested here - see CacheConfigurationTest return(new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { NetworkTimeout = TimeSpan.FromSeconds(1), AckTimeout = TimeSpan.FromSeconds(2), MaxAckTimeout = TimeSpan.FromSeconds(3), SocketTimeout = TimeSpan.FromSeconds(4), JoinTimeout = TimeSpan.FromSeconds(5), IpFinder = new TcpDiscoveryStaticIpFinder { Endpoints = new[] { "127.0.0.1:49900", "127.0.0.1:49901" } }, ClientReconnectDisabled = true, ForceServerMode = true, IpFinderCleanFrequency = TimeSpan.FromMinutes(7), LocalAddress = "127.0.0.1", LocalPort = 49900, LocalPortRange = 13, ReconnectCount = 11, StatisticsPrintFrequency = TimeSpan.FromSeconds(20), ThreadPriority = 6, TopologyHistorySize = 1234567 }, IgniteInstanceName = "gridName1", IncludedEventTypes = EventType.DiscoveryAll, MetricsExpireTime = TimeSpan.FromMinutes(7), MetricsHistorySize = 125, MetricsLogFrequency = TimeSpan.FromMinutes(8), MetricsUpdateFrequency = TimeSpan.FromMinutes(9), NetworkSendRetryCount = 54, NetworkTimeout = TimeSpan.FromMinutes(10), NetworkSendRetryDelay = TimeSpan.FromMinutes(11), WorkDirectory = Path.GetTempPath(), JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath(), Localhost = "127.0.0.1", IsDaemon = false, IsLateAffinityAssignment = false, UserAttributes = Enumerable.Range(1, 10).ToDictionary(x => x.ToString(), x => (object)x), AtomicConfiguration = new AtomicConfiguration { CacheMode = CacheMode.Replicated, Backups = 2, AtomicSequenceReserveSize = 200 }, TransactionConfiguration = new TransactionConfiguration { DefaultTransactionConcurrency = TransactionConcurrency.Optimistic, DefaultTimeout = TimeSpan.FromSeconds(25), DefaultTransactionIsolation = TransactionIsolation.Serializable, PessimisticTransactionLogLinger = TimeSpan.FromHours(1), PessimisticTransactionLogSize = 240 }, CommunicationSpi = new TcpCommunicationSpi { LocalPort = 47501, MaxConnectTimeout = TimeSpan.FromSeconds(34), MessageQueueLimit = 15, ConnectTimeout = TimeSpan.FromSeconds(17), IdleConnectionTimeout = TimeSpan.FromSeconds(19), SelectorsCount = 8, ReconnectCount = 33, SocketReceiveBufferSize = 512, AckSendThreshold = 99, DirectBuffer = false, DirectSendBuffer = true, LocalPortRange = 45, LocalAddress = "127.0.0.1", TcpNoDelay = false, SlowClientQueueLimit = 98, SocketSendBufferSize = 2045, UnacknowledgedMessagesBufferSize = 3450 }, FailureDetectionTimeout = TimeSpan.FromSeconds(3.5), ClientFailureDetectionTimeout = TimeSpan.FromMinutes(12.3), LongQueryWarningTimeout = TimeSpan.FromMinutes(1.23), BinaryConfiguration = new BinaryConfiguration { CompactFooter = false, TypeConfigurations = new[] { new BinaryTypeConfiguration { TypeName = "myType", IsEnum = true, AffinityKeyFieldName = "affKey", KeepDeserialized = false } } }, PluginConfigurations = new[] { new TestIgnitePluginConfiguration() }, EventStorageSpi = new MemoryEventStorageSpi { ExpirationTimeout = TimeSpan.FromSeconds(5), MaxEventCount = 10 }, MemoryConfiguration = new MemoryConfiguration { ConcurrencyLevel = 3, DefaultMemoryPolicyName = "myDefaultPlc", PageSize = 2048, SystemCacheInitialSize = 13 * 1024 * 1024, SystemCacheMaxSize = 15 * 1024 * 1024, MemoryPolicies = new[] { new MemoryPolicyConfiguration { Name = "myDefaultPlc", PageEvictionMode = DataPageEvictionMode.Random2Lru, InitialSize = 340 * 1024 * 1024, MaxSize = 345 * 1024 * 1024, EvictionThreshold = 0.88, EmptyPagesPoolSize = 77, SwapFilePath = "myPath1", RateTimeInterval = TimeSpan.FromSeconds(35), SubIntervals = 7 }, new MemoryPolicyConfiguration { Name = "customPlc", PageEvictionMode = DataPageEvictionMode.RandomLru, MaxSize = 456 * 1024 * 1024, EvictionThreshold = 0.77, EmptyPagesPoolSize = 66, SwapFilePath = "somePath2", MetricsEnabled = true } } }, PublicThreadPoolSize = 3, StripedThreadPoolSize = 5, ServiceThreadPoolSize = 6, SystemThreadPoolSize = 7, AsyncCallbackThreadPoolSize = 8, ManagementThreadPoolSize = 9, DataStreamerThreadPoolSize = 10, UtilityCacheThreadPoolSize = 11, QueryThreadPoolSize = 12, SqlConnectorConfiguration = new SqlConnectorConfiguration { Host = "127.0.0.2", Port = 1081, PortRange = 3, SocketReceiveBufferSize = 2048, MaxOpenCursorsPerConnection = 5, ThreadPoolSize = 4, TcpNoDelay = false, SocketSendBufferSize = 4096 } }); }
/// <summary> /// Gets the custom configuration. /// </summary> private static IgniteConfiguration GetCustomConfig() { // CacheConfiguration is not tested here - see CacheConfigurationTest return(new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { NetworkTimeout = TimeSpan.FromSeconds(1), AckTimeout = TimeSpan.FromSeconds(2), MaxAckTimeout = TimeSpan.FromSeconds(3), SocketTimeout = TimeSpan.FromSeconds(4), JoinTimeout = TimeSpan.FromSeconds(5), IpFinder = new TcpDiscoveryStaticIpFinder { Endpoints = new[] { "127.0.0.1:49900", "127.0.0.1:49901" } }, ClientReconnectDisabled = true, ForceServerMode = true, IpFinderCleanFrequency = TimeSpan.FromMinutes(7), LocalAddress = "127.0.0.1", LocalPort = 49900, LocalPortRange = 13, ReconnectCount = 11, StatisticsPrintFrequency = TimeSpan.FromSeconds(20), ThreadPriority = 6, TopologyHistorySize = 1234567 }, IgniteInstanceName = "gridName1", IgniteHome = IgniteHome.Resolve(null), IncludedEventTypes = EventType.DiscoveryAll, MetricsExpireTime = TimeSpan.FromMinutes(7), MetricsHistorySize = 125, MetricsLogFrequency = TimeSpan.FromMinutes(8), MetricsUpdateFrequency = TimeSpan.FromMinutes(9), NetworkSendRetryCount = 54, NetworkTimeout = TimeSpan.FromMinutes(10), NetworkSendRetryDelay = TimeSpan.FromMinutes(11), WorkDirectory = Path.GetTempPath(), JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath(), Localhost = "127.0.0.1", IsDaemon = false, IsLateAffinityAssignment = false, UserAttributes = Enumerable.Range(1, 10).ToDictionary(x => x.ToString(), x => (object)x), AtomicConfiguration = new AtomicConfiguration { CacheMode = CacheMode.Replicated, Backups = 2, AtomicSequenceReserveSize = 200 }, TransactionConfiguration = new TransactionConfiguration { DefaultTransactionConcurrency = TransactionConcurrency.Optimistic, DefaultTimeout = TimeSpan.FromSeconds(25), DefaultTransactionIsolation = TransactionIsolation.Serializable, PessimisticTransactionLogLinger = TimeSpan.FromHours(1), PessimisticTransactionLogSize = 240 }, CommunicationSpi = new TcpCommunicationSpi { LocalPort = 47501, MaxConnectTimeout = TimeSpan.FromSeconds(34), MessageQueueLimit = 15, ConnectTimeout = TimeSpan.FromSeconds(17), IdleConnectionTimeout = TimeSpan.FromSeconds(19), SelectorsCount = 8, ReconnectCount = 33, SocketReceiveBufferSize = 512, AckSendThreshold = 99, DirectBuffer = false, DirectSendBuffer = true, LocalPortRange = 45, LocalAddress = "127.0.0.1", TcpNoDelay = false, SlowClientQueueLimit = 98, SocketSendBufferSize = 2045, UnacknowledgedMessagesBufferSize = 3450 }, FailureDetectionTimeout = TimeSpan.FromSeconds(3.5), ClientFailureDetectionTimeout = TimeSpan.FromMinutes(12.3), LongQueryWarningTimeout = TimeSpan.FromMinutes(1.23), IsActiveOnStart = true, BinaryConfiguration = new BinaryConfiguration { CompactFooter = false, TypeConfigurations = new[] { new BinaryTypeConfiguration { TypeName = "myType", IsEnum = true, AffinityKeyFieldName = "affKey", KeepDeserialized = false } } }, // Skip cache check because with persistence the grid is not active by default. PluginConfigurations = new[] { new TestIgnitePluginConfiguration { SkipCacheCheck = true } }, EventStorageSpi = new MemoryEventStorageSpi { ExpirationTimeout = TimeSpan.FromSeconds(5), MaxEventCount = 10 }, PublicThreadPoolSize = 3, StripedThreadPoolSize = 5, ServiceThreadPoolSize = 6, SystemThreadPoolSize = 7, AsyncCallbackThreadPoolSize = 8, ManagementThreadPoolSize = 9, DataStreamerThreadPoolSize = 10, UtilityCacheThreadPoolSize = 11, QueryThreadPoolSize = 12, SqlConnectorConfiguration = new SqlConnectorConfiguration { Host = "127.0.0.2", Port = 1081, PortRange = 3, SocketReceiveBufferSize = 2048, MaxOpenCursorsPerConnection = 5, ThreadPoolSize = 4, TcpNoDelay = false, SocketSendBufferSize = 4096 }, ConsistentId = new MyConsistentId { Data = "abc" }, DataStorageConfiguration = new DataStorageConfiguration { AlwaysWriteFullPages = true, CheckpointFrequency = TimeSpan.FromSeconds(25), CheckpointThreads = 2, LockWaitTime = TimeSpan.FromSeconds(5), StoragePath = Path.GetTempPath(), WalThreadLocalBufferSize = 64 * 1024, WalArchivePath = Path.GetTempPath(), WalFlushFrequency = TimeSpan.FromSeconds(3), WalFsyncDelayNanos = 3, WalHistorySize = 10, WalMode = Configuration.WalMode.LogOnly, WalRecordIteratorBufferSize = 32 * 1024 * 1024, WalSegments = 6, WalSegmentSize = 5 * 1024 * 1024, WalPath = Path.GetTempPath(), MetricsEnabled = true, MetricsSubIntervalCount = 7, MetricsRateTimeInterval = TimeSpan.FromSeconds(9), CheckpointWriteOrder = Configuration.CheckpointWriteOrder.Random, WriteThrottlingEnabled = true, SystemRegionInitialSize = 64 * 1024 * 1024, SystemRegionMaxSize = 128 * 1024 * 1024, ConcurrencyLevel = 1, PageSize = 8 * 1024, DefaultDataRegionConfiguration = new DataRegionConfiguration { Name = "reg1", EmptyPagesPoolSize = 50, EvictionThreshold = 0.8, InitialSize = 100 * 1024 * 1024, MaxSize = 150 * 1024 * 1024, MetricsEnabled = true, PageEvictionMode = Configuration.DataPageEvictionMode.Random2Lru, PersistenceEnabled = false, MetricsRateTimeInterval = TimeSpan.FromMinutes(2), MetricsSubIntervalCount = 6, SwapPath = IgniteUtils.GetTempDirectoryName(), CheckpointPageBufferSize = 28 * 1024 * 1024 }, DataRegionConfigurations = new[] { new DataRegionConfiguration { Name = "reg2", EmptyPagesPoolSize = 51, EvictionThreshold = 0.7, InitialSize = 101 * 1024 * 1024, MaxSize = 151 * 1024 * 1024, MetricsEnabled = false, PageEvictionMode = Configuration.DataPageEvictionMode.RandomLru, PersistenceEnabled = false, MetricsRateTimeInterval = TimeSpan.FromMinutes(3), MetricsSubIntervalCount = 7, SwapPath = IgniteUtils.GetTempDirectoryName() } } } }); }
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)); } }
/// <summary> /// Gets the custom configuration. /// </summary> private static IgniteConfiguration GetCustomConfig() { // CacheConfiguration is not tested here - see CacheConfigurationTest return(new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { NetworkTimeout = TimeSpan.FromSeconds(1), AckTimeout = TimeSpan.FromSeconds(2), MaxAckTimeout = TimeSpan.FromSeconds(3), SocketTimeout = TimeSpan.FromSeconds(4), JoinTimeout = TimeSpan.FromSeconds(5), IpFinder = new TcpDiscoveryStaticIpFinder { Endpoints = new[] { "127.0.0.1:49900", "127.0.0.1:49901" } }, ClientReconnectDisabled = true, ForceServerMode = true, HeartbeatFrequency = TimeSpan.FromSeconds(3), IpFinderCleanFrequency = TimeSpan.FromMinutes(7), LocalAddress = "127.0.0.1", LocalPort = 49900, LocalPortRange = 13, MaxMissedClientHeartbeats = 9, MaxMissedHeartbeats = 7, ReconnectCount = 11, StatisticsPrintFrequency = TimeSpan.FromSeconds(20), ThreadPriority = 6, TopologyHistorySize = 1234567 }, GridName = "gridName1", IncludedEventTypes = EventType.SwapspaceAll, MetricsExpireTime = TimeSpan.FromMinutes(7), MetricsHistorySize = 125, MetricsLogFrequency = TimeSpan.FromMinutes(8), MetricsUpdateFrequency = TimeSpan.FromMinutes(9), NetworkSendRetryCount = 54, NetworkTimeout = TimeSpan.FromMinutes(10), NetworkSendRetryDelay = TimeSpan.FromMinutes(11), WorkDirectory = Path.GetTempPath(), JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath(), Localhost = "127.0.0.1", IsDaemon = true, IsLateAffinityAssignment = false, UserAttributes = Enumerable.Range(1, 10).ToDictionary(x => x.ToString(), x => (object)x), AtomicConfiguration = new AtomicConfiguration { CacheMode = CacheMode.Replicated, Backups = 2, AtomicSequenceReserveSize = 200 }, TransactionConfiguration = new TransactionConfiguration { DefaultTransactionConcurrency = TransactionConcurrency.Optimistic, DefaultTimeout = TimeSpan.FromSeconds(25), DefaultTransactionIsolation = TransactionIsolation.Serializable, PessimisticTransactionLogLinger = TimeSpan.FromHours(1), PessimisticTransactionLogSize = 240 }, CommunicationSpi = new TcpCommunicationSpi { LocalPort = 47501, MaxConnectTimeout = TimeSpan.FromSeconds(34), MessageQueueLimit = 15, ConnectTimeout = TimeSpan.FromSeconds(17), IdleConnectionTimeout = TimeSpan.FromSeconds(19), SelectorsCount = 8, ReconnectCount = 33, SocketReceiveBufferSize = 512, AckSendThreshold = 99, DirectBuffer = false, DirectSendBuffer = true, LocalPortRange = 45, LocalAddress = "127.0.0.1", TcpNoDelay = false, SlowClientQueueLimit = 98, SocketSendBufferSize = 2045, UnacknowledgedMessagesBufferSize = 3450 }, FailureDetectionTimeout = TimeSpan.FromSeconds(3.5), SwapSpaceSpi = new FileSwapSpaceSpi { ReadStripesNumber = 64, MaximumWriteQueueSize = 8, WriteBufferSize = 9, BaseDirectory = Path.GetTempPath(), MaximumSparsity = 11.22f } }); }
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 localNode = ignite.GetCluster().GetLocalNode(); var remoteNode = ignite.GetCluster().ForRemotes().GetNode(); 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); var localNodeNew = ignite.GetCluster().GetLocalNode(); Assert.AreNotSame(localNode, localNodeNew); Assert.AreNotEqual(localNode.Id, localNodeNew.Id); var remoteNodeNew = ignite.GetCluster().ForRemotes().GetNode(); Assert.AreEqual(remoteNode.Id, remoteNodeNew.Id); } }
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); cfg.SpringConfigUrl = cfgs[1]; var grid2 = Ignition.Start(cfg); Assert.AreEqual("grid2", grid2.Name); cfg.SpringConfigUrl = cfgs[2]; var grid3 = Ignition.Start(cfg); Assert.IsNull(grid3.Name); Assert.AreSame(grid1, Ignition.GetIgnite("grid1")); Assert.AreSame(grid2, Ignition.GetIgnite("grid2")); Assert.AreSame(grid3, Ignition.GetIgnite(null)); try { Ignition.GetIgnite("invalid_name"); } catch (IgniteException e) { Console.WriteLine("Expected exception: " + e); } Assert.IsTrue(Ignition.Stop("grid1", true)); try { Ignition.GetIgnite("grid1"); } catch (IgniteException e) { Console.WriteLine("Expected exception: " + e); } grid2.Dispose(); try { Ignition.GetIgnite("grid2"); } catch (IgniteException e) { Console.WriteLine("Expected exception: " + e); } grid3.Dispose(); try { Ignition.GetIgnite(null); } catch (IgniteException e) { Console.WriteLine("Expected exception: " + e); } 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 }) { try { Ignition.GetIgnite(gridName); } catch (IgniteException e) { Console.WriteLine("Expected exception: " + e); } } }