hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harsh J <ha...@cloudera.com>
Subject Re: load properties from property file into Configuration object
Date Sat, 03 Aug 2013 12:20:11 GMT
This is a bit unnecessary to manually do. If you use the Tool
framework, then you can pass -Dkey=val props directly into a config
object at runtime. See
and http://hadoop.apache.org/docs/stable/api/org/apache/hadoop/util/GenericOptionsParser.html

On Sat, Aug 3, 2013 at 5:30 PM, Juan Pino <juancitomiguelito@gmail.com> wrote:
> Hi,
> I am trying to simplify code that loads properties from a property file into
> a Configuration object:
> Short excerpt of the code:
> String configFile = args[0];
> Properties p = new Properties();
> p.load(new FileInputStream(configFile));
> Configuration conf = getConf();
> for (String prop: p.stringPropertyNames()) {
>   conf.set(prop, p.getProperty(prop));
> }
> The context is that my program can be run with an optional argument which is
> a config file as "hadoop jar MYJAR MYCLASS -D property1=PROPERTY1 -D
> The format of MYCONFIGFILE is
> "property3=PROPERTY3<NEWLINE>property4=PROPERTY4 etc."
> Looking at the Configuration api, I didn't see any method that directly
> loads properties from a property file.
> Looking at the Configuration code, Configuration looks like a wrapper around
> Properties, so I thought there was a similar method to Properties.load or a
> method that sets several properties at the same time.
> Is there a way to do this ?
> Thanks very much,
> Juan
> --
> In light of the recent NSA scandal, please consider encrypting your reply by
> using my public key available at http://mi.eng.cam.ac.uk/~jmp84/pgp.txt If
> you use webmail, you may consider mailvelope (http://mailvelope.com/) which
> is a very easy to use plugin available for chrome and probably soon for
> firefox.

Harsh J

View raw message