/// <summary> /// Create JVM. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="cbs">Callbacks.</param> /// <returns>Context.</returns> internal static void CreateJvmContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs) { lock (SyncRoot) { // 1. Warn about possible configuration inconsistency. JvmConfiguration jvmCfg = JvmConfig(cfg); if (!cfg.SuppressWarnings && _jvmCfg != null) { if (!_jvmCfg.Equals(jvmCfg)) { Console.WriteLine("Attempting to start Ignite node with different Java " + "configuration; current Java configuration will be ignored (consider " + "starting node in separate process) [oldConfig=" + _jvmCfg + ", newConfig=" + jvmCfg + ']'); } } // 2. Create unmanaged pointer. void* ctx = CreateJvm(cfg, cbs); cbs.SetContext(ctx); // 3. If this is the first JVM created, preserve it. if (_ctx == null) { _ctx = ctx; _jvmCfg = jvmCfg; } } }
public void TestIgniteStartup() { var memoryLog = CreateMemoryLogger(); var logger = new IgniteLog4NetLogger(); var cfg = new IgniteConfiguration { DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), Logger = logger }; Func<IEnumerable<string>> getLogs = () => memoryLog.GetEvents().Select(x => x.MessageObject.ToString()); using (var ignite = Ignition.Start(cfg)) { Assert.IsTrue(getLogs().Contains( string.Format("Starting Ignite.NET {0}", typeof(Ignition).Assembly.GetName().Version))); Assert.IsTrue(getLogs().Any(x => x.Contains(">>> Topology snapshot."))); Assert.IsInstanceOf<IgniteLog4NetLogger>(ignite.Logger); ignite.Logger.Info("Log from user code."); Assert.IsTrue(getLogs().Contains("Log from user code.")); } Assert.IsTrue(getLogs().Contains("Grid is stopping.")); }
public void TestNoCacheNode() { const string cacheName = "cache"; var cacheNodeCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { SpringConfigUrl = @"Config\cache-local-node.xml", GridName = "cacheGrid" }; using (var gridNoCache = Ignition.Start(TestUtils.GetTestConfiguration())) { Assert.Throws<ArgumentException>(() => gridNoCache.GetCache<int, int>(cacheName)); var gridWithCache = Ignition.Start(cacheNodeCfg); var streamer = gridNoCache.GetDataStreamer<int, int>(cacheName); streamer.AddData(1, 2); streamer.Flush(); Ignition.Stop(gridWithCache.Name, true); Thread.Sleep(500); // Wait for node to stop var task = streamer.AddData(2, 3); streamer.Flush(); AssertThrowsCacheStopped(task); } }
/// <summary> /// Serializes specified <see cref="IgniteConfiguration" /> to <see cref="XmlWriter" />. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="writer">The writer.</param> /// <param name="rootElementName">Name of the root element.</param> public static void Serialize(IgniteConfiguration configuration, XmlWriter writer, string rootElementName) { IgniteArgumentCheck.NotNull(configuration, "configuration"); IgniteArgumentCheck.NotNull(writer, "writer"); IgniteArgumentCheck.NotNullOrEmpty(rootElementName, "rootElementName"); WriteElement(configuration, writer, rootElementName, typeof(IgniteConfiguration)); }
public void FixtureSetUp() { var cfg = new IgniteConfiguration { DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), CacheConfiguration = new [] {new CacheConfiguration("aspNetCache") } }; 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.Cluster.Nodes().Count); }
public void FixtureSetUp() { var cfg = new IgniteConfiguration { DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), BinaryConfiguration = new BinaryConfiguration(typeof(Person)) }; Ignition.Start(cfg); }
public void TestAllConfigurationProperties() { var cfg = new IgniteConfiguration(GetCustomConfig()); using (var ignite = Ignition.Start(cfg)) { var resCfg = ignite.GetConfiguration(); var disco = (TcpDiscoverySpi) cfg.DiscoverySpi; var resDisco = (TcpDiscoverySpi) resCfg.DiscoverySpi; Assert.AreEqual(disco.NetworkTimeout, resDisco.NetworkTimeout); Assert.AreEqual(disco.AckTimeout, resDisco.AckTimeout); Assert.AreEqual(disco.MaxAckTimeout, resDisco.MaxAckTimeout); Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout); Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout); var ip = (TcpDiscoveryStaticIpFinder) disco.IpFinder; var resIp = (TcpDiscoveryStaticIpFinder) resDisco.IpFinder; // There can be extra IPv6 endpoints Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray()); Assert.AreEqual(cfg.GridName, resCfg.GridName); Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes); Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime); Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize); Assert.AreEqual(cfg.MetricsLogFrequency, resCfg.MetricsLogFrequency); Assert.AreEqual(cfg.MetricsUpdateFrequency, resCfg.MetricsUpdateFrequency); Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount); Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout); Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay); Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory); Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath); Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions); Assert.IsTrue(File.Exists(resCfg.JvmDllPath)); Assert.AreEqual(cfg.Localhost, resCfg.Localhost); Assert.AreEqual(cfg.IsDaemon, resCfg.IsDaemon); Assert.AreEqual(cfg.UserAttributes, resCfg.UserAttributes); var atm = cfg.AtomicConfiguration; var resAtm = resCfg.AtomicConfiguration; Assert.AreEqual(atm.AtomicSequenceReserveSize, resAtm.AtomicSequenceReserveSize); Assert.AreEqual(atm.Backups, resAtm.Backups); Assert.AreEqual(atm.CacheMode, resAtm.CacheMode); var tx = cfg.TransactionConfiguration; var resTx = resCfg.TransactionConfiguration; Assert.AreEqual(tx.DefaultTimeout, resTx.DefaultTimeout); Assert.AreEqual(tx.DefaultTransactionConcurrency, resTx.DefaultTransactionConcurrency); Assert.AreEqual(tx.DefaultTransactionIsolation, resTx.DefaultTransactionIsolation); Assert.AreEqual(tx.PessimisticTransactionLogLinger, resTx.PessimisticTransactionLogLinger); Assert.AreEqual(tx.PessimisticTransactionLogSize, resTx.PessimisticTransactionLogSize); } }
/// <summary> /// Deserializes <see cref="IgniteConfiguration"/> from specified <see cref="XmlReader"/>. /// </summary> /// <param name="reader">The reader.</param> /// <returns>Resulting <see cref="IgniteConfiguration"/>.</returns> public static IgniteConfiguration Deserialize(XmlReader reader) { IgniteArgumentCheck.NotNull(reader, "reader"); var cfg = new IgniteConfiguration(); if (reader.NodeType == XmlNodeType.Element || reader.Read()) ReadElement(reader, cfg); return cfg; }
/** <inheritdoc /> */ public override void TestSetUp() { base.TestSetUp(); // Start another node without spring config if (Ignition.TryGetIgnite("grid2") == null) { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) {GridName = "grid2"}; _ignite = Ignition.Start(cfg); } }
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 TestClusterRestart() { var serverCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { CacheConfiguration = new[] {new CacheConfiguration(CacheName)} }; var clientCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { GridName = "client", ClientMode = true }; var server = Ignition.Start(serverCfg); var client = Ignition.Start(clientCfg); ClientReconnectEventArgs eventArgs = null; client.ClientReconnected += (sender, args) => { eventArgs = args; }; var cache = client.GetCache<int, int>(CacheName); cache[1] = 1; Ignition.Stop(server.Name, true); var cacheEx = Assert.Throws<CacheException>(() => cache.Get(1)); var ex = cacheEx.InnerException as ClientDisconnectedException; Assert.IsNotNull(ex); // Start the server and wait for reconnect. Ignition.Start(serverCfg); Assert.IsTrue(ex.ClientReconnectTask.Result); // Check the event args. Thread.Sleep(1); // Wait for event handler Assert.IsNotNull(eventArgs); Assert.IsTrue(eventArgs.HasClusterRestarted); // Refresh the cache instance and check that it works. var cache1 = client.GetCache<int, int>(CacheName); Assert.AreEqual(0, cache1.GetSize()); cache1[1] = 2; Assert.AreEqual(2, cache1[1]); // Check that old cache instance does not work. var cacheEx1 = Assert.Throws<InvalidOperationException>(() => cache.Get(1)); Assert.AreEqual("Cache has been closed or destroyed: " + CacheName, cacheEx1.Message); }
public void TestStartWithConfigPath() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config/default-config.xml", JvmClasspath = TestUtils.CreateTestClasspath() }; var grid = Ignition.Start(cfg); Assert.IsNotNull(grid); Assert.AreEqual(1, grid.Cluster.Nodes().Count); }
public void TestDisabledSwapSpace() { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()); using (var ignite = Ignition.Start(cfg)) { // NoopSwapSpaceSpi is used by default. Assert.IsNull(ignite.GetConfiguration().SwapSpaceSpi); var ex = Assert.Throws<CacheException>( () => ignite.CreateCache<int, int>(new CacheConfiguration {EnableSwap = true})); Assert.IsTrue(ex.Message.EndsWith("has not swap SPI configured")); } }
/// <summary> /// Calculate Ignite home. /// </summary> /// <param name="cfg">Configuration.</param> /// <returns></returns> public static string Resolve(IgniteConfiguration cfg) { var home = cfg == null ? null : cfg.IgniteHome; if (string.IsNullOrWhiteSpace(home)) home = Environment.GetEnvironmentVariable(EnvIgniteHome); else if (!IsIgniteHome(new DirectoryInfo(home))) throw new IgniteException(string.Format("IgniteConfiguration.IgniteHome is not valid: '{0}'", home)); if (string.IsNullOrWhiteSpace(home)) home = Resolve(); else if (!IsIgniteHome(new DirectoryInfo(home))) throw new IgniteException(string.Format("{0} is not valid: '{1}'", EnvIgniteHome, home)); return home; }
public void TestSwapSpace() { const int entrySize = 1024; var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { SwapSpaceSpi = new FileSwapSpaceSpi { BaseDirectory = _tempDir, WriteBufferSize = 64 } }; using (var ignite = Ignition.Start(cfg)) { // Create cache with eviction and swap. var cache = ignite.CreateCache<int, byte[]>(new CacheConfiguration("cache") { EnableSwap = true, EvictionPolicy = new LruEvictionPolicy { MaxSize = 3 }, OffHeapMaxMemory = 5 * entrySize }); // Populate to trigger eviction. var data = Enumerable.Range(1, entrySize).Select(x => (byte) x).ToArray(); for (int i = 0; i < 10; i++) cache[i] = data; // Check that swap files exist. var files = Directory.GetFiles(_tempDir, "*.*", SearchOption.AllDirectories); CollectionAssert.IsNotEmpty(files); // Wait for metrics update and check metrics. Thread.Sleep(((TcpDiscoverySpi) ignite.GetConfiguration().DiscoverySpi).HeartbeatFrequency); var metrics = cache.GetLocalMetrics(); Assert.AreEqual(4, metrics.OffHeapEntriesCount); // Entry takes more space than the value Assert.AreEqual(3, metrics.SwapEntriesCount); // 10 - 3 - 4 = 3 Assert.AreEqual(3, metrics.OverflowSize / entrySize); Assert.AreEqual(metrics.SwapSize, metrics.OverflowSize); } }
public void TestCodeConfig() { var cfg = new IgniteConfiguration { DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), CacheConfiguration = new[] {new CacheConfiguration("testcache")} }; using (var ignite = Ignition.Start(cfg)) { var cache = ignite.GetCache<int, int>("testcache"); cache[1] = 5; Assert.AreEqual(5, cache[1]); } }
/// <summary> /// Creates classpath from the given configuration, or default classpath if given config is null. /// </summary> /// <param name="ggHome">The home dir.</param> /// <param name="cfg">The configuration.</param> /// <param name="forceTestClasspath">Append test directories even if /// <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param> /// <returns> /// Classpath string. /// </returns> internal static string CreateClasspath(string ggHome, IgniteConfiguration cfg, bool forceTestClasspath) { var cpStr = new StringBuilder(); if (cfg != null && cfg.JvmClasspath != null) { cpStr.Append(cfg.JvmClasspath); if (!cfg.JvmClasspath.EndsWith(";")) cpStr.Append(';'); } if (!string.IsNullOrWhiteSpace(ggHome)) AppendHomeClasspath(ggHome, forceTestClasspath, cpStr); return ClasspathPrefix + cpStr; }
public virtual void StartGrids() { TestUtils.KillProcesses(); IgniteConfiguration cfg = new IgniteConfiguration(); cfg.JvmClasspath = TestUtils.CreateTestClasspath(); cfg.JvmOptions = TestUtils.TestJavaOptions(); cfg.SpringConfigUrl = "config\\native-client-test-cache-affinity.xml"; for (int i = 0; i < 3; i++) { cfg.GridName = "grid-" + i; Ignition.Start(cfg); } }
public void FixtureSetUp() { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { CacheConfiguration = new[] { new CacheConfiguration(CacheName) { AffinityFunction = new SimpleAffinityFunction(), Backups = 7 } } }; _ignite = Ignition.Start(cfg); _ignite2 = Ignition.Start(new IgniteConfiguration(TestUtils.GetTestConfiguration()) {GridName = "grid2"}); }
public void TestQueryEntityConfiguration() { var cfg = new IgniteConfiguration { JvmOptions = TestUtils.TestJavaOptions(), JvmClasspath = TestUtils.CreateTestClasspath(), BinaryConfiguration = new BinaryConfiguration(typeof (QueryPerson)), CacheConfiguration = new[] { new CacheConfiguration(CacheName, new QueryEntity(typeof (int), typeof (QueryPerson)) { Fields = new[] { new QueryField("Name", typeof (string)), new QueryField("Age", typeof (int)) }, Indexes = new[] { new QueryIndex(false, QueryIndexType.FullText, "Name"), new QueryIndex("Age") } }) } }; using (var ignite = Ignition.Start(cfg)) { var cache = ignite.GetCache<int, QueryPerson>(CacheName); Assert.IsNotNull(cache); cache[1] = new QueryPerson("Arnold", 10); cache[2] = new QueryPerson("John", 20); using (var cursor = cache.Query(new SqlQuery(typeof (QueryPerson), "age > 10"))) { Assert.AreEqual(2, cursor.GetAll().Single().Key); } using (var cursor = cache.Query(new TextQuery(typeof (QueryPerson), "Ar*"))) { Assert.AreEqual(1, cursor.GetAll().Single().Key); } } }
public void TestIgniteStartup() { var cfg = new IgniteConfiguration { DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), Logger = new IgniteNLogLogger(LogManager.GetCurrentClassLogger()) }; using (Ignition.Start(cfg)) { Assert.IsTrue(_logTarget.Logs.Contains( string.Format("|Debug|Starting Ignite.NET {0}||", typeof(Ignition).Assembly.GetName().Version))); Assert.IsTrue(_logTarget.Logs.Any(x => x.Contains(">>> Topology snapshot."))); } Assert.IsTrue(_logTarget.Logs.Contains( "org.apache.ignite.internal.IgniteKernal|Debug|Grid is stopping.||")); }
public virtual void BeforeTests() { //TestUtils.JVM_DEBUG = true; TestUtils.KillProcesses(); TestUtils.JvmDebug = true; IgniteConfiguration cfg = new IgniteConfiguration { GridName = IgniteName, JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions(), SpringConfigUrl = @"config\cache\store\cache-store-session.xml" }; Ignition.Start(cfg); }
public void TestStartupPutGet() { var cfg = new IgniteConfiguration { DiscoverySpi = TestUtil.GetLocalDiscoverySpi(), GridName = "myGrid" }; // ReSharper disable once ObjectCreationAsStatement new IgniteDbConfiguration(cfg, new CacheConfiguration("efMetaCache") {AtomicityMode = CacheAtomicityMode.Transactional}, new CacheConfiguration("efDataCache"), null); var ignite = Ignition.GetIgnite(cfg.GridName); Assert.IsNotNull(ignite); Assert.IsNotNull(ignite.GetCache<string, object>("efMetaCache")); Assert.IsNotNull(ignite.GetCache<string, object>("efDataCache")); }
public void TestDisconnectedException() { var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\compute\\compute-grid1.xml", JvmClasspath = TestUtils.CreateTestClasspath(), JvmOptions = TestUtils.TestJavaOptions() }; var proc = StartServerProcess(cfg); Ignition.ClientMode = true; using (var ignite = Ignition.Start(cfg)) { Assert.IsTrue(ignite.GetCluster().ClientReconnectTask.IsCompleted); var cache = ignite.GetCache<int, int>(null); cache[1] = 1; // Suspend external process to cause disconnect proc.Suspend(); var ex = Assert.Throws<CacheException>(() => cache.Get(1)); var inner = (ClientDisconnectedException) ex.InnerException; var clientReconnectTask = inner.ClientReconnectTask; Assert.AreEqual(ignite.GetCluster().ClientReconnectTask, clientReconnectTask); // Resume process to reconnect proc.Resume(); clientReconnectTask.Wait(); Assert.AreEqual(1, cache[1]); } }
public void TestCacheCreationWithDirectQueryEntityMappingsDoesNotLogWarnings(Type type) { var cfg = new IgniteConfiguration(GetConfigWithLogger()) { CacheConfiguration = new[] { new CacheConfiguration("cache1", new QueryEntity(type, type) { Fields = new[] { new QueryField("myField", type) } }) } }; using (Ignition.Start(cfg)) { int warnsCount = TestLogger.Entries.Count(x => x.Level == LogLevel.Warn && x.Args != null); Assert.AreEqual(0, warnsCount); } }
public void TestInvalidConfiguration() { // Pass open generic type. var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { // Open generics are not allowed BinaryConfiguration = new BinaryConfiguration(typeof(List <>)) }; var ex = Assert.Throws <IgniteException>(() => Ignition.Start(cfg)); Assert.AreEqual("Failed to start Ignite.NET, check inner exception for details", ex.Message); Assert.IsNotNull(ex.InnerException); Assert.IsTrue(ex.InnerException.Message.StartsWith( "Open generic types (Type.IsGenericTypeDefinition == true) are not allowed in BinaryConfiguration: " + "System.Collections.Generic.List`1, mscorlib")); // Pass open generic type name. cfg.BinaryConfiguration = new BinaryConfiguration { Types = new[] { typeof(IList <>).AssemblyQualifiedName } }; ex = Assert.Throws <IgniteException>(() => Ignition.Start(cfg)); Assert.AreEqual("Failed to start Ignite.NET, check inner exception for details", ex.Message); Assert.IsNotNull(ex.InnerException); Assert.IsTrue(ex.InnerException.Message.StartsWith( "Open generic types (Type.IsGenericTypeDefinition == true) are not allowed in BinaryConfiguration: " + "System.Collections.Generic.IList`1, mscorlib")); // Pass interface. cfg.BinaryConfiguration = new BinaryConfiguration(typeof(ICollection)); ex = Assert.Throws <IgniteException>(() => Ignition.Start(cfg)); Assert.AreEqual("Failed to start Ignite.NET, check inner exception for details", ex.Message); Assert.IsNotNull(ex.InnerException); Assert.IsTrue(ex.InnerException.Message.StartsWith( "Abstract types and interfaces are not allowed in BinaryConfiguration: " + "System.Collections.ICollection, mscorlib")); }
public static void Main() { var cfg = new IgniteConfiguration { SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml", JvmOptions = new List <string> { "-Xms512m", "-Xmx1024m" } }; using (var ignite = Ignition.Start(cfg)) { Console.WriteLine(">>> Services example started."); Console.WriteLine(); // Deploy a service var svc = new MapService <int, string>(); Console.WriteLine(">>> Deploying service to all nodes..."); ignite.GetServices().DeployNodeSingleton("service", svc); // Get a sticky service proxy so that we will always be contacting the same remote node. 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 KeepWalsSeparately() { // tag::separate-wal[] var cfg = new IgniteConfiguration { DataStorageConfiguration = new DataStorageConfiguration { // Sets a path to the root directory where data and indexes are to be persisted. // It's assumed the directory is on a separated SSD. StoragePath = "/ssd/storage", // Sets a path to the directory where WAL is stored. // It's assumed the directory is on a separated HDD. WalPath = "/wal", // Sets a path to the directory where WAL archive is stored. // The directory is on the same HDD as the WAL. WalArchivePath = "/wal/archive" } }; // end::separate-wal[] }
public static void startCache() { IgniteConfiguration cfg = new IgniteConfiguration { BinaryConfiguration = new BinaryConfiguration(typeof(TestObject)) }; using (var ignite = Ignition.Start(cfg)) { var cacheCfg = new CacheConfiguration { ReadThrough = true, WriteThrough = true, KeepBinaryInStore = false, CacheStoreFactory = new OracleStoreFactory() }; var cache = ignite.CreateCache <int, TestObject>(cacheCfg); Console.WriteLine(cache.Get(1).ID + " " + cache.Get(1).NAME); // OracleStore.Load is called. } }
/// <summary> /// Constructor. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="name">Grid name.</param> /// <param name="proc">Interop processor.</param> /// <param name="marsh">Marshaller.</param> /// <param name="lifecycleBeans">Lifecycle beans.</param> /// <param name="cbs">Callbacks.</param> public Ignite(IgniteConfiguration cfg, string name, IUnmanagedTarget proc, Marshaller marsh, IList <LifecycleBeanHolder> lifecycleBeans, UnmanagedCallbacks cbs) { Debug.Assert(cfg != null); Debug.Assert(proc != null); Debug.Assert(marsh != null); Debug.Assert(lifecycleBeans != null); Debug.Assert(cbs != null); _cfg = cfg; _name = name; _proc = proc; _marsh = marsh; _lifecycleBeans = lifecycleBeans; _cbs = cbs; marsh.Ignite = this; _prj = new ClusterGroupImpl(proc, UU.ProcessorProjection(proc), marsh, this, null); _binary = new Binary.Binary(marsh); _binaryProc = new BinaryProcessor(UU.ProcessorBinaryProcessor(proc), marsh); _proxy = new IgniteProxy(this); cbs.Initialize(this); // Grid is not completely started here, can't initialize interop transactions right away. _transactions = new Lazy <TransactionsImpl>( () => new TransactionsImpl(UU.ProcessorTransactions(proc), marsh, GetLocalNode().Id)); // Set reconnected task to completed state for convenience. _clientReconnectTaskCompletionSource.SetResult(false); SetCompactFooter(); _pluginProcessor = new PluginProcessor(this); }
static void Main() { var cfg = new IgniteConfiguration { DataStorageConfiguration = new DataStorageConfiguration { DefaultDataRegionConfiguration = new DataRegionConfiguration { Name = "defaultRegion", InitialSize = 256 * 1024 * 1024, // 256 MB, MaxSize = 4L * 1024 * 1024 * 1025 // 4 GB }, DataRegionConfigurations = new[] { new DataRegionConfiguration { Name = "customRegion", InitialSize = 32 * 1024 * 1024, // 32 MB, MaxSize = 512 * 1024 * 1025 // 512 MB } } }, CacheConfiguration = new[] { new CacheConfiguration { Name = "cache1" // Use default region }, new CacheConfiguration { Name = "cache2", DataRegionName = "customRegion" } } }; Console.WriteLine("Done !!!"); Console.ReadLine(); }
public static void Configuration() { // tag::cfg[] var cfg = new IgniteConfiguration { DataStorageConfiguration = new DataStorageConfiguration { // tag::storage-path[] StoragePath = "/ssd/storage", // end::storage-path[] DefaultDataRegionConfiguration = new DataRegionConfiguration { Name = "Default_Region", PersistenceEnabled = true } } }; Ignition.Start(cfg); // end::cfg[] }
public void TestLoadFromGac() { Assert.False(IsLoaded("System.Data.Linq")); var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid3.xml", Assemblies = new List<string> { "System.Data.Linq,Culture=neutral,Version=1.0.0.0,PublicKeyToken=b77a5c561934e089" }, JvmClasspath = TestUtils.CreateTestClasspath() }; var grid = Ignition.Start(cfg); Assert.IsNotNull(grid); Assert.True(IsLoaded("System.Data.Linq")); }
static void Sample() { var cfg = new IgniteConfiguration { // Register custom class for Ignite serialization BinaryConfiguration = new BinaryConfiguration(typeof(Person)) }; IIgnite ignite = Ignition.Start(cfg); ICache <int, Person> cache = ignite.GetOrCreateCache <int, Person>("persons"); cache[1] = new Person { Name = "Micky Mouse", Age = 25 }; cache[2] = new Person { Name = "lmn", Age = 27 }; foreach (ICacheEntry <int, Person> cacheEntry in cache) { Console.WriteLine(cacheEntry); } }
public void TestAllConfigurationProperties() { var cfg = new IgniteConfiguration(GetCustomConfig()); using (var ignite = Ignition.Start(cfg)) { var resCfg = ignite.GetConfiguration(); var disco = (TcpDiscoverySpi) cfg.DiscoverySpi; var resDisco = (TcpDiscoverySpi) resCfg.DiscoverySpi; Assert.AreEqual(disco.NetworkTimeout, resDisco.NetworkTimeout); Assert.AreEqual(disco.AckTimeout, resDisco.AckTimeout); Assert.AreEqual(disco.MaxAckTimeout, resDisco.MaxAckTimeout); Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout); Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout); var ip = (TcpDiscoveryStaticIpFinder) disco.IpFinder; var resIp = (TcpDiscoveryStaticIpFinder) resDisco.IpFinder; // There can be extra IPv6 endpoints Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray()); Assert.AreEqual(cfg.GridName, resCfg.GridName); Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes); Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime); Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize); Assert.AreEqual(cfg.MetricsLogFrequency, resCfg.MetricsLogFrequency); Assert.AreEqual(cfg.MetricsUpdateFrequency, resCfg.MetricsUpdateFrequency); Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount); Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout); Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay); Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory); Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath); Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions); Assert.IsTrue(File.Exists(resCfg.JvmDllPath)); Assert.AreEqual(cfg.Localhost, resCfg.Localhost); } }
public void TestSpringXml() { // When Spring XML is used, .NET overrides Spring. var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { SpringConfigUrl = @"config\spring-test.xml", NetworkSendRetryDelay = TimeSpan.FromSeconds(45), MetricsHistorySize = 57 }; using (var ignite = Ignition.Start(cfg)) { var resCfg = ignite.GetConfiguration(); Assert.AreEqual(45, resCfg.NetworkSendRetryDelay.TotalSeconds); // .NET overrides XML Assert.AreEqual(2999, resCfg.NetworkTimeout.TotalMilliseconds); // Not set in .NET -> comes from XML Assert.AreEqual(57, resCfg.MetricsHistorySize); // Only set in .NET var disco = resCfg.DiscoverySpi as TcpDiscoverySpi; Assert.IsNotNull(disco); Assert.AreEqual(TimeSpan.FromMilliseconds(300), disco.SocketTimeout); // Check memory configuration defaults. var mem = resCfg.MemoryConfiguration; Assert.IsNotNull(mem); Assert.AreEqual("dfltPlc", mem.DefaultMemoryPolicyName); Assert.AreEqual(MemoryConfiguration.DefaultPageSize, mem.PageSize); Assert.AreEqual(MemoryConfiguration.DefaultSystemCacheInitialSize, mem.SystemCacheInitialSize); Assert.AreEqual(MemoryConfiguration.DefaultSystemCacheMaxSize, mem.SystemCacheMaxSize); var plc = mem.MemoryPolicies.Single(); Assert.AreEqual("dfltPlc", plc.Name); Assert.AreEqual(MemoryPolicyConfiguration.DefaultEmptyPagesPoolSize, plc.EmptyPagesPoolSize); Assert.AreEqual(MemoryPolicyConfiguration.DefaultEvictionThreshold, plc.EvictionThreshold); Assert.AreEqual(MemoryPolicyConfiguration.DefaultInitialSize, plc.InitialSize); Assert.AreEqual(MemoryPolicyConfiguration.DefaultMaxSize, plc.MaxSize); } }
public static void ConfigurationExample() { // tag::cfg[] var cfg = new IgniteConfiguration { CacheConfiguration = new[] { new CacheConfiguration { Name = "myCache", CacheMode = CacheMode.Partitioned, Backups = 2, RebalanceMode = CacheRebalanceMode.Sync, WriteSynchronizationMode = CacheWriteSynchronizationMode.FullSync, PartitionLossPolicy = PartitionLossPolicy.ReadOnlySafe } } }; Ignition.Start(cfg); // end::cfg[] }
public void TestJavaInterop() { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { BinaryConfiguration = new BinaryConfiguration { NameMapper = BinaryBasicNameMapper.SimpleNameInstance } }; using (var ignite = Ignition.Start(cfg)) { var cacheCfg = new CacheConfiguration("default", new QueryEntity(typeof(PlatformComputeBinarizable)) { Fields = new[] { new QueryField("Field", typeof(int)) } }); var cache = ignite.CreateCache <int, object>(cacheCfg); // Force dynamic registration for .NET cache.Put(-1, new PlatformComputeBinarizable { Field = 7 }); cache.Put(ComputeApiTest.EchoTypeBinarizable, 255); // Run Java code that will also perform dynamic registration var fromJava = ignite.GetCompute().ExecuteJavaTask <PlatformComputeBinarizable>(ComputeApiTest.EchoTask, ComputeApiTest.EchoTypeBinarizable); // Check that objects are compatible Assert.AreEqual(255, fromJava.Field); // Check that Java can read what .NET has put var qryRes = ignite.GetCompute().ExecuteJavaTask <IList>( BinaryCompactFooterInteropTest.PlatformSqlQueryTask, "Field = 7"); Assert.AreEqual(7, qryRes.OfType <PlatformComputeBinarizable>().Single().Field); } }
public void TestTwoGrids([Values(false, true)] bool clientMode) { using (var ignite1 = Ignition.Start(TestUtils.GetTestConfiguration())) { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { IgniteInstanceName = "grid2", ClientMode = clientMode }; using (var ignite2 = Ignition.Start(cfg)) { Test(ignite1, ignite2); } // Test twice to verify double registration. using (var ignite2 = Ignition.Start(cfg)) { Test(ignite1, ignite2); } } }
public void TestLoadFromGac() { Assert.False(IsLoaded("System.Data.Linq")); var cfg = new IgniteConfiguration { SpringConfigUrl = "config\\start-test-grid3.xml", Assemblies = new List <string> { "System.Data.Linq,Culture=neutral,Version=1.0.0.0,PublicKeyToken=b77a5c561934e089" }, JvmClasspath = TestUtils.CreateTestClasspath() }; var grid = Ignition.Start(cfg); Assert.IsNotNull(grid); Assert.True(IsLoaded("System.Data.Linq")); }
public void TestClientNodeReconnectWithoutClusterRestartKeepsNearCache() { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { CommunicationSpi = new TcpCommunicationSpi { IdleConnectionTimeout = TimeSpan.FromSeconds(2) }, FailureDetectionTimeout = TimeSpan.FromSeconds(2), ClientFailureDetectionTimeout = TimeSpan.FromSeconds(2), IgniteInstanceName = "srv" }; var server = Ignition.Start(cfg); var serverCache = server.CreateCache <int, Foo>(new CacheConfiguration(CacheName) { PlatformNearConfiguration = new PlatformNearCacheConfiguration() }); var clientCfg = new IgniteConfiguration(cfg) { ClientMode = true, IgniteInstanceName = "client" }; var client = Ignition.Start(clientCfg); var clientCache = client.GetOrCreateNearCache <int, Foo>(CacheName, new NearCacheConfiguration()); clientCache[1] = new Foo(2); Assert.AreEqual(2, clientCache.LocalPeek(1, CachePeekMode.PlatformNear).Bar); PerformClientReconnect(client); // Near cache data is removed after disconnect. Assert.AreEqual(0, clientCache.GetLocalSize(CachePeekMode.PlatformNear)); // Updates work as expected. Assert.AreEqual(2, clientCache[1].Bar); serverCache[1] = new Foo(33); TestUtils.WaitForTrueCondition(() => 33 == clientCache.LocalPeek(1, CachePeekMode.PlatformNear).Bar); }
public static void Main() { var cfg = new IgniteConfiguration { SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml", JvmOptions = new List <string> { "-Xms512m", "-Xmx1024m" } }; using (var ignite = Ignition.Start(cfg)) { Console.WriteLine(); Console.WriteLine(">>> Closure execution example started."); // Split the string by spaces to count letters in each word in parallel. 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 static void AffinityRunDemo() { var cfg = new IgniteConfiguration(); // end::affinityRun[] var discoverySpi = new TcpDiscoverySpi { LocalPort = 48500, LocalPortRange = 20, IpFinder = new TcpDiscoveryStaticIpFinder { Endpoints = new[] { "127.0.0.1:48500..48520" } } }; cfg.DiscoverySpi = discoverySpi; // tag::affinityRun[] var ignite = Ignition.Start(cfg); var cache = ignite.GetOrCreateCache <int, string>("myCache"); cache.Put(0, "foo"); cache.Put(1, "bar"); cache.Put(2, "baz"); var keyCnt = 3; var compute = ignite.GetCompute(); for (var key = 0; key < keyCnt; key++) { // This closure will execute on the remote node where // data for the given 'key' is located. compute.AffinityRun("myCache", key, new MyComputeAction { Key = key }); } }
public void TestIgniteStartsFromSpringXml() { // When Spring XML is used, .NET overrides Spring. var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { DataStorageConfiguration = null, SpringConfigUrl = @"Config\spring-test.xml", NetworkSendRetryDelay = TimeSpan.FromSeconds(45), MetricsHistorySize = 57 }; using (var ignite = Ignition.Start(cfg)) { var resCfg = ignite.GetConfiguration(); Assert.AreEqual(45, resCfg.NetworkSendRetryDelay.TotalSeconds); // .NET overrides XML Assert.AreEqual(2999, resCfg.NetworkTimeout.TotalMilliseconds); // Not set in .NET -> comes from XML Assert.AreEqual(57, resCfg.MetricsHistorySize); // Only set in .NET var disco = resCfg.DiscoverySpi as TcpDiscoverySpi; Assert.IsNotNull(disco); Assert.AreEqual(TimeSpan.FromMilliseconds(300), disco.SocketTimeout); // DataStorage defaults. var dsCfg = new DataStorageConfiguration { DefaultDataRegionConfiguration = new DataRegionConfiguration { Name = "default" }, SystemDataRegionConfiguration = new SystemDataRegionConfiguration() }; AssertExtensions.ReflectionEqual(dsCfg, resCfg.DataStorageConfiguration, ignoredProperties: new HashSet <string> { "MaxSize" }); } }
public void TestAllConfigurationProperties() { var cfg = new IgniteConfiguration(GetCustomConfig()); using (var ignite = Ignition.Start(cfg)) { var resCfg = ignite.GetConfiguration(); var disco = (TcpDiscoverySpi)cfg.DiscoverySpi; var resDisco = (TcpDiscoverySpi)resCfg.DiscoverySpi; Assert.AreEqual(disco.NetworkTimeout, resDisco.NetworkTimeout); Assert.AreEqual(disco.AckTimeout, resDisco.AckTimeout); Assert.AreEqual(disco.MaxAckTimeout, resDisco.MaxAckTimeout); Assert.AreEqual(disco.SocketTimeout, resDisco.SocketTimeout); Assert.AreEqual(disco.JoinTimeout, resDisco.JoinTimeout); var ip = (TcpDiscoveryStaticIpFinder)disco.IpFinder; var resIp = (TcpDiscoveryStaticIpFinder)resDisco.IpFinder; // There can be extra IPv6 endpoints Assert.AreEqual(ip.Endpoints, resIp.Endpoints.Take(2).Select(x => x.Trim('/')).ToArray()); Assert.AreEqual(cfg.GridName, resCfg.GridName); Assert.AreEqual(cfg.IncludedEventTypes, resCfg.IncludedEventTypes); Assert.AreEqual(cfg.MetricsExpireTime, resCfg.MetricsExpireTime); Assert.AreEqual(cfg.MetricsHistorySize, resCfg.MetricsHistorySize); Assert.AreEqual(cfg.MetricsLogFrequency, resCfg.MetricsLogFrequency); Assert.AreEqual(cfg.MetricsUpdateFrequency, resCfg.MetricsUpdateFrequency); Assert.AreEqual(cfg.NetworkSendRetryCount, resCfg.NetworkSendRetryCount); Assert.AreEqual(cfg.NetworkTimeout, resCfg.NetworkTimeout); Assert.AreEqual(cfg.NetworkSendRetryDelay, resCfg.NetworkSendRetryDelay); Assert.AreEqual(cfg.WorkDirectory, resCfg.WorkDirectory); Assert.AreEqual(cfg.JvmClasspath, resCfg.JvmClasspath); Assert.AreEqual(cfg.JvmOptions, resCfg.JvmOptions); Assert.IsTrue(File.Exists(resCfg.JvmDllPath)); Assert.AreEqual(cfg.Localhost, resCfg.Localhost); } }
/// <summary> /// Gets the config. /// </summary> private static IgniteConfiguration GetConfig(bool client, bool customMapper, string name = null) { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { ClientMode = client, IgniteInstanceName = name }; if (customMapper) { cfg.BinaryConfiguration = new BinaryConfiguration { NameMapper = new BinaryBasicNameMapper { NamespaceToLower = true, NamespacePrefix = "foo.bar." } }; } return(cfg); }
public void FixtureSetUp() { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { BinaryConfiguration = new BinaryConfiguration(typeof(Foo)) { TypeConfigurations = { new BinaryTypeConfiguration(typeof(Key)) { EqualityComparer = new BinaryArrayEqualityComparer() }, new BinaryTypeConfiguration(typeof(Key2)) { EqualityComparer = new BinaryFieldEqualityComparer("Hi", "Lo") } } } }; Ignition.Start(cfg); }
public void FixtureSetUp() { var cfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { CacheConfiguration = new List <CacheConfiguration> { new CacheConfiguration(DefaultCacheName), GetCustomCacheConfiguration(), GetCustomCacheConfiguration2() }, IgniteInstanceName = CacheName, BinaryConfiguration = new BinaryConfiguration(typeof(Entity)), #pragma warning disable 618 MemoryConfiguration = new MemoryConfiguration { MemoryPolicies = new[] { new MemoryPolicyConfiguration { Name = "myMemPolicy", InitialSize = 77 * 1024 * 1024, MaxSize = 99 * 1024 * 1024 }, new MemoryPolicyConfiguration { Name = MemoryConfiguration.DefaultDefaultMemoryPolicyName, InitialSize = 55 * 1024 * 1024, MaxSize = 88 * 1024 * 1024 } } }, #pragma warning restore 618 DataStorageConfiguration = null, SpringConfigUrl = Path.Combine("Config", "cache-default.xml") }; _ignite = Ignition.Start(cfg); }
static void Main(string[] args) { Random r = new Random(); int biggest = Int32.MinValue; var dtgrd = new IgniteConfiguration { BinaryConfiguration = new BinaryConfiguration(typeof(CountFunc)), ClientMode = true }; using (var ignite = Ignition.Start(dtgrd)) { int n = 5; int m = 5; int[][] mas = new int[n][]; for (int i = 0; i < n; i++) { mas[i] = new int[m]; for (int j = 0; j < m; j++) { mas[i][j] = r.Next(0, 10); Console.Write(mas[i][j] + " "); } Console.WriteLine(); } var res = ignite.GetCompute().Apply(new CountFunc(), mas); foreach (var ul in res) { if (ul > biggest) { biggest = ul; } } Console.WriteLine("Самый большой элемент строки: " + biggest); Console.Read(); } }
public static void LocalListenDemo() { var cfg = new IgniteConfiguration { IncludedEventTypes = new[] { EventType.CacheObjectPut, EventType.CacheObjectRead, EventType.CacheObjectRemoved, } }; //end::localListen[] var discoverySpi = new TcpDiscoverySpi { LocalPort = 48500, LocalPortRange = 20, IpFinder = new TcpDiscoveryStaticIpFinder { Endpoints = new[] { "127.0.0.1:48500..48520" } } }; cfg.DiscoverySpi = discoverySpi; // tag::localListen[] var ignite = Ignition.Start(cfg); var events = ignite.GetEvents(); events.LocalListen(new LocalListener(), EventType.CacheObjectPut, EventType.CacheObjectRead, EventType.CacheObjectRemoved); var cache = ignite.GetOrCreateCache <int, int>("myCache"); cache.Put(1, 1); cache.Put(2, 2); }
/// <summary> /// Create JVM. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="log">Logger</param> /// <returns>Callback context.</returns> internal static UnmanagedCallbacks CreateJvmContext(IgniteConfiguration cfg, ILogger log) { lock (SyncRoot) { // 1. Warn about possible configuration inconsistency. JvmConfiguration jvmCfg = JvmConfig(cfg); if (!cfg.SuppressWarnings && _jvmCfg != null) { if (!_jvmCfg.Equals(jvmCfg)) { log.Warn("Attempting to start Ignite node with different Java " + "configuration; current Java configuration will be ignored (consider " + "starting node in separate process) [oldConfig=" + _jvmCfg + ", newConfig=" + jvmCfg + ']'); } } // 2. Create unmanaged pointer. var jvm = CreateJvm(cfg, log); if (cfg.RedirectJavaConsoleOutput) { jvm.EnableJavaConsoleWriter(); } var cbs = new UnmanagedCallbacks(log, jvm); jvm.RegisterCallbacks(cbs); // 3. If this is the first JVM created, preserve configuration. if (_jvmCfg == null) { _jvmCfg = jvmCfg; } return(cbs); } }
static void Main(string[] args) { var cfg = new IgniteConfiguration { BinaryConfiguration = new BinaryConfiguration(typeof(Person), typeof(Organization)) }; IIgnite ignite = Ignition.Start(cfg); Environment.SetEnvironmentVariable("IGNITE_H2_DEBUG_CONSOLE", "true"); ICache <int, Person> personCache = ignite.GetOrCreateCache <int, Person>(new CacheConfiguration("persons", typeof(Person))); var OrgCache = ignite.GetOrCreateCache <int, Organization>(new CacheConfiguration("orgs", typeof(Organization))); personCache[1] = new Person { Name = "Stan", Age = 55, OrgId = 2 }; personCache[2] = new Person { Name = "Mike", Age = 54, OrgId = 1 }; personCache[3] = new Person { Name = "Oprah", Age = 22, OrgId = 2 }; OrgCache[1] = new Organization { Name = "Asha Foundation", Id = 2 }; OrgCache[2] = new Organization { Name = "Okla Foundation", Id = 1 }; var fieldsQuery = new SqlFieldsQuery("select Person.Name from Person " + "join \"orgs\".Organization as org on (Person.OrgId = org.Id) " + "where org.Name = ?", "Asha Foundation"); foreach (var fieldList in personCache.QueryFields(fieldsQuery)) { Console.WriteLine(fieldList[0]); } }
public IIgnite Launch() { var jvmDllPath = GetJvmDllPath(); if (!File.Exists(jvmDllPath)) { throw new FileNotFoundException("Jvm not found", jvmDllPath); } var configuration = new IgniteConfiguration() { ClientMode = false, JvmInitialMemoryMb = 512, JvmMaxMemoryMb = 8192, MetricsLogFrequency = TimeSpan.Zero, JvmDllPath = jvmDllPath, JvmClasspath = GetJvmClassPath(), JvmOptions = new List <string>() { }, Logger = new IgniteLogger(logger, minLogLevel), LifecycleHandlers = new List <ILifecycleHandler>() { }, DataStorageConfiguration = new DataStorageConfiguration() { DataRegionConfigurations = new List <DataRegionConfiguration>(IgniteDataRegions.All), StoragePath = GetDirectory(true, "Data", "Storage") }, WorkDirectory = GetDirectory(true, "Data", "Work") }; var result = Ignition.Start(configuration); result.GetCluster().SetActive(true); return(result); }
public static void Main() { Console.WriteLine(); Console.WriteLine(">>> Lifecycle example started."); // Create new configuration. var lifecycleExampleBean = new LifecycleExampleBean(); var cfg = new IgniteConfiguration { DiscoverySpi = new TcpDiscoverySpi { IpFinder = new TcpDiscoveryStaticIpFinder { Endpoints = new[] { "127.0.0.1:47500" } } }, LifecycleBeans = new List <ILifecycleBean> { lifecycleExampleBean } }; // Provide lifecycle bean to configuration. using (Ignition.Start(cfg)) { // Make sure that lifecycle bean was notified about Ignite startup. Console.WriteLine(); Console.WriteLine(">>> Started (should be true): " + lifecycleExampleBean.Started); } // Make sure that lifecycle bean was notified about Ignite stop. Console.WriteLine(); Console.WriteLine(">>> Started (should be false): " + lifecycleExampleBean.Started); Console.WriteLine(); Console.WriteLine(">>> Example finished, press any key to exit ..."); Console.ReadKey(); }
public void StartTRexGridCacheNode() { var cfg = new IgniteConfiguration(); ConfigureTRexGrid(cfg); _log.LogInformation($"Creating new Ignite node for {cfg.IgniteInstanceName}"); try { mutableTRexGrid = DIContext.Obtain <ITRexGridFactory>()?.Grid(TRexGrids.MutableGridName(), cfg); } finally { _log.LogInformation($"Completed creation of new Ignite node: Exists = {mutableTRexGrid != null}, Factory available = {DIContext.Obtain<ITRexGridFactory>() != null}"); } // Wait until the grid is active DIContext.Obtain <IActivatePersistentGridServer>().WaitUntilGridActive(TRexGrids.MutableGridName()); // Add the mutable Spatial & NonSpatial caches InstantiateNonSpatialCacheReference(); InstantiateSpatialSubGridDirectoryCacheReference(); InstantiateSpatialSubGridSegmentCacheReference(); InstantiateTAGFileBufferQueueCacheReference(); InstantiateSiteModelExistenceMapsCacheReference(); InstantiateSiteModelsCacheReference(); InstantiateRebuildSiteModelCacheReferences(); InstantiateDesignTopologyExistenceMapsCache(); // Create the SiteModel MetaData Manager so later DI context references wont need to create the cache etc for it at an inappropriate time var _ = DIContext.Obtain <ISiteModelMetadataManager>(); }
public static void Main() { var cfg = new IgniteConfiguration { SpringConfigUrl = @"platforms\dotnet\examples\config\example-compute.xml", JvmOptions = new List <string> { "-Xms512m", "-Xmx1024m" } }; using (var ignite = Ignition.Start(cfg)) { 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(); }
/// <summary> /// Creates classpath from the given configuration, or default classpath if given config is null. /// </summary> /// <param name="cfg">The configuration.</param> /// <param name="forceTestClasspath">Append test directories even if /// <see cref="EnvIgniteNativeTestClasspath" /> is not set.</param> /// <param name="log">The log.</param> /// <returns> /// Classpath string. /// </returns> internal static string CreateClasspath(IgniteConfiguration cfg = null, bool forceTestClasspath = false, ILogger log = null) { var cpStr = new StringBuilder(); if (cfg != null && cfg.JvmClasspath != null) { cpStr.Append(cfg.JvmClasspath); if (!cfg.JvmClasspath.EndsWith(";")) cpStr.Append(';'); } var ggHome = IgniteHome.Resolve(cfg, log); if (!string.IsNullOrWhiteSpace(ggHome)) AppendHomeClasspath(ggHome, forceTestClasspath, cpStr); if (log != null) log.Debug("Classpath resolved to: " + cpStr); return ClasspathPrefix + cpStr; }
public void TestNoCacheNode() { const string cacheName = "cache"; var cacheNodeCfg = new IgniteConfiguration(TestUtils.GetTestConfiguration()) { SpringConfigUrl = @"Config\cache-local-node.xml", GridName = "cacheGrid" }; using (var gridNoCache = Ignition.Start(TestUtils.GetTestConfiguration())) { Assert.Throws<ArgumentException>(() => gridNoCache.GetCache<int, int>(cacheName)); var gridWithCache = Ignition.Start(cacheNodeCfg); var streamer = gridNoCache.GetDataStreamer<int, int>(cacheName); streamer.AddData(1, 2); streamer.Flush(); Ignition.Stop(gridWithCache.Name, true); Thread.Sleep(500); // Wait for node to stop var task = streamer.AddData(2, 3); streamer.Flush(); var ex = Assert.Throws<AggregateException>(task.Wait).InnerException; Assert.IsNotNull(ex); Assert.AreEqual("Java exception occurred [class=org.apache.ignite.cache." + "CacheServerNotFoundException, message=Failed to find server node for cache " + "(all affinity nodes have left the grid or cache was stopped): cache]", ex.Message); } }
/// <summary> /// Calculate Ignite home. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="log">The log.</param> public static string Resolve(IgniteConfiguration cfg, ILogger log = null) { var home = cfg == null ? null : cfg.IgniteHome; if (string.IsNullOrWhiteSpace(home)) { home = Environment.GetEnvironmentVariable(EnvIgniteHome); if (log != null) log.Debug("IgniteHome retrieved from {0} environment variable: '{1}'", EnvIgniteHome, home); } else if (!IsIgniteHome(new DirectoryInfo(home))) throw new IgniteException(string.Format("IgniteConfiguration.IgniteHome is not valid: '{0}'", home)); if (string.IsNullOrWhiteSpace(home)) home = Resolve(log); else if (!IsIgniteHome(new DirectoryInfo(home))) throw new IgniteException(string.Format("{0} is not valid: '{1}'", EnvIgniteHome, home)); if (log != null) log.Debug("IgniteHome resolved to '{0}'", home); return home; }