/// <summary> /// Gets the custom configuration. /// </summary> private static IgniteConfiguration GetCustomConfig() { // CacheConfiguration is not tested here - see CacheConfigurationTest return(new IgniteConfiguration(TestUtils.GetTestConfiguration()) { 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 }, EncryptionSpi = new KeystoreEncryptionSpi() { KeySize = 192, KeyStorePassword = "******", KeyStorePath = "tde.jks", MasterKeyName = KeystoreEncryptionSpi.DefaultMasterKeyName }, 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(), 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, DefaultTimeoutOnPartitionMapExchange = TimeSpan.FromSeconds(25) }, 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, ConnectionsPerNode = 12, UsePairedConnections = true, SharedMemoryPort = 1234, SocketWriteTimeout = 2222, SelectorSpins = 12, FilterReachableAddresses = true }, FailureDetectionTimeout = TimeSpan.FromSeconds(3.5), SystemWorkerBlockedTimeout = TimeSpan.FromSeconds(8.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, WalAutoArchiveAfterInactivity = TimeSpan.FromMinutes(5), CheckpointReadLockTimeout = TimeSpan.FromSeconds(9.5), 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 = TestUtils.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 = TestUtils.GetTempDirectoryName() } } }, AuthenticationEnabled = false, MvccVacuumFrequency = 20000, MvccVacuumThreadCount = 8, SqlQueryHistorySize = 99, SqlSchemas = new List <string> { "SCHEMA_3", "schema_4" }, ExecutorConfiguration = new[] { new ExecutorConfiguration { Name = "ex-1", Size = 11 } } }); }
public void TestJavaLogger() { // Run the test in a separate process because log4jlogger has some static state, // and after Ignite has been started once, it is not possible to start a new node // with a different logger config. const string envVar = "DefaultLoggerTest.TestJavaLogger"; if (Environment.GetEnvironmentVariable(envVar) == "true") { // Delete all log files from the work dir Func <string[]> getLogs = () => Directory.GetFiles(IgniteHome.Resolve(), "dotnet-logger-test.log", SearchOption.AllDirectories); getLogs().ToList().ForEach(File.Delete); var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration(false)) { SpringConfigUrl = @"config\log\custom-log.xml", CacheConfiguration = new[] { new CacheConfiguration("cache1", new QueryEntity(typeof(uint), typeof(ulong))) }, Logger = null }; // Start Ignite and verify file log using (var ignite = Ignition.Start(cfg)) { // Log with all levels var log = ignite.Logger; var levels = new[] { LogLevel.Trace, LogLevel.Info, LogLevel.Debug, LogLevel.Warn, LogLevel.Error }; foreach (var level in levels) { var ex = new Exception("EXCEPTION_TEST_" + level); log.Log(level, "DOTNET-" + level, null, null, "=DOTNET=", null, ex); } } using (var fs = File.Open(getLogs().Single(), FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { var log = new StreamReader(fs).ReadToEnd(); // Check output from Java: Assert.IsTrue(log.Contains(">>> Topology snapshot.")); // Check output from .NET: Assert.IsTrue(log.Contains("Starting Ignite.NET " + typeof(Ignition).Assembly.GetName().Version)); Assert.IsTrue(log.Contains( "Validating cache configuration 'cache1', QueryEntity 'java.lang.Integer:java.lang." + "Long': Type 'System.UInt32' maps to Java type 'java.lang.Integer' using unchecked " + "conversion. This may cause issues in SQL queries. You can use 'System.Int32' " + "instead to achieve direct mapping.")); // Check custom log output (trace is disabled, errors are logged from Warn and up): Assert.IsTrue(log.Contains("[INFO ][main][=DOTNET=] DOTNET-Info")); Assert.IsTrue(log.Contains("[DEBUG][main][=DOTNET=] DOTNET-Debug")); Assert.IsTrue(log.Contains("[WARN ][main][=DOTNET=] DOTNET-Warn")); Assert.IsTrue(log.Contains("class org.apache.ignite.IgniteException: " + "Platform error:System.Exception: EXCEPTION_TEST_Warn")); Assert.IsTrue(log.Contains("[ERROR][main][=DOTNET=] DOTNET-Error")); Assert.IsTrue(log.Contains("class org.apache.ignite.IgniteException: " + "Platform error:System.Exception: EXCEPTION_TEST_Error")); } } else { Environment.SetEnvironmentVariable(envVar, "true"); TestUtils.RunTestInNewProcess(GetType().FullName, "TestJavaLogger"); } }
public void TestCustomDeployment() { // Create temp folder var folder = GetTempFolder(); // Copy jars var home = IgniteHome.Resolve(null); var jarNames = new[] { @"\ignite-core-", @"\cache-api-1.0.0.jar", @"\modules\spring\" }; var jars = Directory.GetFiles(home, "*.jar", SearchOption.AllDirectories) .Where(jarPath => jarNames.Any(jarPath.Contains)).ToArray(); Assert.Greater(jars.Length, 3); foreach (var jar in jars) { // ReSharper disable once AssignNullToNotNullAttribute File.Copy(jar, Path.Combine(folder, Path.GetFileName(jar)), true); } // Build classpath var classpath = string.Join(";", Directory.GetFiles(folder).Select(Path.GetFileName)); // Copy .NET binaries foreach (var asm in new[] { typeof(IgniteRunner).Assembly, typeof(Ignition).Assembly, GetType().Assembly }) { File.Copy(asm.Location, Path.Combine(folder, Path.GetFileName(asm.Location))); } // Copy config var springPath = Path.GetFullPath("config\\compute\\compute-grid2.xml"); var springFile = Path.GetFileName(springPath); File.Copy(springPath, Path.Combine(folder, springFile)); // Start a node and make sure it works properly var exePath = Path.Combine(folder, "Apache.Ignite.exe"); var proc = IgniteProcess.Start(exePath, string.Empty, args: new[] { "-springConfigUrl=" + springFile, "-jvmClasspath=" + classpath, "-J-ea", "-J-Xcheck:jni", "-J-Xms512m", "-J-Xmx512m" }); Assert.IsNotNull(proc); try { VerifyNodeStarted(exePath); } finally { proc.Kill(); Assert.IsTrue( TestUtils.WaitForCondition(() => { try { Directory.Delete(folder, true); return(true); } catch (Exception) { return(false); } }, 1000), "Failed to remove temp directory: " + folder); } }
/// <summary> /// /// </summary> /// <returns></returns> public static string CreateTestClasspath() { var home = IgniteHome.Resolve(); return(Classpath.CreateClasspath(null, home, forceTestClasspath: true)); }
/// <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 }, 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.Disabled, 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.Disabled, 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 }, PersistentStoreConfiguration = new PersistentStoreConfiguration { AlwaysWriteFullPages = true, CheckpointingFrequency = TimeSpan.FromSeconds(25), CheckpointingPageBufferSize = 28 * 1024 * 1024, CheckpointingThreads = 2, LockWaitTime = TimeSpan.FromSeconds(5), PersistentStorePath = Path.GetTempPath(), TlbSize = 64 * 1024, WalArchivePath = Path.GetTempPath(), WalFlushFrequency = TimeSpan.FromSeconds(3), WalFsyncDelayNanos = 3, WalHistorySize = 10, WalMode = WalMode.LogOnly, WalRecordIteratorBufferSize = 32 * 1024 * 1024, WalSegments = 6, WalSegmentSize = 5 * 1024 * 1024, WalStorePath = Path.GetTempPath(), MetricsEnabled = true, SubIntervals = 7, RateTimeInterval = TimeSpan.FromSeconds(9), CheckpointWriteOrder = CheckpointWriteOrder.Random, WriteThrottlingEnabled = true }, ConsistentId = new MyConsistentId { Data = "abc" } }); }