Configuration

Configuring Apache Ignite.NET nodes

Ignite.NET nodes can be configured in a variety of ways which are represented by a set of Ignition.Start* methods.

C# code

Use Ignition.Start(IgniteConfiguration) method to configure Ignite.NET entirely in C# code.

Ignition.Start(new IgniteConfiguration
{
    DiscoverySpi = new TcpDiscoverySpi
    {
        IpFinder = new TcpDiscoveryStaticIpFinder
        {
            Endpoints = new[] {"127.0.0.1:47500..47509"}
        },
        SocketTimeout = TimeSpan.FromSeconds(0.3)
    },
    IncludedEventTypes = EventType.CacheAll,
    JvmOptions = new[] { "-Xms1024m", "-Xmx1024m" }
});

app.config & web.config

Ignition.StartFromApplicationConfiguration methods read configuration from Apache.Ignite.Core.IgniteConfigurationSection in app.config or web.config files.

IgniteConfigurationSection.xsd schema file can be found next to Apache.Ignite.Core.dll in the binary distribution, and in Apache.Ignite.Schema NuGet package. Include it in your project with None build action to enable IntelliSense in Visual Studio while editing IgniteConfigurationSection in the config files.

📘

To add IgniteConfigurationSection.xsd schema file to a Visual Studio project go to Projects menu and click on Add Existing Item... menu item. After that locate IgniteConfigurationSection.xsd inside of Apache Ignite distribution and pick it up.

Alternatively, install NuGet package: Install-Package Apache.Ignite.Schema. This will add xsd file to the project automatically.

To improve editing, make sure that Statement Completion options are enabled in Tools - Options - Text Editor - XML.

<?xml version="1.0" encoding="utf-8"?>

<configuration>
    <configSections>
        <section name="igniteConfiguration" type="Apache.Ignite.Core.IgniteConfigurationSection, Apache.Ignite.Core" />
    </configSections>

    <runtime>
        <gcServer enabled="true"/>
    </runtime>

    <igniteConfiguration xmlns="http://ignite.apache.org/schema/dotnet/IgniteConfigurationSection" gridName="myGrid1">
        <discoverySpi type="TcpDiscoverySpi">
            <ipFinder type="TcpDiscoveryStaticIpFinder">
                <endpoints>
                    <string>127.0.0.1:47500..47509</string>
                </endpoints>
            </ipFinder>
        </discoverySpi>
        
        <cacheConfiguration>
            <cacheConfiguration cacheMode='Replicated' readThrough='true' writeThrough='true' />
            <cacheConfiguration name='secondCache' />
        </cacheConfiguration>
        
        <includedEventTypes>
            <int>42</int>
            <int>TaskFailed</int>
            <int>JobFinished</int>
        </includedEventTypes>
        
        <userAttributes>
            <pair key='myNode' value='true' />
        </userAttributes>
      
        <JvmOptions>
          <string>-Xms1024m</string>
          <string>-Xmx1024m</string>
        </JvmOptions>
    </igniteConfiguration>
</configuration>
var ignite = Ignition.StartFromApplicationConfiguration("igniteConfiguration");

Ignite Configuration Section syntax

Configuration section maps directly to IgniteConfiguration class:

  • Simple properties (strings, primitives, enums) map to XML attributes (attribute name = camelCased C# property name).
  • Complex properties map to nested XML elements (element name = camelCased C# property name).
  • When a complex property is an interface or abstract class, type attribute is used to specify the type, using assembly-qualified name. For built-in types (like TcpDiscoverySpi in the code sample above) assembly name and namespace can be omitted.
  • When in doubt, consult the schema in IgniteConfigurationSection.xsd.

Spring XML

Spring XML allows native java-based Ignite configuration. Spring config file can be provided via Ignition.Start(string) method and IgniteConfiguration.SpringConfigUrl property.

When IgniteConfiguration.SpringConfigUrl property is used, Spring config is loaded first, and other IgniteConfiguration properties are applied on top of it. This is useful when some Java property is not supported in Ignite.NET directly.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:util="http://www.springframework.org/schema/util"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/util
                           http://www.springframework.org/schema/util/spring-util.xsd">
    <bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="localHost" value="127.0.0.1"/>
        <property name="gridName" value="grid1"/>
        <property name="userAttributes">
            <map>
                <entry key="my_attr" value="value1"/>
            </map>
        </property>

        <property name="cacheConfiguration">
            <list>
                <bean class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="cache1"/>
                    <property name="startSize" value="10"/>
                </bean>
            </list>
        </property>

        <property name="discoverySpi">
            <bean class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                    <bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder">
                        <property name="addresses">
                            <list>
                                <value>127.0.0.1:47500..47509</value>
                            </list>
                        </property>
                    </bean>
                </property>
                <property name="socketTimeout" value="300" />
            </bean>
        </property>
    </bean>
</beans>
var ignite = Ignition.Start("spring-config.xml");