You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by yucigou <yu...@gmail.com> on 2016/12/05 17:33:39 UTC
How to pass variable to the configuration file
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.
Re: How to pass variable to the configuration file
Posted by yucigou <yu...@gmail.com>.
Hi AG,
That looks good.
Now I can set my properties file
${MY_APP_HOME}/conf/apache-ignite.properties accordingly for the production
cluster and failover cluser:
* Production
nodeIpAddresses=10.22.3.30,10.22.3.31,10.22.3.32,10.22.3.33
* Failover
nodeIpAddresses=10.22.4.30,10.22.4.31,10.22.4.32,10.22.4.33
Then use the property in the Ignite configuration file:
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>file:${MY_APP_HOME}/conf/apache-ignite.properties</value>
</property>
</bean>
<bean class="org.springframework.util.StringUtils"
factory-method="commaDelimitedListToSet">
<constructor-arg type="java.lang.String" value="${nodeIpAddresses}"/>
</bean>
Note: MY_APP_HOME is an environmental variable.
Cheers,
Yuci
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/How-to-pass-variable-to-the-configuration-file-tp9402p9433.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: How to pass variable to the configuration file
Posted by Alexey Goncharuk <al...@gmail.com>.
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 <yu...@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.
>