Пример #1
0
        public void TestStartStopLeak()
        {
            var cfg = TestUtils.GetTestConfiguration();

            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.
                {
                    TaskRunner.Run(() => grid.Dispose()).Wait();
                }
                else
                {
                    grid.Dispose();
                }

                GC.Collect(); // At the time of writing java references are cleaned from finalizer, so GC is needed.
            }
        }
Пример #2
0
        public void TestMultipleDomains()
        {
            using (var ignite = Ignition.Start(TestUtils.GetTestConfiguration()))
            {
                Assert.IsTrue(_outSb.ToString().Contains("[ver=1, servers=1, clients=0,"));

                // Run twice
                RunInNewDomain();
                RunInNewDomain();

                Assert.AreEqual(5, ignite.GetCluster().TopologyVersion);

                var outTxt = _outSb.ToString();

                // Check output from another domain (2 started + 2 stopped = 4)
                Assert.AreEqual(4, Regex.Matches(outTxt, ">>> Ignite instance name: newDomainGrid").Count);

                // Both domains produce the topology snapshot on node enter
                Assert.AreEqual(2, Regex.Matches(outTxt, "ver=2, servers=2, clients=0,").Count);
                Assert.AreEqual(1, Regex.Matches(outTxt, "ver=3, servers=1, clients=0,").Count);
                Assert.AreEqual(2, Regex.Matches(outTxt, "ver=4, servers=2, clients=0,").Count);
                Assert.AreEqual(1, Regex.Matches(outTxt, "ver=5, servers=1, clients=0,").Count);
            }
        }
Пример #3
0
        public void TestDisabledRedirect()
        {
            // Run test in new process because JVM is initialized only once.
            const string envVar = "ConsoleRedirectTest.TestDisabledRedirect";

            if (Environment.GetEnvironmentVariable(envVar) == "true")
            {
                var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration(false));
                Assert.IsTrue(cfg.RedirectJavaConsoleOutput);

                cfg.RedirectJavaConsoleOutput = false;

                using (Ignition.Start(cfg))
                {
                    Assert.AreEqual("", _errSb.ToString());
                    Assert.AreEqual("", _outSb.ToString());
                }
            }
            else
            {
                Environment.SetEnvironmentVariable(envVar, "true");
                TestUtils.RunTestInNewProcess(GetType().FullName, "TestDisabledRedirect");
            }
        }
Пример #4
0
 /// <summary>
 /// Gets the configuration.
 /// </summary>
 protected virtual IgniteConfiguration GetConfig()
 {
     return(TestUtils.GetTestConfiguration());
 }
Пример #5
0
        public void TestClusterRestart()
        {
            var serverCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                CacheConfiguration = new[] { new CacheConfiguration(CacheName) }
            };

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

            var server = Ignition.Start(serverCfg);

            Assert.AreEqual(1, server.GetCluster().GetNodes().Count);

            var client = Ignition.Start(clientCfg);

            Assert.AreEqual(2, client.GetCluster().GetNodes().Count);

            ClientReconnectEventArgs eventArgs = null;

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

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

            cache[1] = new Person(1);

            Ignition.Stop(server.Name, true);

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

            Assert.IsNotNull(ex);

            // Wait a bit for cluster restart detection.
            Thread.Sleep(1000);

            // Start the server and wait for reconnect.
            Ignition.Start(serverCfg);

            // Check reconnect task.
            Assert.IsTrue(ex.ClientReconnectTask.Result);

            // Wait a bit for notifications.
            Thread.Sleep(100);

            // Check the event args.
            Assert.IsNotNull(eventArgs);
            Assert.IsTrue(eventArgs.HasClusterRestarted);

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

            Assert.AreEqual(0, cache1.GetSize());

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

            // Check that old cache instance still works.
            Assert.AreEqual(2, cache.Get(1).Id);
        }
Пример #6
0
 /// <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:47503", "127.0.0.1:47504" }
             },
             ClientReconnectDisabled = true,
             ForceServerMode = true,
             IpFinderCleanFrequency = TimeSpan.FromMinutes(7),
             LocalAddress = "127.0.0.1",
             LocalPort = 47503,
             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(),
         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 = PathUtils.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 = PathUtils.GetTempDirectoryName()
                 }
             }
         },
         AuthenticationEnabled = false,
         MvccVacuumFrequency = 20000,
         MvccVacuumThreadCount = 8,
         SqlQueryHistorySize = 99,
         JavaPeerClassLoadingEnabled = false,
         SqlSchemas = new List <string> {
             "SCHEMA_3", "schema_4"
         },
         ExecutorConfiguration = new[]
         {
             new ExecutorConfiguration
             {
                 Name = "ex-1",
                 Size = 11
             }
         }
     });
 }