apache-ignite
111 строк · 4.5 Кб
1// Licensed to the Apache Software Foundation (ASF) under one or more
2// contributor license agreements. See the NOTICE file distributed with
3// this work for additional information regarding copyright ownership.
4// The ASF licenses this file to You under the Apache License, Version 2.0
5// (the "License"); you may not use this file except in compliance with
6// the License. You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15= Understanding Configuration
16
17This chapter explains different ways of setting configuration parameters in an Ignite cluster. The chapter covers the most
18ubiquitous approaches for Java and C++ applications.
19
20[NOTE]
21====
22[discrete]
23=== Configuring .NET, Python, Node.JS and other programming languages
24
25* .NET developers: refer to the link:net-specific/net-configuration-options[Ignite.NET Configuration] section
26* Developers of Python, Node.JS, and other programming languages: use this page to configure your
27Java-powered Ignite cluster and link:thin-clients/getting-started-with-thin-clients[thin clients] section to set up
28your language-specific applications that will be working with the cluster.
29====
30
31== Overview
32
33You can specify custom configuration parameters by providing an instance of the javadoc:org.apache.ignite.configuration.IgniteConfiguration[] class to Ignite when starting the node.
34You can set the parameters either programmatically or via an XML configuration file.
35These 2 ways are fully interchangeable.
36
37The XML configuration file is a Spring Bean definition file that must contain the `IgniteConfiguration` bean.
38When starting a node from the command line, pass the configuration file as a parameter to the `ignite.sh|bat` script, as follows:
39
40[source,shell]
41----
42ignite.sh ignite-config.xml
43----
44
45If you don't specify a configuration file, the default file `{IGNITE_HOME}/config/default-config.xml` is used.
46
47== Spring XML Configuration
48
49To create a configuration in a Spring XML format, you need to define the
50`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
51https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/xsd-configuration.html[official
52Spring documentation].
53
54In the example below, we create an `IgniteConfiguration` bean, set the `workDirectory` property, and configure a link:data-modeling/data-partitioning#partitioned[partitioned cache].
55
56[source,xml]
57----
58<?xml version="1.0" encoding="UTF-8"?>
59
60<beans xmlns="http://www.springframework.org/schema/beans"
61xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
62xsi:schemaLocation="
63http://www.springframework.org/schema/beans
64http://www.springframework.org/schema/beans/spring-beans.xsd">
65
66<bean class="org.apache.ignite.configuration.IgniteConfiguration">
67<property name="workDirectory" value="/path/to/work/directory"/>
68
69<property name="cacheConfiguration">
70<bean class="org.apache.ignite.configuration.CacheConfiguration">
71<!-- Set the cache name. -->
72<property name="name" value="myCache"/>
73<!-- Set the cache mode. -->
74<property name="cacheMode" value="PARTITIONED"/>
75<!-- Other cache parameters. -->
76</bean>
77</property>
78</bean>
79</beans>
80----
81
82== Programmatic Configuration
83
84Create an instance of the `IgniteConfiguration` class and set the required
85parameters, as shown in the example below.
86
87[tabs]
88--
89
90tab:Java[]
91[source,java]
92----
93include::{javaCodeDir}/UnderstandingConfiguration.java[tag=cfg,indent=0]
94----
95
96See the link:{javadoc_base_url}/org/apache/ignite/configuration/IgniteConfiguration.html[IgniteConfiguration,window=_blank] javadoc for the complete list of parameters.
97
98tab:C#/.NET[]
99[source,csharp]
100----
101include::code-snippets/dotnet/UnderstandingConfiguration.cs[tag=UnderstandingConfigurationProgrammatic,indent=0]
102----
103
104See the https://ignite.apache.org/releases/{version}/dotnetdoc/api/Apache.Ignite.Core.IgniteConfiguration.html[API docs,window=_blank] for details.
105
106tab:C++[]
107[source,cpp]
108----
109include::code-snippets/cpp/src/setting_work_directory.cpp[tag=setting-work-directory,indent=0]
110----
111--
112