You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hadoop.apache.org by Stephen Boesch <ja...@gmail.com> on 2012/10/12 15:37:55 UTC

Getting hostname (or any environment variable) into *-site.xml files

Hi,
   We are using a library with hdfs that uses custom properties inside the
*-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed" script
to update to the local hostnames on each deployed node, is there a
mechanism to use environment variables?

<property>
<name>custom.property</name>
<value>${HOSTNAME}</value>
</property>


I have tried this and out of the box the string ${HOSTNAME} is used.
 Anyone have recommendation/solution on this?

thanks,

stephen b

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Stephen Boesch <ja...@gmail.com>.
Thanks Harsh that is helpful and it does work.

2012/10/12 Harsh J <ha...@cloudera.com>

> The ${FOO} stuff can be replaced via JVM System Properties. I just
> explained this on another thread (a few mails ago).
>
> So if your "library" JVM had a system property of
> -DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
> donkeykong.com automatically.
>
> Likewise, even using Tool as the entry point of your app will let you
> achieve the same via regular -D args.
>
> Hope this helps!
>
> On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> > Hi,
> >    We are using a library with hdfs that uses custom properties inside
> the
> > *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed"
> script
> > to update to the local hostnames on each deployed node, is there a
> mechanism
> > to use environment variables?
> >
> > <property>
> > <name>custom.property</name>
> > <value>${HOSTNAME}</value>
> > </property>
> >
> >
> > I have tried this and out of the box the string ${HOSTNAME} is used.
>  Anyone
> > have recommendation/solution on this?
> >
> > thanks,
> >
> > stephen b
>
>
>
> --
> Harsh J
>

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Stephen Boesch <ja...@gmail.com>.
Thanks Harsh that is helpful and it does work.

2012/10/12 Harsh J <ha...@cloudera.com>

> The ${FOO} stuff can be replaced via JVM System Properties. I just
> explained this on another thread (a few mails ago).
>
> So if your "library" JVM had a system property of
> -DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
> donkeykong.com automatically.
>
> Likewise, even using Tool as the entry point of your app will let you
> achieve the same via regular -D args.
>
> Hope this helps!
>
> On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> > Hi,
> >    We are using a library with hdfs that uses custom properties inside
> the
> > *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed"
> script
> > to update to the local hostnames on each deployed node, is there a
> mechanism
> > to use environment variables?
> >
> > <property>
> > <name>custom.property</name>
> > <value>${HOSTNAME}</value>
> > </property>
> >
> >
> > I have tried this and out of the box the string ${HOSTNAME} is used.
>  Anyone
> > have recommendation/solution on this?
> >
> > thanks,
> >
> > stephen b
>
>
>
> --
> Harsh J
>

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Stephen Boesch <ja...@gmail.com>.
Thanks Harsh that is helpful and it does work.

2012/10/12 Harsh J <ha...@cloudera.com>

> The ${FOO} stuff can be replaced via JVM System Properties. I just
> explained this on another thread (a few mails ago).
>
> So if your "library" JVM had a system property of
> -DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
> donkeykong.com automatically.
>
> Likewise, even using Tool as the entry point of your app will let you
> achieve the same via regular -D args.
>
> Hope this helps!
>
> On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> > Hi,
> >    We are using a library with hdfs that uses custom properties inside
> the
> > *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed"
> script
> > to update to the local hostnames on each deployed node, is there a
> mechanism
> > to use environment variables?
> >
> > <property>
> > <name>custom.property</name>
> > <value>${HOSTNAME}</value>
> > </property>
> >
> >
> > I have tried this and out of the box the string ${HOSTNAME} is used.
>  Anyone
> > have recommendation/solution on this?
> >
> > thanks,
> >
> > stephen b
>
>
>
> --
> Harsh J
>

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Stephen Boesch <ja...@gmail.com>.
Thanks Harsh that is helpful and it does work.

2012/10/12 Harsh J <ha...@cloudera.com>

