You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@flink.apache.org by raikarsunil <rs...@gmail.com> on 2017/01/17 13:55:43 UTC

Flink Run command :Replace placeholder value in spring xml

Hi,I am not able to replace value into spring place holder .Below is the xml
code snippet .					file:#{systemProperties['configFileName']}		In the above
code I need to replace *configFileName* with actual file which I need to
provide externally.Below is the java code with
*args="/home/myfilepath/file.properties"*:public static void main(String[]
args) {        System.setProperty("configFileName", args[0]);}The above does
not replace *configFileName* with *args *provided.Flink Command :*./flink
run ../../my-code-1.0.0-SNAPSHOT.jar "/home/myfilepath/file.properties"*Any
help on this?Thanks,Sunil



--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Flink-Run-command-Replace-placeholder-value-in-spring-xml-tp11109.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

Re: Flink Run command :Replace placeholder value in spring xml

Posted by raikarsunil <rs...@gmail.com>.
Hi,

Let me give a overall picture :

I am using properties file which contains
values(passwords,kafkahostnames,schemaName etc..) related to DB,kafka ,flink
etc.. which is Environment Specific(Dev,QA,Production) .

Using this properties file in spring xml ,set values to beans .

	<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="location">
			<value>file:#{systemProperties['configFileName']}</value>
		</property>
		<property name="systemPropertiesModeName">
			<value>SYSTEM_PROPERTIES_MODE_OVERRIDE</value>
		</property>
	</bean>
<bean id="cassandraConnector"
class="com.cme.clearing.pmapi.stp_data_core.datastore.connector.CassandraConnector"
		destroy-method="close" >
		<constructor-arg value="${cassandra.keyspace.name}" />
		<constructor-arg value="${cassandra.username}" />
		<constructor-arg value="${cassandra.password}" />
		<constructor-arg value="${consul.cassandra.service.name}" />
	</bean>

*NOTE: the ${} values are in properties file *

I bundle this into a jar containing a main class which takes arguments.

By using *System.setProperty("configFileName", args[0])* , try to set value
for *configFileName*.

By using below java command I am able to successfully run the code .

java -jar my-code-1.0.0-SNAPSHOT.jar
"/home/MyFileLocation/property.properties"

But using below Flink command it fails.

./flink run ../../my-code-1.0.0-SNAPSHOT.jar
"/home/MyFileLocation/property.properties"

Thanks,
Sunil





--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Flink-Run-command-Replace-placeholder-value-in-spring-xml-tp11109p11124.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

Re: Flink Run command :Replace placeholder value in spring xml

Posted by Timo Walther <tw...@apache.org>.
I'm not sure what you want to do with this configuration. But you should 
keep in mind that all properties you set are only valid in the Flink 
Client that submits the job to the JobManager, you cannot access this 
property within a Flink Function such as MapFunction. Maybe you could 
show us a bit more of your code (esp. the Flink-related parts).


Am 17/01/17 um 15:51 schrieb raikarsunil:
> Hi,
>
>
> args[0]=/home/myfilepath/file.properties
>
> Thanks,
> Sunil
>
>
>
> --
> View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Flink-Run-command-Replace-placeholder-value-in-spring-xml-tp11109p11112.html
> Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.



Re: Flink Run command :Replace placeholder value in spring xml

Posted by raikarsunil <rs...@gmail.com>.
Hi,


args[0]=/home/myfilepath/file.properties

Thanks,
Sunil



--
View this message in context: http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Flink-Run-command-Replace-placeholder-value-in-spring-xml-tp11109p11112.html
Sent from the Apache Flink User Mailing List archive. mailing list archive at Nabble.com.

Re: Flink Run command :Replace placeholder value in spring xml

Posted by Timo Walther <tw...@apache.org>.
Hi Sunil,

what is the content of args[0] when you execute public static void 
main(String[] args) { System.out.println(args[0]); }

Am 17/01/17 um 14:55 schrieb raikarsunil:
> Hi, I am not able to replace value into spring place holder .Below is 
> the xml code snippet . file:#{systemProperties['configFileName']} In 
> the above code I need to replace *configFileName* with actual file 
> which I need to provide externally. Below is the java code with 
> *args="/home/myfilepath/file.properties"*: public static void 
> main(String[] args) { System.setProperty("configFileName", args[0]); } 
> The above does not replace *configFileName* with *args *provided. 
> Flink Command :*./flink run ../../my-code-1.0.0-SNAPSHOT.jar 
> "/home/myfilepath/file.properties"* Any help on this? Thanks, Sunil
> ------------------------------------------------------------------------
> View this message in context: Flink Run command :Replace placeholder 
> value in spring xml 
> <http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/Flink-Run-command-Replace-placeholder-value-in-spring-xml-tp11109.html>
> Sent from the Apache Flink User Mailing List archive. mailing list 
> archive 
> <http://apache-flink-user-mailing-list-archive.2336050.n4.nabble.com/> 
> at Nabble.com.