Hi Yuci,

Ignite uses Spring XML for configuration creation, so standard
PropertyPlaceholderConfigurer perfectly meets your needs.
Just add

<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

to your configuration file and it will do the trick. Make sure to consult
the PropertyPlaceholderConfigurer javadoc for the available system
properties resolution modes.

Hope this helps,
AG

2016-12-05 20:33 GMT+03:00 yucigou <yuci....@gmail.com>:

> Suppose I have the following configuration file for standalone Ignite
> server
> nodes:
>
> <?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 id="ignite.cfg"
> class="org.apache.ignite.configuration.IgniteConfiguration">
>
>             <property name="peerClassLoadingEnabled" value="true"/>
>
>                 <property name="cacheConfiguration">
>                         <list>
>                                 <bean class="org.apache.ignite.
> configuration.CacheConfiguration">
>                                         <property name="name"
> value="my-cache" />
>
>                                         <property name="cacheMode"
> value="PARTITIONED"/>
>                                         <property name="backups"
> value="1"/>
>                                 </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">
>                                                         <bean
> class="org.springframework.util.StringUtils"
> factory-method="commaDelimitedListToSet">
>
> <constructor-arg type="java.lang.String"
> value="10.22.3.30,10.22.3.31,10.22.3.32,10.22.3.33"/>
>                                                         </bean>
>                                                 </property>
>                                         </bean>
>                                 </property>
>                         </bean>
>                 </property>
>
>         </bean>
> </beans>
>
> Now instead of "10.22.3.30,10.22.3.31,10.22.3.32,10.22.3.33", I would like
> to give a different set of IPs to the fail-over cluser, for example,
> "10.22.4.30,10.22.4.31,10.22.4.32,10.22.4.33".
>
> Is it possible to just specify a variable in the configuration file, such
> as:
>
> <bean class="org.springframework.util.StringUtils"
> factory-method="commaDelimitedListToSet">
>     <constructor-arg type="java.lang.String" value="${nodeIpAddresses}"/>
> </bean>
>
> And then pass the specific IP addresses to the configuration when we
> starting Ignite? Somehow like:
> bin/ignite.sh conf/apache-ignite-server.xml
> -DnodeIpAddresses="10.22.3.30,10.22.3.31,10.22.3.32,10.22.3.33"
> bin/ignite.sh conf/apache-ignite-server.xml
> -DnodeIpAddresses="10.22.4.30,10.22.4.31,10.22.4.32,10.22.4.33"
>
> Thank you,
> Yuci
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/How-to-pass-variable-to-the-
> configuration-file-tp9402.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Reply via email to