> The ${FOO} stuff can be replaced via JVM System Properties. I just
> explained this on another thread (a few mails ago).
>
> So if your "library" JVM had a system property of
> -DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
> donkeykong.com automatically.
>
> Likewise, even using Tool as the entry point of your app will let you
> achieve the same via regular -D args.
>
> Hope this helps!
>
> On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> > Hi,
> >    We are using a library with hdfs that uses custom properties inside
> the
> > *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed"
> script
> > to update to the local hostnames on each deployed node, is there a
> mechanism
> > to use environment variables?
> >
> > <property>
> > <name>custom.property</name>
> > <value>${HOSTNAME}</value>
> > </property>
> >
> >
> > I have tried this and out of the box the string ${HOSTNAME} is used.
>  Anyone
> > have recommendation/solution on this?
> >
> > thanks,
> >
> > stephen b
>
>
>
> --
> Harsh J
>

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Harsh J <ha...@cloudera.com>.
The ${FOO} stuff can be replaced via JVM System Properties. I just
explained this on another thread (a few mails ago).

So if your "library" JVM had a system property of
-DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
donkeykong.com automatically.

Likewise, even using Tool as the entry point of your app will let you
achieve the same via regular -D args.

Hope this helps!

On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> Hi,
>    We are using a library with hdfs that uses custom properties inside the
> *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed" script
> to update to the local hostnames on each deployed node, is there a mechanism
> to use environment variables?
>
> <property>
> <name>custom.property</name>
> <value>${HOSTNAME}</value>
> </property>
>
>
> I have tried this and out of the box the string ${HOSTNAME} is used.  Anyone
> have recommendation/solution on this?
>
> thanks,
>
> stephen b



-- 
Harsh J

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Harsh J <ha...@cloudera.com>.
The ${FOO} stuff can be replaced via JVM System Properties. I just
explained this on another thread (a few mails ago).

So if your "library" JVM had a system property of
-DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
donkeykong.com automatically.

Likewise, even using Tool as the entry point of your app will let you
achieve the same via regular -D args.

Hope this helps!

On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> Hi,
>    We are using a library with hdfs that uses custom properties inside the
> *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed" script
> to update to the local hostnames on each deployed node, is there a mechanism
> to use environment variables?
>
> <property>
> <name>custom.property</name>
> <value>${HOSTNAME}</value>
> </property>
>
>
> I have tried this and out of the box the string ${HOSTNAME} is used.  Anyone
> have recommendation/solution on this?
>
> thanks,
>
> stephen b



-- 
Harsh J

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Harsh J <ha...@cloudera.com>.
The ${FOO} stuff can be replaced via JVM System Properties. I just
explained this on another thread (a few mails ago).

So if your "library" JVM had a system property of
-DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
donkeykong.com automatically.

Likewise, even using Tool as the entry point of your app will let you
achieve the same via regular -D args.

Hope this helps!

On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> Hi,
>    We are using a library with hdfs that uses custom properties inside the
> *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed" script
> to update to the local hostnames on each deployed node, is there a mechanism
> to use environment variables?
>
> <property>
> <name>custom.property</name>
> <value>${HOSTNAME}</value>
> </property>
>
>
> I have tried this and out of the box the string ${HOSTNAME} is used.  Anyone
> have recommendation/solution on this?
>
> thanks,
>
> stephen b



-- 
Harsh J

Re: Getting hostname (or any environment variable) into *-site.xml files

Posted by Harsh J <ha...@cloudera.com>.
The ${FOO} stuff can be replaced via JVM System Properties. I just
explained this on another thread (a few mails ago).

So if your "library" JVM had a system property of
-DHOSTNAME=donkeykong.com then ${HOSTNAME} will be replaced by
donkeykong.com automatically.

Likewise, even using Tool as the entry point of your app will let you
achieve the same via regular -D args.

Hope this helps!

On Fri, Oct 12, 2012 at 7:07 PM, Stephen Boesch <ja...@gmail.com> wrote:
> Hi,
>    We are using a library with hdfs that uses custom properties inside the
> *-site.xml files.  Instead of (a) hard-coding or (b) writing a "sed" script
> to update to the local hostnames on each deployed node, is there a mechanism
> to use environment variables?
>
> <property>
> <name>custom.property</name>
> <value>${HOSTNAME}</value>
> </property>
>
>
> I have tried this and out of the box the string ${HOSTNAME} is used.  Anyone
> have recommendation/solution on this?
>
> thanks,
>
> stephen b



-- 
Harsh J