blob: 6bd6d7858c9b2c0eec9bec5bf271cba6b030da8c [file] [log] [blame]
// Licensed to the Apache Software Foundation (ASF) under one or more
// contributor license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// The ASF licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
= Understanding Configuration
This chapter explains different ways of setting configuration parameters in an Ignite cluster. The chapter covers the most
ubiquitous approaches for Java and C++ applications.
[NOTE]
====
[discrete]
=== Configuring .NET, Python, Node.JS and other programming languages
* .NET developers: refer to the link:net-specific/net-configuration-options[Ignite.NET Configuration] section
* Developers of Python, Node.JS, and other programming languages: use this page to configure your
Java-powered Ignite cluster and link:thin-clients/getting-started-with-thin-clients[thin clients] section to set up
your language-specific applications that will be working with the cluster.
====
== Overview
You can specify custom configuration parameters by providing an instance of the javadoc:org.apache.ignite.configuration.IgniteConfiguration[] class to Ignite when starting the node.
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:
[source,shell]
----
ignite.sh ignite-config.xml
----
If you don't specify a configuration file, the default file `{IGNITE_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
https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/xsd-configuration.html[official
Spring documentation].
In the example below, we create an `IgniteConfiguration` bean, set the `workDirectory` property, and configure a link:data-modeling/data-partitioning#partitioned[partitioned cache].
[source,xml]
----
<?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.
[tabs]
--
tab:Java[]
[source,java]
----
include::{javaCodeDir}/UnderstandingConfiguration.java[tag=cfg,indent=0]
----
See the link:{javadoc_base_url}/org/apache/ignite/configuration/IgniteConfiguration.html[IgniteConfiguration,window=_blank] javadoc for the complete list of parameters.
tab:C#/.NET[]
[source,csharp]
----
include::code-snippets/dotnet/UnderstandingConfiguration.cs[tag=UnderstandingConfigurationProgrammatic,indent=0]
----
See the https://ignite.apache.org/releases/{version}/dotnetdoc/api/Apache.Ignite.Core.IgniteConfiguration.html[API docs,window=_blank] for details.
tab:C++[]
[source,cpp]
----
include::code-snippets/cpp/src/setting_work_directory.cpp[tag=setting-work-directory,indent=0]
----
--