Understanding Configuration
This chapter explains different ways of configuring a GridGain cluster.
Overview
When you start a GridGain node, you need to provide configuration parameters to the node. Basically, all configuration parameters are defined in an instance of the IgniteConfiguration class. You can set the parameters either programmatically or via an XML configuration file. These 2 ways are fully interchangeable.
The XML configuration file is a Spring Bean definition file that must contain the IgniteConfiguration
bean.
When starting a node from the command line, pass the configuration file as a parameter to the ignite.sh|bat
script, as follows:
ignite.sh ignite-config.xml
If you don’t specify a configuration file, the default file {GRIDGAIN_HOME}/config/default-config.xml
is used.
Spring XML Configuration
To create a configuration in a Spring XML format, you need to define the
IgniteConfiguration
bean and set the parameters that you want to be different from the default. For detailed information on how to use XML Schema-based configuration, see the
official
Spring documentation.
In the example below, we create an IgniteConfiguration
bean, set the workDirectory
property, and configure a partitioned cache.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="workDirectory" value="/path/to/work/directory"/>
<property name="cacheConfiguration">
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<!-- Set the cache name. -->
<property name="name" value="myCache"/>
<!-- Set the cache mode. -->
<property name="cacheMode" value="PARTITIONED"/>
<!-- Other cache parameters. -->
</bean>
</property>
</bean>
</beans>
Programmatic Configuration
Create an instance of the IgniteConfiguration
class and set the required
parameters, as shown in the example below.
IgniteConfiguration igniteCfg = new IgniteConfiguration();
//setting the work directory
igniteCfg.setWorkDirectory("/path/to/work/directory");
//defining a partitioned cache
CacheConfiguration cacheCfg = new CacheConfiguration("myCache");
cacheCfg.setCacheMode(CacheMode.PARTITIONED);
igniteCfg.setCacheConfiguration(cacheCfg);
See the IgniteConfiguration javadoc for the complete list of parameters.
var igniteCfg = new IgniteConfiguration
{
WorkDirectory = "/path/to/work/directory",
CacheConfiguration = new[]
{
new CacheConfiguration
{
Name = "myCache",
CacheMode = CacheMode.Partitioned
}
}
};
See the API docs for details.
IgniteConfiguration cfg;
cfg.igniteHome = "/path/to/work/directory";
© 2024 GridGain Systems, Inc. All Rights Reserved. Privacy Policy | Legal Notices. GridGain® is a registered trademark of GridGain Systems, Inc.
Apache, Apache Ignite, the Apache feather and the Apache Ignite logo are either registered trademarks or trademarks of The Apache Software Foundation.