예제 #1
0
        public static void EnablingSsl()
        {
            //tag::ssl[]
            var cfg = new IgniteClientConfiguration
            {
                Endpoints        = new[] { "127.0.0.1:10800" },
                SslStreamFactory = new SslStreamFactory
                {
                    CertificatePath     = ".../certs/client.pfx",
                    CertificatePassword = "******",
                }
            };

            using (var client = Ignition.StartClient(cfg))
            {
                //...
            }

            //end::ssl[]
        }
예제 #2
0
        public void TestClientMaintainsConnectionWhenOriginalNodeLeaves()
        {
            // Client knows about single server node initially.
            var ignite = Ignition.Start(GetIgniteConfiguration());
            var cfg    = GetClientConfiguration();

            cfg.Endpoints = new[] { IPAddress.Loopback + ":10803" };

            // Client starts and discovers other server nodes.
            var client = Ignition.StartClient(cfg);

            AssertClientConnectionCount(client, 4);

            // Original node leaves. Client is still connected.
            ignite.Dispose();
            AssertClientConnectionCount(client, 3);

            // Perform any operation to verify that client works.
            Assert.AreEqual(3, client.GetCluster().GetNodes().Count);
        }
예제 #3
0
        public void TestAsyncCompletionOrder()
        {
            var config = GetClientConfiguration();

            config.SocketTimeout = TimeSpan.FromMinutes(2);
            using (var client = Ignition.StartClient(config))
            {
                var cache  = client.GetCache <int, int>(CacheName);
                var cache2 = Client.GetOrCreateCache <int, int>("TestAsyncCompletionOrder");

                cache.PutAll(Enumerable.Range(1, 50000).Select(x => new KeyValuePair <int, int>(x, x)));
                var t1 = cache.RemoveAllAsync();
                var t2 = cache2.PutAsync(1, 1);

                t2.Wait();
                Assert.IsFalse(t1.IsCompleted);

                t1.Wait();
            }
        }
예제 #4
0
 /// <summary>
 /// Waits for server node to fully start.
 /// </summary>
 private static bool WaitForStart()
 {
     return(TestUtils.WaitForCondition(() =>
     {
         try
         {
             // Port 10890 is set in Runner.java
             using (var client = Ignition.StartClient(GetClientConfiguration()))
             {
                 // Create cache to ensure valid grid state.
                 client.GetOrCreateCache <int, int>(typeof(JavaServer).FullName);
                 return true;
             }
         }
         catch (Exception)
         {
             return false;
         }
     }, 60000));
 }
예제 #5
0
파일: ThinClient.cs 프로젝트: zombar/ignite
        //end::scanQry[]

        public static void ScanQueryFilterDemo()
        {
            using (var ignite = Ignition.Start())
            {
                var cfg = new IgniteClientConfiguration
                {
                    Endpoints = new[] { "127.0.0.1:10800" }
                };
                using (var client = Ignition.StartClient(cfg))
                {
                    //tag::scanQry2[]
                    var cache = client.GetOrCreateCache <int, Person>("personCache");

                    cache.Put(1, new Person {
                        Name = "John Smith"
                    });
                    cache.Put(2, new Person {
                        Name = "John Johnson"
                    });

                    using (var cursor = cache.Query(new ScanQuery <int, Person>(new NameFilter())))
                    {
                        foreach (var entry in cursor)
                        {
                            Console.WriteLine("Key = " + entry.Key + ", Name = " + entry.Value.Name);
                        }
                    }

                    //end::scanQry2[]

                    //tag::handleNodeFailure[]
                    var scanQry = new ScanQuery <int, Person>(new NameFilter());
                    using (var cur = cache.Query(scanQry))
                    {
                        var res = cur.GetAll().ToDictionary(entry => entry.Key, entry => entry.Value);
                    }

                    //end::handleNodeFailure[]
                }
            }
        }
