Return-Path: X-Original-To: apmail-hadoop-user-archive@minotaur.apache.org Delivered-To: apmail-hadoop-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8782410A6F for ; Sat, 3 Aug 2013 12:01:33 +0000 (UTC) Received: (qmail 39746 invoked by uid 500); 3 Aug 2013 12:01:27 -0000 Delivered-To: apmail-hadoop-user-archive@hadoop.apache.org Received: (qmail 39377 invoked by uid 500); 3 Aug 2013 12:01:24 -0000 Mailing-List: contact user-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@hadoop.apache.org Delivered-To: mailing list user@hadoop.apache.org Received: (qmail 39370 invoked by uid 99); 3 Aug 2013 12:01:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Aug 2013 12:01:23 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of juancitomiguelito@gmail.com designates 209.85.212.178 as permitted sender) Received: from [209.85.212.178] (HELO mail-wi0-f178.google.com) (209.85.212.178) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Aug 2013 12:01:18 +0000 Received: by mail-wi0-f178.google.com with SMTP id j17so244402wiw.5 for ; Sat, 03 Aug 2013 05:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=UcbQ057FXAenhjoFNdIW9Fi2zvaKUraVWOK5PP7HjaM=; b=olyyf6KLDZM5m3VtUiQ9y+gsthGqWyxvlS/XsjWyxNpnDZ4P0rhBcjwqVk4J4sbYYf 06C3lgTdEzcMAeGt4hCZ9+9EtBT54D2Io45L9Tsiy2uWENY4THuI5zsfeA7g6s2OHNPQ fWFbd/NnVzcHy/9iFkXTr4q8r6mcur4DIoix9ABdnpm43RpfeeZuGbstLo9c10K7+ftS 9XEkZ+AFBbIJGLI+RArFh7PrrXwROjKrFdCWouH4aNN7iKMknSjbL7t2/19nyX3pxuNI Ru3dLQdsXhFWCUX8qMJVrIhVnzOIIKVaU2pv6AJNusJm51hxChyi49LjlIDWcABVV+/I +Elw== X-Received: by 10.194.175.66 with SMTP id by2mr6033424wjc.59.1375531258252; Sat, 03 Aug 2013 05:00:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.78.241 with HTTP; Sat, 3 Aug 2013 05:00:28 -0700 (PDT) From: Juan Pino Date: Sat, 3 Aug 2013 13:00:28 +0100 Message-ID: Subject: load properties from property file into Configuration object To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=089e013d19f806982f04e309d447 X-Virus-Checked: Checked by ClamAV on apache.org --089e013d19f806982f04e309d447 Content-Type: text/plain; charset=UTF-8 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=PROPERTY3property4=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. --089e013d19f806982f04e309d447 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I am trying to simplify code that l= oads properties from a property file into a Configuration object:

Short excerpt of the code:

String = configFile =3D args[0];
Properties p =3D new Properties();
p.load(new FileInputStrea= m(configFile));
Configuration conf =3D getConf();
for (= String prop: p.stringPropertyNames()) {
=C2=A0 conf.set(prop, p.g= etProperty(prop));
}

The context is that my program can be run w= ith an optional argument which is a config file as "hadoop jar MYJAR= =C2=A0MYCLASS -D property1=3DPROPERTY1 -D property2=3DPROPERTY2 [MYCONFIGFI= LE]"
The format of MYCONFIGFILE is "property3=3DPROPERTY3<NEWLINE&g= t;property4=3DPROPERTY4 etc."

Looking at= the Configuration api, I didn't see any method that directly loads pro= perties 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.lo= ad or a method that sets several properties at the same time.
Is there a way to do this ?

Thanks very much,

Juan

--
In li= ght of the recent NSA scandal, please consider encrypting your reply by usi= ng my public key available at=C2=A0http://mi.eng.cam.ac.uk/~jmp84/pgp.txt=C2= =A0If you use webmail, you may consider mailvelope (http://mailvelope.com/) which is a very e= asy to use plugin available for chrome and probably soon for firefox.
--089e013d19f806982f04e309d447--