hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juan Pino <juancitomiguel...@gmail.com>
Subject load properties from property file into Configuration object
Date Sat, 03 Aug 2013 12:00:28 GMT
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
property2=PROPERTY2 [MYCONFIGFILE]"
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.

Mime
View raw message