예제 #6
0
        public void TestStartFromAppConfig()
        {
            using (Ignition.Start(TestUtils.GetTestConfiguration()))
            {
                // Custom file.
                using (var client = Ignition.StartClient("igniteClientConfiguration", "custom_app.config"))
                {
                    Assert.AreEqual(512, client.GetConfiguration().SocketSendBufferSize);
                }

                // Missing file.
                var ex = Assert.Throws<ConfigurationErrorsException>(() => Ignition.StartClient("foo", "bar"));
                Assert.AreEqual("Specified config file does not exist: bar", ex.Message);

#if !NETCOREAPP2_0 && !NETCOREAPP3_0  // Test runners do not pick up default config.
                // Default section.
                using (var client = Ignition.StartClient())
                {
                    Assert.AreEqual("127.0.0.1", client.GetConfiguration().Host);
                    Assert.AreEqual(0, client.GetConfiguration().SocketSendBufferSize);
                }

                // Custom section.
                using (var client = Ignition.StartClient("igniteClientConfiguration2"))
                {
                    Assert.AreEqual("127.0.0.1", client.GetConfiguration().Host);
                    Assert.AreEqual(2048, client.GetConfiguration().SocketSendBufferSize);
                }

                // Missing section content.
                ex = Assert.Throws<ConfigurationErrorsException>(() =>
                    Ignition.StartClient("igniteClientConfiguration3"));
                Assert.AreEqual("IgniteClientConfigurationSection with name 'igniteClientConfiguration3' is " +
                                "defined in <configSections>, but not present in configuration.", ex.Message);

                // Missing section.
                ex = Assert.Throws<ConfigurationErrorsException>(() => Ignition.StartClient("foo"));
                Assert.AreEqual("Could not find IgniteClientConfigurationSection with name 'foo'.", ex.Message);
#endif
            }
        }
