public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Transaction deadlock detection example started."); var cache = ignite.GetOrCreateCache <int, int>(new CacheConfiguration { Name = CacheName, AtomicityMode = CacheAtomicityMode.Transactional }); // Clean up caches on all nodes before run. cache.Clear(); var keys = Enumerable.Range(1, 100).ToArray(); // Modify keys in reverse order to cause a deadlock. var task1 = Task.Factory.StartNew(() => UpdateKeys(cache, keys, 1)); var task2 = Task.Factory.StartNew(() => UpdateKeys(cache, keys.Reverse(), 2)); Task.WaitAll(task1, task2); Console.WriteLine("\n>>> Example finished, press any key to exit ..."); Console.ReadKey(); } }
static void Main(string[] args) { using (var ignite = Ignition.StartFromApplicationConfiguration()) { ignite.GetCluster().ForServers().GetCompute().Call(new UseDiagnosticsSource()); } }
private void button7_Click(object sender, EventArgs e) { try { List <Person> lstData = GeneratePersonData(5); var cfg = new IgniteConfiguration { BinaryConfiguration = new BinaryConfiguration(typeof(Person), typeof(PersonFilter)), }; Ignition.ClientMode = true; using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration")) { ICache <int, Person> persons = ignite.GetOrCreateCache <int, Person>(new CacheConfiguration("SQL_DATA", typeof(Person), typeof(PersonFilter))); int i = 1; foreach (Person p in lstData) { persons.Put(i++, p); } } txtMsg.Text = "Data pushed into cache 'SQL_DATA' heap........."; dgCacheData.DataSource = lstData; } catch (Exception ex) { txtMsg.Text = ex.ToString(); } }
static void Main(string[] args) { Ignition.ClientMode = true; using (var ignite = Ignition.StartFromApplicationConfiguration()) { var cache = ignite.GetCache <string, Record>("SQL_PUBLIC_RECORDS"); // Ignite SQL has a usability issue: the INSERT statement does not fill primary key fields embedded // into value objects. Need to fill the primary key fields manually. const string key = "SQL"; var sqlRec = cache.Get(key); sqlRec.id = key; Console.WriteLine($">>>>> {sqlRec}"); var phpRec = cache.Get("PHP"); Console.WriteLine($">>>>> {phpRec}"); var dotnetRec = new Record { id = ".NET", price = 30.0, quantity = 3 }; cache.Put(dotnetRec.id, dotnetRec); Console.WriteLine($">>>>> {cache.Get(dotnetRec.id)}"); } }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Cache EntryProcessor example started."); ICache <int, int> cache = ignite.GetOrCreateCache <int, int>(CacheName); cache.Clear(); // Populate cache with Invoke. int[] keys = Enumerable.Range(1, EntryCount).ToArray(); foreach (var key in keys) { cache.Invoke(key, new CachePutEntryProcessor(), 10); } PrintCacheEntries(cache); // Increment entries by 5 with InvokeAll. cache.InvokeAll(keys, new CacheIncrementEntryProcessor(), 5); PrintCacheEntries(cache); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Closure execution example started."); ICollection <string> words = "Count characters using closure".Split().ToList(); Console.WriteLine(); Console.WriteLine(">>> Calculating character count with manual reducing:"); var res = ignite.GetCompute().Apply(new CharacterCountClosure(), words); int totalLen = res.Sum(); Console.WriteLine(">>> Total character count: " + totalLen); Console.WriteLine(); Console.WriteLine(">>> Calculating character count with reducer:"); totalLen = ignite.GetCompute().Apply(new CharacterCountClosure(), words, new CharacterCountReducer()); Console.WriteLine(">>> Total character count: " + totalLen); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public void TestIgniteStart() { Environment.SetEnvironmentVariable(Classpath.EnvIgniteNativeTestClasspath, "true"); using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration")) { Assert.AreEqual("myGrid1", ignite.Name); Assert.IsNotNull(ignite.GetCache <int, int>("cacheName")); } using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration2")) { Assert.AreEqual("myGrid2", ignite.Name); Assert.IsNotNull(ignite.GetCache <int, int>("cacheName2")); } using (var ignite = Ignition.StartFromApplicationConfiguration()) { Assert.IsTrue(ignite.Name.StartsWith("myGrid")); } using (var ignite = Ignition.StartFromApplicationConfiguration( "igniteConfiguration3", "custom_app.config")) { Assert.AreEqual("myGrid3", ignite.Name); } }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Optimistic transaction example started."); // Create Transactional cache. var cacheCfg = new CacheConfiguration(CacheName) { AtomicityMode = CacheAtomicityMode.Transactional }; var cache = ignite.GetOrCreateCache <int, int>(cacheCfg); // Put a value. cache[1] = 0; // Increment a value in parallel within a transaction. var task1 = Task.Factory.StartNew(() => IncrementCacheValue(cache, 1)); var task2 = Task.Factory.StartNew(() => IncrementCacheValue(cache, 2)); Task.WaitAll(task1, task2); Console.WriteLine(); Console.WriteLine(">>> Resulting value in cache: " + cache[1]); Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); } }
public static void Run() { var ignite = Ignition.TryGetIgnite() ?? Ignition.StartFromApplicationConfiguration(); Console.WriteLine(); Console.WriteLine(">>> Cache query example started."); var employeeCache = ignite.GetOrCreateCache <int, Employee>( new CacheConfiguration(EmployeeCacheName, typeof(Employee))); var employeeCacheColocated = ignite.GetOrCreateCache <AffinityKey, Employee>( new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee))); var organizationCache = ignite.GetOrCreateCache <int, Organization>( new CacheConfiguration(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); // Run SQL fields query example. SqlFieldsQueryExample(employeeCache); }
/// <summary> /// Starts standalone node. /// </summary> private void StartRemoteNodes() { if (_remoteNodeStarted) { return; } // Start a grid to monitor topology; // Stop it after topology check so we don't interfere with example. Ignition.ClientMode = false; using (var ignite = Ignition.StartFromApplicationConfiguration( "igniteConfiguration", PathUtil.ExamplesAppConfigPath)) { var args = new List <string> { "-configFileName=" + PathUtil.ExamplesAppConfigPath, " -assembly=" + typeof(AverageSalaryJob).Assembly.Location }; var proc = new IgniteProcess(args.ToArray()); Assert.IsTrue(ignite.WaitTopology(2), string.Format("Standalone node failed to join topology: [{0}]", proc.GetInfo())); Assert.IsTrue(proc.Alive, string.Format("Standalone node stopped unexpectedly: [{0}]", proc.GetInfo())); } _remoteNodeStarted = true; }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Cache query DML example started."); var employeeCache = ignite.GetOrCreateCache <int, Employee>( new CacheConfiguration(EmployeeCacheName, new QueryEntity(typeof(int), typeof(Employee)))); var organizationCache = ignite.GetOrCreateCache <int, Organization>(new CacheConfiguration( OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization)))); employeeCache.Clear(); organizationCache.Clear(); Insert(organizationCache, employeeCache); Select(employeeCache, "Inserted data"); Update(employeeCache); Select(employeeCache, "Update salary for ASF employees"); Delete(employeeCache); Select(employeeCache, "Delete non-ASF employees"); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { // See app.config: <atomicConfiguration atomicSequenceReserveSize="10" /> // Each node reserves 10 numbers to itself, so that 10 increments can be done locally, // without communicating to other nodes. After that, another 10 elements are reserved. using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Atomic sequence example started."); IAtomicSequence atomicSequence = ignite.GetAtomicSequence(AtomicSequenceIncrementAction.AtomicSequenceName, 0, true); Console.WriteLine(">>> Atomic sequence initial value: " + atomicSequence.Read()); // Broadcast an action that increments AtomicSequence a number of times. ignite.GetCompute().Broadcast(new AtomicSequenceIncrementAction()); // Actual value will depend on number of participating nodes. Console.WriteLine("\n>>> Atomic sequence current value: " + atomicSequence.Read()); } Console.WriteLine("\n>>> Check output on all nodes."); Console.WriteLine("\n>>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(">>> Events example started."); Console.WriteLine(); Console.WriteLine(">>> Listening for a local event..."); ignite.GetEvents().EnableLocal(EventType.TaskExecutionAll); var listener = new LocalListener(); ignite.GetEvents().LocalListen(listener, EventType.TaskExecutionAll); ExecuteTask(ignite); ignite.GetEvents().StopLocalListen(listener); Console.WriteLine(">>> Received events count: " + listener.EventsReceived); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(">>> Services example started."); Console.WriteLine(); var svc = new MapService <int, string>(); Console.WriteLine(">>> Deploying service to all nodes..."); ignite.GetServices().DeployNodeSingleton("service", svc); var prx = ignite.GetServices().GetServiceProxy <IMapService <int, string> >("service", true); for (var i = 0; i < 10; i++) { prx.Put(i, i.ToString()); } var mapSize = prx.Size; Console.WriteLine(">>> Map service size: " + mapSize); ignite.GetServices().CancelAll(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Task execution example started."); // Generate employees to calculate average salary for. ICollection <Employee> employees = Employees(); Console.WriteLine(); Console.WriteLine(">>> Calculating average salary for employees:"); foreach (Employee employee in employees) { Console.WriteLine(">>> " + employee); } // Execute task and get average salary. var avgSalary = ignite.GetCompute().Execute(new AverageSalaryTask(), employees); Console.WriteLine(); Console.WriteLine(">>> Average salary for all employees: " + avgSalary); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Cache query example started."); var employeeCache = ignite.GetOrCreateCache <int, Employee>( new CacheConfiguration(EmployeeCacheName, typeof(Employee))); // Populate cache with sample data entries. PopulateCache(employeeCache); // Run scan query example. ScanQueryExample(employeeCache); // Run full text query example. FullTextQueryExample(employeeCache); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Peer loading example started."); var remotes = ignite.GetCluster().ForRemotes(); if (remotes.GetNodes().Count == 0) { throw new Exception("This example requires remote nodes to be started. " + "Please start at least 1 remote node. " + "Refer to example's documentation for details on configuration."); } Console.WriteLine(">>> Executing an action on all remote nodes..."); // Execute action on all remote cluster nodes. remotes.GetCompute().Broadcast(new HelloAction()); Console.WriteLine(">>> Action executed, check output on remote nodes."); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public void TestIgniteStart() { using (EnvVar.Set(Classpath.EnvIgniteNativeTestClasspath, bool.TrueString)) { using (var ignite = Ignition.StartFromApplicationConfiguration(Ignition.ConfigurationSectionName)) { Assert.AreEqual("myGrid1", ignite.Name); Assert.IsNotNull(ignite.GetCache <int, int>("cacheName")); } using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration2")) { Assert.AreEqual("myGrid2", ignite.Name); Assert.IsNotNull(ignite.GetCache <int, int>("cacheName2")); } using (var ignite = Ignition.StartFromApplicationConfiguration()) { Assert.AreEqual("myGrid1", ignite.Name); } using (var ignite = Ignition.StartFromApplicationConfiguration( "igniteConfiguration3", "custom_app.config")) { Assert.AreEqual("myGrid3", ignite.Name); } } }
static void Main() { AdoNetCacheStore.InitializeDb(); using (var ignite = Ignition.StartFromApplicationConfiguration()) { var cacheCfg = new CacheConfiguration { Name = "cars", CacheStoreFactory = new AdoNetCacheStoreFactory(), KeepBinaryInStore = true, ReadThrough = true, WriteThrough = true }; ICache <int, IBinaryObject> cars = ignite.GetOrCreateCache <int, object>(cacheCfg).WithKeepBinary <int, IBinaryObject>(); IBinaryObject car = ignite.GetBinary() .GetBuilder("Car") .SetStringField("Name", "Honda NSX") .SetIntField("Power", 600) .Build(); // Put an entry to Ignite cache, this causes AdoNetCacheStore.Write call. cars.Put(1, car); // Remove an entry from Ignite cache, but not from cache store. Console.WriteLine("Cache size before Clear: " + cars.GetSize()); cars.Clear(); Console.WriteLine("Cache size after Clear: " + cars.GetSize()); // Get an entry by key, which delegates to AdoNetCacheStore.Load. Console.WriteLine("Requesting key from Ignite cache..."); IBinaryObject carFromStore = cars.Get(1); Console.WriteLine("Entry from cache store: " + carFromStore); // Read data from SQL server directly. Console.WriteLine("\nData from SQL server:"); using (var conn = new SqlCeConnection(AdoNetCacheStore.ConnectionString)) { using (var cmd = new SqlCeCommand(@"SELECT * FROM Cars", conn)) { conn.Open(); foreach (IDataRecord row in cmd.ExecuteReader()) { Console.WriteLine("SQL row: "); for (var i = 0; i < row.FieldCount; i++) { Console.Write(row.GetValue(i) + "; "); } } } } Console.WriteLine(); } }
public static void Main(string[] args) { InitializeDb(); using (var ignite = Ignition.StartFromApplicationConfiguration()) { var blogs = ignite.GetOrCreateCache <int, Blog>(new CacheConfiguration { Name = "blogs", CacheStoreFactory = new BlogCacheStoreFactory(), ReadThrough = true, WriteThrough = true, KeepBinaryInStore = false // Store works with concrete classes. }); var posts = ignite.GetOrCreateCache <int, Post>(new CacheConfiguration { Name = "posts", CacheStoreFactory = new PostCacheStoreFactory(), ReadThrough = true, WriteThrough = true, KeepBinaryInStore = false // Store works with concrete classes. }); Console.WriteLine("\n>>> Example started\n\n"); // Load all posts, but do not load blogs. Console.WriteLine("Calling ICache.LoadCache..."); posts.LoadCache(null); // Show all posts with their blogs. DisplayData(posts, blogs); // Add new data to cache. Console.WriteLine("Adding new post to existing blog.."); var postId = posts.Max(x => x.Key) + 1; // Generate new id. posts[1] = new Post { BlogId = blogs.Min(x => x.Key), // Existing blog PostId = postId, Title = "New Post From Ignite" }; // Show all posts with their blogs. DisplayData(posts, blogs); // Remove newly added post. Console.WriteLine("Removing post with id {0}...", postId); posts.Remove(postId); Console.WriteLine("\n>>> Example finished.\n"); } }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Transaction example started."); var cache = ignite.GetOrCreateCache <int, Account>(new CacheConfiguration { Name = CacheName, AtomicityMode = CacheAtomicityMode.Transactional }); // Clean up caches on all nodes before run. cache.Clear(); // Initialize. cache.Put(1, new Account(1, 100)); cache.Put(2, new Account(2, 200)); Console.WriteLine(); Console.WriteLine(">>> Accounts before transfer: "); Console.WriteLine(">>> " + cache.Get(1)); Console.WriteLine(">>> " + cache.Get(2)); Console.WriteLine(); // Transfer money between accounts in a single transaction. using (var tx = cache.Ignite.GetTransactions().TxStart(TransactionConcurrency.Pessimistic, TransactionIsolation.RepeatableRead)) { Account acc1 = cache.Get(1); Account acc2 = cache.Get(2); acc1.Balance += 100; acc2.Balance -= 100; cache.Put(1, acc1); cache.Put(2, acc2); tx.Commit(); } Console.WriteLine(">>> Transfer finished."); Console.WriteLine(); Console.WriteLine(">>> Accounts after transfer: "); Console.WriteLine(">>> " + cache.Get(1)); Console.WriteLine(">>> " + cache.Get(2)); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { Console.WriteLine(); Console.WriteLine(">>> Multi-tiered cache example started."); // Configure swap in the current bin directory (where our assembly is located). var binDir = Path.GetDirectoryName(typeof(MultiTieredCacheExample).Assembly.Location); var swapDir = Path.Combine(binDir, "ignite-swap"); Console.WriteLine(">>> Swap space directory: " + swapDir); using (var ignite = Ignition.StartFromApplicationConfiguration()) { var cacheCfg = new CacheConfiguration { Name = CacheName, Backups = 1, EvictionPolicy = new LruEvictionPolicy { MaxSize = 10 // Maximum number of entries that will be stored in Java heap. }, }; ICache <int, byte[]> cache = ignite.GetOrCreateCache <int, byte[]>(cacheCfg); // Sample data. byte[] dataBytes = new byte[EntrySize]; // Filling out cache and printing its metrics. PrintCacheMetrics(cache); for (int i = 0; i < 100; i++) { cache.Put(i, dataBytes); if (i % 10 == 0) { Console.WriteLine(">>> Cache entries created: {0}", i + 1); PrintCacheMetrics(cache); } } Console.WriteLine(">>> Waiting for metrics final update..."); Thread.Sleep(IgniteConfiguration.DefaultMetricsUpdateFrequency); PrintCacheMetrics(cache); Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); } }
public void TestIgniteStartsFromAppConfig() { var configPath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "app.config"); Environment.SetEnvironmentVariable(Classpath.EnvIgniteNativeTestClasspath, "true"); using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration", configPath)) { var cache = ignite.GetCache <int, int>(ignite.GetCacheNames().Single()); Assert.AreEqual("cacheName", cache.Name); } }
public void TestIgniteStartsFromAppConfig() { // 1) MsTest does not pick up the config file, so we have to provide it manually. // 2) Note that System.Configuration.ConfigurationManager NuGet package has to be installed. var configPath = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "app.config"); using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration", configPath)) { var cache = ignite.GetCache <int, int>(ignite.GetCacheNames().Single()); Assert.AreEqual("cacheFromConfig", cache.Name); Assert.AreEqual(CacheMode.Replicated, cache.GetConfiguration().CacheMode); } }
/// <summary> /// Runs the example. /// </summary> public static void Run() { var ignite = Ignition.TryGetIgnite() ?? Ignition.StartFromApplicationConfiguration(); 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); PutGetAsync(ignite).Wait(); }
public static void Main() { // Make sure to start an Ignite server node before. Ignition.ClientMode = true; using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(">>> Client node connected to the cluster"); // Creating a distributed and near cache. var nearCacheCfg = new NearCacheConfiguration { EvictionPolicy = new LruEvictionPolicy { // Near cache will store only 10 recently accessed/used entries. MaxSize = 10 } }; // Enable .NET near cache: keeps data in CLR heap to avoid deserialization costs. var platformNearCacheCfg = new PlatformNearCacheConfiguration(); Console.WriteLine(">>> Populating the cache..."); ICache <int, int> cache = ignite.GetOrCreateCache <int, int>( new CacheConfiguration(CacheName), nearCacheCfg, platformNearCacheCfg); // Adding data into the cache. // Latest 10 entries will be stored in the near cache on the client node side. for (int i = 0; i < 1000; i++) { cache.Put(i, i * 10); } Console.WriteLine(">>> Cache size: [Total={0}, Near={1}]", cache.GetSize(), cache.GetSize(CachePeekMode.PlatformNear)); Console.WriteLine("\n>>> Reading from near cache..."); // Read data directly from .NET cache, without network or JVM calls, and without deserialization. foreach (var entry in cache.GetLocalEntries(CachePeekMode.PlatformNear)) { Console.WriteLine(entry); } Console.WriteLine("\n>>> Example finished, press any key to exit ..."); Console.ReadKey(); } }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Cache query example started."); var employeeCache = ignite.GetOrCreateCache <int, Employee>( new CacheConfiguration(EmployeeCacheName, typeof(Employee))); var employeeCacheColocated = ignite.GetOrCreateCache <AffinityKey, Employee>( new CacheConfiguration(EmployeeCacheNameColocated, typeof(Employee))); var organizationCache = ignite.GetOrCreateCache <int, Organization>( new CacheConfiguration(OrganizationCacheName, new QueryEntity(typeof(int), typeof(Organization)))); // Populate cache with sample data entries. PopulateCache(employeeCache); PopulateCache(employeeCacheColocated); PopulateCache(organizationCache); // Run scan query example. ScanQueryExample(employeeCache); // Run SQL query example. SqlQueryExample(employeeCache); // Run SQL query with join example. SqlJoinQueryExample(employeeCacheColocated); // Run SQL query with distributed join example. SqlDistributedJoinQueryExample(employeeCache); // Run SQL fields query example. SqlFieldsQueryExample(employeeCache); // Run full text query example. FullTextQueryExample(employeeCache); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public static void Main() { using (var ignite = Ignition.StartFromApplicationConfiguration()) { Console.WriteLine(); Console.WriteLine(">>> Cache LINQ example started."); var cache = ignite.GetOrCreateCache <object, object>(new CacheConfiguration { Name = CacheName, QueryEntities = new[] { new QueryEntity(typeof(int), typeof(Organization)), new QueryEntity(typeof(EmployeeKey), typeof(Employee)) } }); // Clean up caches on all nodes before run. cache.Clear(); // Populate cache with sample data entries. PopulateCache(cache); // Create cache that will work with specific types. var employeeCache = ignite.GetCache <EmployeeKey, Employee>(CacheName); var organizationCache = ignite.GetCache <int, Organization>(CacheName); // Run SQL query example. QueryExample(employeeCache); // Run compiled SQL query example. CompiledQueryExample(employeeCache); // Run SQL query with join example. JoinQueryExample(employeeCache, organizationCache); // Run SQL fields query example. FieldsQueryExample(employeeCache); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
private void btnStart_Click(object sender, EventArgs e) { try { Ignition.ClientMode = true; using (var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration")) { txtMsg.Text = "Connection successful.......:)"; ICache <int, string> cache = ignite.GetOrCreateCache <int, string>("test"); cache.Put(1, "Hello, World!"); } } catch (Exception ex) { txtMsg.Text = ex.ToString(); } }
/// <summary> /// Tests the example with standalone Apache.Ignite.exe nodes. /// </summary> /// <param name="example">The example to run.</param> /// <param name="clientMode">Client mode flag.</param> private static void TestRemoteNodes(Example example, bool clientMode) { // Exclude LifecycleExample if (string.IsNullOrEmpty(example.ConfigPath)) { Assert.AreEqual("LifecycleExample", example.Name); return; } var configPath = Path.Combine(PathUtil.IgniteHome, PathUtil.DevPrefix, example.ConfigPath); // Try with multiple standalone nodes for (var i = 0; i < 2; i++) { // Start a grid to monitor topology // Stop it after topology check so we don't interfere with example Ignition.ClientMode = false; using (var ignite = Ignition.StartFromApplicationConfiguration( "igniteConfiguration", configPath)) { var args = new List <string> { "-configFileName=" + configPath }; if (example.NeedsTestDll) { args.Add(" -assembly=" + typeof(AverageSalaryJob).Assembly.Location); } var proc = new IgniteProcess(args.ToArray()); Assert.IsTrue(ignite.WaitTopology(i + 2)); Assert.IsTrue(proc.Alive); } Ignition.ClientMode = clientMode; // Run twice to catch issues with standalone node state example.Run(); example.Run(); } }