private void TestFailureHandler(Type type) { var configFile = "config\\ignite-stophandler-dotnet-cfg.xml"; if (type == typeof(StopNodeOrHaltFailureHandler)) { configFile = "config\\ignite-halthandler-dotnet-cfg.xml"; } var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-configFileName=" + configFile); Assert.IsTrue(proc.Alive); var ccfg = new CacheConfiguration("CacheWithFailedStore") { CacheStoreFactory = new FailedCacheStoreFactory(), ReadThrough = true }; var ex = Assert.Throws <CacheException>(() => _grid.GetOrCreateCache <int, int>(ccfg)); Assert.IsTrue(ex.Message.Contains(CacheStoreExMessage)); Thread.Sleep(TimeSpan.Parse("0:0:5")); Assert.IsFalse(proc.Alive); }
public void TestDefaultSpi() { var cfg = new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { AckTimeout = TimeSpan.FromDays(2), MaxAckTimeout = TimeSpan.MaxValue, JoinTimeout = TimeSpan.MaxValue, NetworkTimeout = TimeSpan.MaxValue, SocketTimeout = TimeSpan.MaxValue }, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), Localhost = "127.0.0.1" }; using (var ignite = Ignition.Start(cfg)) { cfg.IgniteInstanceName = "ignite2"; using (var ignite2 = Ignition.Start(cfg)) { Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count); Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count); } } }
/// <summary> /// Tests the ip finders. /// </summary> /// <param name="ipFinder">The ip finder.</param> /// <param name="ipFinder2">The ip finder2.</param> private static void TestIpFinders(TcpDiscoveryIpFinderBase ipFinder, TcpDiscoveryIpFinderBase ipFinder2) { var cfg = new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { IpFinder = ipFinder }, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), Localhost = "127.0.0.1" }; using (var ignite = Ignition.Start(cfg)) { // Start with the same endpoint cfg.IgniteInstanceName = "ignite2"; using (var ignite2 = Ignition.Start(cfg)) { Assert.AreEqual(2, ignite.GetCluster().GetNodes().Count); Assert.AreEqual(2, ignite2.GetCluster().GetNodes().Count); } // Start with incompatible endpoint and check that there are 2 topologies ((TcpDiscoverySpi)cfg.DiscoverySpi).IpFinder = ipFinder2; using (var ignite2 = Ignition.Start(cfg)) { Assert.AreEqual(1, ignite.GetCluster().GetNodes().Count); Assert.AreEqual(1, ignite2.GetCluster().GetNodes().Count); } } }
public void TestStartStopLeak() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid1.xml", JvmOptions = new List <string> { "-Xcheck:jni", "-Xms256m", "-Xmx256m", "-XX:+HeapDumpOnOutOfMemoryError" }, JvmClasspath = TestUtils.CreateTestClasspath() }; for (var i = 0; i < 50; i++) { Console.WriteLine("Iteration: " + i); var grid = Ignition.Start(cfg); UseIgnite(grid); if (i % 2 == 0) // Try to stop ignite from another thread. { Task.Factory.StartNew(() => grid.Dispose()).Wait(); } else { grid.Dispose(); } GC.Collect(); // At the time of writing java references are cleaned from finalizer, so GC is needed. } }
/// <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" }); }
public void TestUsageAfterStop() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid1.xml", JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath() }; var grid = Ignition.Start(cfg); Assert.IsNotNull(grid.GetCache <int, int>("cache1")); grid.Dispose(); try { grid.GetCache <int, int>("cache1"); Assert.Fail(); } catch (InvalidOperationException e) { Console.WriteLine("Expected exception: " + e); } }
public void TestLoadAllDllInDir() { var dirInfo = Directory.CreateDirectory(Path.GetTempPath() + "/testDlls"); Assert.False(IsLoaded("dllFromDir1")); Assert.False(IsLoaded("dllFromDir2")); GenerateDll(dirInfo.FullName + "/dllFromDir1.dll"); GenerateDll(dirInfo.FullName + "/dllFromDir2.dll"); File.WriteAllText(dirInfo.FullName + "/notADll.txt", "notADll"); var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid3.xml", Assemblies = new List <string> { dirInfo.FullName }, JvmClasspath = TestUtils.CreateTestClasspath() }; var grid = Ignition.Start(cfg); Assert.IsNotNull(grid); Assert.True(IsLoaded("dllFromDir1")); Assert.True(IsLoaded("dllFromDir2")); }
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 (Ignition.Start(servCfg)) // start server-mode ignite first { Ignition.ClientMode = true; using (var grid = Ignition.Start(clientCfg)) { UseIgnite(grid); } } } finally { Ignition.ClientMode = false; } }
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 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); } }
/// <summary> /// Gets the grid configuration. /// </summary> protected virtual IgniteConfiguration GetConfiguration(string springConfigUrl) { return(new IgniteConfiguration { SpringConfigUrl = springConfigUrl, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions() }); }
/// <summary> /// Gets the Ignite configuration. /// </summary> private static IgniteConfiguration Configuration(string springConfigUrl) { return(new IgniteConfiguration { SpringConfigUrl = springConfigUrl, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions() }); }
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); } }
public void SetUp() { var cfg = new IgniteConfiguration { GridName = GridName, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), SpringConfigUrl = "config\\native-client-test-cache.xml" }; Ignition.Start(cfg); }
public void TestStartDefault() { var cfg = new IgniteConfiguration { JvmClasspath = TestUtils.CreateTestClasspath() }; var grid = Ignition.Start(cfg); Assert.IsNotNull(grid); Assert.AreEqual(1, grid.GetCluster().GetNodes().Count); }
public void TestLoadUnexistingLibrary() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid3.xml", Assemblies = new List <string> { "unexistingAssembly.820482.dll" }, JvmClasspath = TestUtils.CreateTestClasspath() }; Assert.Throws <IgniteException>(() => Ignition.Start(cfg)); }
/// <summary> /// Starts the grid with provided config. /// </summary> /// <param name="binaryConfiguration">The binary configuration.</param> private void StartGrid(BinaryConfiguration binaryConfiguration) { Ignition.StopAll(true); var grid = Ignition.Start(new IgniteConfiguration { SpringConfigUrl = "config\\cache-binarizables.xml", JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), BinaryConfiguration = binaryConfiguration }); _cache = grid.GetCache <int, TestGenericBinarizableBase>(null); }
public void TestStartWithConfigPath() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\spring-test.xml", JvmClasspath = TestUtils.CreateTestClasspath() }; var grid = Ignition.Start(cfg); Assert.IsNotNull(grid); Assert.AreEqual(1, grid.GetCluster().GetNodes().Count); }
public void TestProcessorInit() { var cfg = new IgniteConfiguration { SpringConfigUrl = "Config\\spring-test.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"); Assert.IsTrue(proc.Alive); 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)); }
public void TestJvmOptsCmd() { var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + SpringCfgPath, "-J-DOPT1", "-J-DOPT2" ); Assert.IsTrue(_grid.WaitTopology(2)); var cfg = RemoteConfig(); Assert.IsTrue(cfg.JvmOptions.Contains("-DOPT1") && cfg.JvmOptions.Contains("-DOPT2")); }
public void TestXmlConfigurationCmd() { var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-configFileName=config\\ignite-dotnet-cfg.xml"); Assert.IsTrue(_grid.WaitTopology(2)); var remoteCfg = RemoteConfig(); Assert.IsTrue(remoteCfg.JvmOptions.Contains("-DOPT25")); proc.Kill(); Assert.IsTrue(_grid.WaitTopology(1)); }
/// <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, 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 } }); }
/// <summary> /// Verifies that custom-deployed node has started. /// </summary> private static void VerifyNodeStarted(string exePath) { using (var ignite = Ignition.Start(new IgniteConfiguration { SpringConfigUrl = "config\\compute\\compute-grid1.xml", JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions() })) { Assert.IsTrue(ignite.WaitTopology(2)); var remoteProcPath = ignite.GetCluster().ForRemotes().GetCompute().Call(new ProcessPathFunc()); Assert.AreEqual(exePath, remoteProcPath); } }
/// <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.LifecycleBeans = new List <ILifecycleBean> { new Bean(), new Bean() }; return(Ignition.Start(cfg)); }
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)); }
public void TestXmlConfigurationAppConfig() { IgniteProcess.ReplaceConfiguration("config\\Apache.Ignite.exe.config.test3"); var proc = new IgniteProcess("-jvmClasspath=" + TestUtils.CreateTestClasspath()); Assert.IsTrue(_grid.WaitTopology(2)); var remoteCfg = RemoteConfig(); Assert.IsTrue(remoteCfg.JvmOptions.Contains("-DOPT25")); proc.Kill(); Assert.IsTrue(_grid.WaitTopology(1)); }
/// <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> /// 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 TestAssemblyCmd() { GenerateDll("test-1.dll"); GenerateDll("test-2.dll"); var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + SpringCfgPath, "-assembly=test-1.dll", "-assembly=test-2.dll" ); Assert.IsTrue(_grid.WaitTopology(2)); var cfg = RemoteConfig(); Assert.IsTrue(cfg.Assemblies.Contains("test-1.dll") && cfg.Assemblies.Contains("test-2.dll")); }
public void TestJvmMemoryOptsCmdRaw() { var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + SpringCfgPath, "-J-Xms506m", "-J-Xmx607m" ); Assert.IsTrue(_grid.WaitTopology(2, 30000)); var minMem = _grid.Cluster.ForRemotes().Compute().ExecuteJavaTask <long>(MinMemTask, null); Assert.AreEqual((long)506 * 1024 * 1024, minMem); var maxMem = _grid.Cluster.ForRemotes().Compute().ExecuteJavaTask <long>(MaxMemTask, null); AssertJvmMaxMemory((long)607 * 1024 * 1024, maxMem); }
public void TestJvmMemoryOptsCmdCustom() { var proc = new IgniteProcess( "-jvmClasspath=" + TestUtils.CreateTestClasspath(), "-springConfigUrl=" + SpringCfgPath, "-JvmInitialMemoryMB=615", "-JvmMaxMemoryMB=863" ); Assert.IsTrue(_grid.WaitTopology(2)); var minMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask <long>(MinMemTask, null); Assert.AreEqual((long)615 * 1024 * 1024, minMem); var maxMem = _grid.GetCluster().ForRemotes().GetCompute().ExecuteJavaTask <long>(MaxMemTask, null); AssertJvmMaxMemory((long)863 * 1024 * 1024, maxMem); }