예제 #7
0
        public async Task Invoke()
        {
            var cfg = new IgniteClientConfiguration
            {
                Host = ClusterNode.Address.ToString(),
                Port = ClusterNode.Port != 0 ? ClusterNode.Port : DEFAULT_PORT,
            };

            using (var client = Ignition.StartClient(cfg))
            {
                foreach (var fileInfo in SourceFiles)
                {
                    OnFileOpen?.Invoke(this, fileInfo);
                    using (var device = new FastPcapFileReaderDevice(fileInfo.FullName))
                    {
                        await ProcessFile(client, fileInfo, device);
                    }
                    OnFileCompleted?.Invoke(this, fileInfo);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// Starts the grids.
        /// </summary>
        private void StartGrids()
        {
            if (_grid1 != null)
            {
                return;
            }

            var path = Path.Combine("Config", "Compute", "compute-grid");

            var cfg = GetConfiguration(path + "1.xml");

            _grid1 = Ignition.Start(cfg);

            cfg.ClientMode         = true;
            cfg.IgniteInstanceName = "client";
            cfg.WorkDirectory      = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
                                                  "client_work");

            _client     = Ignition.Start(cfg);
            _thinClient = Ignition.StartClient(GetClientConfiguration());
        }
예제 #9
0
        public static void Main()
        {
            var cfg = new IgniteClientConfiguration
            {
                Host = "127.0.0.1"
            };

            using (IIgniteClient igniteClient = Ignition.StartClient(cfg))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Cache put-get client example started.");

                ICacheClient <int, Organization> cache = igniteClient.GetCache <int, Organization>(CacheName);

                PutGet(cache);
            }

            Console.WriteLine();
            Console.WriteLine(">>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
예제 #10
0
        public static void Main()
        {
            var cfg = new IgniteClientConfiguration
            {
                Host = "127.0.0.1"
            };

            using (IIgniteClient igniteClient = Ignition.StartClient(cfg))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Cache query client example started.");

                // Configure query entities to enable SQL.
                var cacheCfg = new CacheClientConfiguration
                {
                    Name          = CacheName,
                    QueryEntities = new[]
                    {
                        new QueryEntity(typeof(int), typeof(Employee)),
                    }
                };

                ICacheClient <int, Employee> cache = igniteClient.GetOrCreateCache <int, Employee>(cacheCfg);

                // Populate cache with sample data entries.
                PopulateCache(cache);

                // Run SQL example.
                SqlQueryExample(cache);
                LinqExample(cache);

                // Run SQL fields query example.
                SqlFieldsQueryExample(cache);
                LinqFieldsExample(cache);
            }

            Console.WriteLine();
            Console.WriteLine(">>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
예제 #11
0
        public void IgniteOperations()
        {
            IgniteClientConfiguration _igniteClientConfiguration = new IgniteClientConfiguration
            {
                Endpoints     = new string[] { "localhost" },
                SocketTimeout = TimeSpan.FromSeconds(30)
            };
            Student student = new Student {
                Department = "ece", Year = 2, Name = "ABC", RoleNumber = "12-abc"
            };
            Lecturer lect = new Lecturer {
                Name = "ABC-L", Id = "LET-1"
            };

            using (IIgniteClient client = Ignition.StartClient(_igniteClientConfiguration))
            {
                try
                {
                    var cache = client.GetCache <string, ICollege>("college-code-123");
                    //create student
                    cache.Put(student.RoleNumber, student);
                    var sqlQuery = new SqlQuery(typeof(Student), "where Name = ?", "ABC");
                    var record   = cache.Query(sqlQuery).GetAll();

                    //create lecturer
                    cache.Put(lect.Id, lect);
                    var lectRec = cache.Get(lect.Id);
                    //create lecturer table since cache configuration not able to change for existing cache
                    var sQuery = CreateTable();
                    cache.Query(sQuery);

                    var lsqlQuery = new SqlQuery(typeof(Lecturer), "where Name = ?", "ABC-L");
                    var lrecord   = cache.Query(sqlQuery).GetAll();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
예제 #12
0
        public static void Main()
        {
            var cfg = new IgniteClientConfiguration("127.0.0.1");

            using (IIgniteClient igniteClient = Ignition.StartClient(cfg))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Cache query client example started.");

                ICacheClient <int, Employee> cache = igniteClient.GetOrCreateCache <int, Employee>(CacheName);

                // Populate cache with sample data entries.
                PopulateCache(cache);

                // Run scan query example.
                ScanQueryExample(cache);
            }

            Console.WriteLine();
            Console.WriteLine(">>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
예제 #13
0
        public void TestPutGetDictionary([Values(true, false)] bool compactFooter)
        {
            var cfg = GetClientConfiguration();

            cfg.BinaryConfiguration = new BinaryConfiguration
            {
                CompactFooter = compactFooter
            };

            using (var client = Ignition.StartClient(cfg))
            {
                var dict = new Dictionary<ByteEnum, int> { { ByteEnum.One, 1 }, { ByteEnum.Two, 2 } };

                var serverCache = GetCache<Dictionary<ByteEnum, int>>();
                var clientCache = client.GetCache<int, Dictionary<ByteEnum, int>>(CacheName);

                serverCache.Put(1, dict);
                var res = clientCache.Get(1);

                Assert.AreEqual(dict, res);
            }
        }
예제 #14
0
        public void TestPutGetHashSet([Values(true, false)] bool compactFooter)
        {
            var cfg = GetClientConfiguration();

            cfg.BinaryConfiguration = new BinaryConfiguration
            {
                CompactFooter = compactFooter
            };

            using (var client = Ignition.StartClient(cfg))
            {
                var hashSet = new HashSet<ByteEnum> { ByteEnum.One, ByteEnum.Two };

                var serverCache = GetCache<HashSet<ByteEnum>>();
                var clientCache = client.GetCache<int, HashSet<ByteEnum>>(CacheName);

                serverCache.Put(1, hashSet);
                var res = clientCache.Get(1);

                Assert.AreEqual(hashSet, res);
            }
        }
예제 #15
0
        public void TestEndPoints()
        {
            using (var ignite = Ignition.Start(TestUtils.GetTestConfiguration()))
            {
                ignite.CreateCache <int, int>("foo");

                const int port = IgniteClientConfiguration.DefaultPort;

                // DnsEndPoint.
                var cfg = new IgniteClientConfiguration
                {
                    Endpoints = new[] { "localhost" }
                };

                using (var client = Ignition.StartClient(cfg))
                {
                    Assert.AreEqual("foo", client.GetCacheNames().Single());
                }

                // IPEndPoint.
                cfg = new IgniteClientConfiguration
                {
                    Endpoints = new[] { "127.0.0.1:" + port }
                };

                using (var client = Ignition.StartClient(cfg))
                {
                    Assert.AreEqual("foo", client.GetCacheNames().Single());
                }

                // Port range.
                cfg = new IgniteClientConfiguration("127.0.0.1:10798..10800");

                using (var client = Ignition.StartClient(cfg))
                {
                    Assert.AreEqual("foo", client.GetCacheNames().Single());
                }
            }
        }
예제 #16
0
        public void TestSslConnectionWithoutClientAuth()
        {
            Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                SpringConfigUrl = Path.Combine("Config", "Client", "server-with-ssl-no-client-auth.xml"),
            });

            var cfg = new IgniteClientConfiguration
            {
                Endpoints        = new[] { "127.0.0.1:11120" },
                SslStreamFactory = new SslStreamFactory
                {
                    SkipServerCertificateValidation = true,
                    SslProtocols = SslProtocols.Tls12
                }
            };

            using (var client = Ignition.StartClient(cfg))
            {
                Assert.AreEqual(1, client.GetCluster().GetNodes().Count);
            }
        }
예제 #17
0
        public static void Main()
        {
            using (IIgniteClient ignite = Ignition.StartClient(Utils.GetThinClientConfiguration()))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Cache put-get example started.");

                // Clean up caches on all nodes before run.
                ignite.GetOrCreateCache <object, object>(CacheName).Clear();

                PutGet(ignite);
                PutGetBinary(ignite);
                PutAllGetAll(ignite);
                PutAllGetAllBinary(ignite);

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine(">>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
예제 #18
0
        public static void Main()
        {
            using (var ignite = Ignition.StartClient(Utils.GetThinClientConfiguration()))
            {
                Console.WriteLine();
                Console.WriteLine(">>> Cache SQL example started.");

                var employeeCache = ignite.GetOrCreateCache <int, Employee>(
                    new CacheClientConfiguration(EmployeeCacheName, new QueryEntity(typeof(int), typeof(Employee))));

                var employeeCacheColocated = ignite.GetOrCreateCache <AffinityKey, Employee>(
                    new CacheClientConfiguration(EmployeeCacheNameColocated,
                                                 new QueryEntity(typeof(AffinityKey), typeof(Employee))));

                var organizationCache = ignite.GetOrCreateCache <int, Organization>(
                    new CacheClientConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization))));

                // Populate cache with sample data entries.
                PopulateCache(employeeCache);
                PopulateCache(employeeCacheColocated);
                PopulateCache(organizationCache);

                // Run SQL query example.
                SqlQueryExample(employeeCache);

                // Run SQL query with join example.
                SqlJoinQueryExample(employeeCacheColocated);

                // Run SQL query with distributed join example.
                SqlDistributedJoinQueryExample(employeeCache);

                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine(">>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
예제 #19
0
        private static IIgniteClient GetClient(bool enableHeartbeats, int?heartbeatInterval = null,
                                               int port = IgniteClientConfiguration.DefaultPort)
        {
            var cfg = new IgniteClientConfiguration
            {
                Endpoints = new List <string> {
                    $"{IPAddress.Loopback}:{port}"
                },
                EnableHeartbeats = enableHeartbeats,
                Logger           = new ListLogger
                {
                    EnabledLevels = new[] { LogLevel.Debug, LogLevel.Info, LogLevel.Warn, LogLevel.Error }
                },
                EnablePartitionAwareness = true
            };

            if (heartbeatInterval != null)
            {
                cfg.HeartbeatInterval = TimeSpan.FromMilliseconds(heartbeatInterval.Value);
            }

            return(Ignition.StartClient(cfg));
        }
예제 #20
0
        public static void Main()
        {
            using (IIgniteClient ignite = Ignition.StartClient(Utils.GetThinClientConfiguration()))
            {
                Console.WriteLine(">>> Services example started.");
                Console.WriteLine();

                var prx = ignite.GetServices().GetServiceProxy <IMapService <int, string> >(ServiceName);

                for (var i = 0; i < 10; i++)
                {
                    prx.Put(i, i.ToString());
                }

                var mapSize = prx.Size;

                Console.WriteLine(">>> Map service size: " + mapSize);
            }

            Console.WriteLine();
            Console.WriteLine(">>> Example finished, press any key to exit ...");
            Console.ReadKey();
        }
예제 #21
0
        public void TestReconnect()
        {
            // Connect client and check.
            Ignition.Start(TestUtils.GetTestConfiguration());
            var client = Ignition.StartClient(new IgniteClientConfiguration("127.0.0.1"));

            Assert.AreEqual(0, client.GetCacheNames().Count);

            var ep = client.RemoteEndPoint as IPEndPoint;

            Assert.IsNotNull(ep);
            Assert.AreEqual(IgniteClientConfiguration.DefaultPort, ep.Port);
            Assert.AreEqual("127.0.0.1", ep.Address.ToString());

            ep = client.LocalEndPoint as IPEndPoint;
            Assert.IsNotNull(ep);
            Assert.AreNotEqual(IgniteClientConfiguration.DefaultPort, ep.Port);
            Assert.AreEqual("127.0.0.1", ep.Address.ToString());

            // Stop server.
            Ignition.StopAll(true);

            // First request fails, error is detected.
            var ex = Assert.Catch(() => client.GetCacheNames());

            Assert.IsNotNull(GetSocketException(ex));

            // Second request causes reconnect attempt which fails (server is stopped).
            var aex = Assert.Throws <AggregateException>(() => client.GetCacheNames());

            Assert.AreEqual("Failed to establish Ignite thin client connection, " +
                            "examine inner exceptions for details.", aex.Message.Substring(0, 88));

            // Start server, next operation succeeds.
            Ignition.Start(TestUtils.GetTestConfiguration());
            Assert.AreEqual(0, client.GetCacheNames().Count);
        }
예제 #22
0
        public void TestReconnectDisabled()
        {
            // Connect client and check.
            Ignition.Start(TestUtils.GetTestConfiguration());
            using (var client = Ignition.StartClient(new IgniteClientConfiguration("127.0.0.1")
            {
                ReconnectDisabled = true
            }))
            {
                Assert.AreEqual(0, client.GetCacheNames().Count);

                // Stop server.
                Ignition.StopAll(true);

                // Request fails, error is detected.
                var ex = Assert.Catch(() => client.GetCacheNames());
                Assert.IsNotNull(GetSocketException(ex));

                // Restart server, client does not reconnect.
                Ignition.Start(TestUtils.GetTestConfiguration());
                ex = Assert.Catch(() => client.GetCacheNames());
                Assert.IsNotNull(GetSocketException(ex));
            }
        }
예제 #23
0
        public void TestDisabledConnector()
        {
            var servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                ClientConnectorConfigurationEnabled = false
            };

            var clientCfg = new IgniteClientConfiguration
            {
                Endpoints = new[] { "localhost" }
            };

            using (Ignition.Start(servCfg))
            {
                var ex = Assert.Throws <AggregateException>(() => Ignition.StartClient(clientCfg));
                Assert.AreEqual("Failed to establish Ignite thin client connection, " +
                                "examine inner exceptions for details.", ex.Message.Substring(0, 88));
            }

            // Disable only thin client.
            servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                ClientConnectorConfiguration = new ClientConnectorConfiguration
                {
                    ThinClientEnabled = false
                }
            };

            using (Ignition.Start(servCfg))
            {
                var ex = Assert.Throws <IgniteClientException>(() => Ignition.StartClient(clientCfg));
                Assert.AreEqual("Client handshake failed: 'Thin client connection is not allowed, " +
                                "see ClientConnectorConfiguration.thinClientEnabled.'.",
                                ex.Message.Substring(0, 118));
            }
        }
        public void TestCompactFooterEnabledOnServerDisabledOnClientProducesWarning()
        {
            Ignition.Start(TestUtils.GetTestConfiguration());

            var logger = GetLogger();

            var clientConfiguration = new IgniteClientConfiguration(GetClientConfiguration(logger))
            {
                BinaryConfiguration = new BinaryConfiguration
                {
                    CompactFooter = false
                }
            };

            using (var client = Ignition.StartClient(clientConfiguration))
            {
                var resCfg = client.GetConfiguration();

                Assert.IsNotNull(resCfg.BinaryConfiguration);
                Assert.IsFalse(resCfg.BinaryConfiguration.CompactFooter);

                AssertCompactFooter(client, false);

                Assert.AreEqual(1, logger.Entries.Count(e =>
                                                        e.Message == "Server binary configuration retrieved: " +
                                                        "BinaryConfigurationClientInternal [CompactFooter=True, NameMapperMode=BasicFull]" &&
                                                        e.Level == LogLevel.Debug));

                Assert.AreEqual(1, logger.Entries.Count(e =>
                                                        e.Message == "BinaryConfiguration.CompactFooter is true on the server, but false on the client." +
                                                        "Consider enabling this setting to reduce cache entry size." &&
                                                        e.Level == LogLevel.Info));

                Assert.IsEmpty(logger.Entries.Where(e => e.Level > LogLevel.Info));
            }
        }
        public void TestCacheStartFromThinClientRegistersMetaForQueryEntityTypes()
        {
            var cfg = new CacheClientConfiguration
            {
                Name          = TestUtils.TestName,
                QueryEntities = new[]
                {
                    new QueryEntity
                    {
                        KeyType   = typeof(Key1),
                        ValueType = typeof(Value1)
                    }
                }
            };

            using (var client = Ignition.StartClient(new IgniteClientConfiguration("localhost:10800..10801")))
            {
                client.CreateCache <Key1, Value1>(cfg);

                var type = client.GetBinary().GetBinaryType(typeof(Key1));

                Assert.AreEqual("Bar", type.AffinityKeyFieldName);
            }
        }
예제 #26
0
        public void TestCustomConfig()
        {
            var servCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration())
            {
                ClientConnectorConfiguration = new ClientConnectorConfiguration
                {
                    Host      = "localhost",
                    Port      = 2000,
                    PortRange = 1
                }
            };

            var clientCfg = new IgniteClientConfiguration
            {
                Host = "localhost",
                Port = 2000
            };

            using (Ignition.Start(servCfg))
                using (Ignition.StartClient(clientCfg))
                {
                    // No-op.
                }
        }
예제 #27
0
파일: ThinClient.cs 프로젝트: zombar/ignite
        public static void Compute()
        {
            //tag::client-compute-setup[]
            var igniteCfg = new IgniteConfiguration
            {
                ClientConnectorConfiguration = new ClientConnectorConfiguration
                {
                    ThinClientConfiguration = new ThinClientConfiguration
                    {
                        MaxActiveComputeTasksPerConnection = 10
                    }
                }
            };

            IIgnite ignite = Ignition.Start(igniteCfg);
            //end::client-compute-setup[]

            var cfg = new IgniteClientConfiguration();
            //tag::client-compute-task[]
            IIgniteClient  client  = Ignition.StartClient(cfg);
            IComputeClient compute = client.GetCompute();
            int            result  = compute.ExecuteJavaTask <int>("org.foo.bar.AddOneTask", 1);
            //end::client-compute-task[]
        }
예제 #28
0
        public void TestClientDisposalStopsReceiverThread([Values(true, false)] bool async)
        {
            Ignition.Start(TestUtils.GetTestConfiguration());

            var logger = new ListLogger {
                EnabledLevels = new[] { LogLevel.Trace }
            };

            var cfg = new IgniteClientConfiguration(GetClientConfiguration())
            {
                Logger = logger
            };

            using (var client = Ignition.StartClient(cfg))
            {
                var cache = client.GetOrCreateCache <int, int>("c");

                if (async)
                {
                    cache.PutAsync(1, 1);
                }
                else
                {
                    cache.Put(1, 1);
                }
            }

            var threadId = logger.Entries
                           .Select(e => Regex.Match(e.Message, "Receiver thread #([0-9]+) started."))
                           .Where(m => m.Success)
                           .Select(m => int.Parse(m.Groups[1].Value))
                           .First();

            TestUtils.WaitForTrueCondition(() => logger.Entries.Any(
                                               e => e.Message == string.Format("Receiver thread #{0} stopped.", threadId)));
        }
예제 #29
0
        public void CacheGet_PartitionAwarenessDisabled_RequestIsRoutedToDefaultNode()
        {
            var cfg = GetClientConfiguration();

            cfg.EnablePartitionAwareness = false;

            using (var client = Ignition.StartClient(cfg))
            {
                var cache = client.GetCache <int, int>(_cache.Name);

                var requestTargets = Enumerable
                                     .Range(1, 10)
                                     .Select(x =>
                {
                    cache.Get(x);
                    return(GetClientRequestGridIndex());
                })
                                     .Distinct()
                                     .ToArray();

                // Partition awareness disabled - all requests go to same socket, picked with round-robin on connect.
                Assert.AreEqual(1, requestTargets.Length);
            }
        }
예제 #30
0
        public void ReadData(string cacheName)
        {
            Console.WriteLine("ReadData:::");
            var _igniteClientConfiguration = new IgniteClientConfiguration
            {
                Endpoints     = new string[] { "localhost" },
                SocketTimeout = TimeSpan.FromSeconds(60)
            };

            using (var client = Ignition.StartClient(_igniteClientConfiguration)) //in other services simply open connection and closing
            {
                try
                {
                    var    cache          = client.GetCache <object, object>(cacheName);
                    string query          = "select Name from Forms";
                    var    sqlFieldsQuery = new SqlFieldsQuery(query);
                    var    result         = cache.Query(sqlFieldsQuery).GetAll();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }