Flying Dutchman
Flying Dutchman

Reputation: 145

How to attach/connect to exising Ignite node

Getting a "Failed to get default Ignite instance: there are no instances started." when trying to connect (using Ignition.GetIgnite()).

More Information:

I am trying to use Apache Ignite as my in-memory database. My plan is to start the Ignite instance in a server and then make the application connect to that. I started apache ignite from commmand line with the default configuration

    ignite.bat   

Then, from my .NET application, I tried to GetIgnite so it would connect/attach the existing ignite node, since both were in my local machine.

    var ignite = Ignition.GetIgnite();

This is the configuration I have in web.config

    <configSections>
<section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
 </configSections>
 <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection"
                    localhost="127.0.0.1" peerAssemblyLoadingMode="CurrentAppDomain">
   <atomicConfiguration atomicSequenceReserveSize="10" />
 </igniteConfiguration>

Working Version: I could start "Ignite" from within the application and perform in-memory database operations like caching data with different ICache and later join to retrieve data. But this version will not be scaleable.

     //for some reason I have to set the environment variable like this
     Environment.SetEnvironmentVariable("IGNITE_HOME", "C:\\test\app\\packages\\Apache.Ignite.2.4.0\\");
     // Start Ignite and retrieve cache
     _ignite = Ignition.StartFromApplicationConfiguration();

     CacheConfiguration config = new CacheConfiguration("MyProduct", typeof(MyProduct));
     config.CacheMode = CacheMode.Local;
     ICache productList = _ignite.GetOrCreateCache<string, MyProduct>
                                    (config);

Upvotes: 0

Views: 490

Answers (1)

alamar
alamar

Reputation: 19313

You should start an Ignite Client node in your process to be able to connect to Ignite cluster, even if "cluster" is one node on the same machine.

Copy the configuration, set clientMode to true, start it with Ignition.start().

Upvotes: 2

Related Questions