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 026B810ABC for ; Sat, 3 Aug 2013 12:21:07 +0000 (UTC) Received: (qmail 52588 invoked by uid 500); 3 Aug 2013 12:20:59 -0000 Delivered-To: apmail-hadoop-user-archive@hadoop.apache.org Received: (qmail 52501 invoked by uid 500); 3 Aug 2013 12:20:58 -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 52494 invoked by uid 99); 3 Aug 2013 12:20:57 -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:20:57 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of harsh@cloudera.com designates 209.85.219.49 as permitted sender) Received: from [209.85.219.49] (HELO mail-oa0-f49.google.com) (209.85.219.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Aug 2013 12:20:52 +0000 Received: by mail-oa0-f49.google.com with SMTP id n10so3229641oag.22 for ; Sat, 03 Aug 2013 05:20:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:x-gm-message-state; bh=u+C9Hr7ecSk/OJndCjjevEXl+tHMA1UBdPTYjOp8wMA=; b=DeklrEXZsG5PeNTx5koZL1IDd5cIEAfoddTRUjBVWYV+7YpaEy3wlc/06yvH09yS00 22bGt0bwwVsWDXAAWyxn5PbVAyIkkQMz3hj1yUXlCZAaA1R80xQZeKytpx1doV5oiCOD cycxKiC7QJ2k8UMLWrU2AVirdFgQ+ecjzpiAOW8p6xydIAUlcHJmsV0S6yumkyNFHUPq fBC6aIiGCkGJCNBe+fJBCUQqpgCX/0dN2b+DxM8gQLMhaNtXbYwTtartJnjUUlgfzvnM qRundGshnm5TViqytoeVr0ewihXVQI9VkFV0SRYTGg6fXfGZC9T3Lj1saMhFSMn2+OYP kurA== X-Received: by 10.43.2.68 with SMTP id nt4mr737757icb.0.1375532431254; Sat, 03 Aug 2013 05:20:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.50.87.164 with HTTP; Sat, 3 Aug 2013 05:20:11 -0700 (PDT) In-Reply-To: References: From: Harsh J Date: Sat, 3 Aug 2013 17:50:11 +0530 Message-ID: Subject: Re: load properties from property file into Configuration object To: "" Content-Type: text/plain; charset=ISO-8859-1 X-Gm-Message-State: ALoCoQkwIVn9hQHKNm4koCZPbLm+Cm/TUey+nUI1yn0mYZaGgkIQmD8pFEEbJxMXGouR7j7UuTSd X-Virus-Checked: Checked by ClamAV on apache.org 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 http://hadoop.apache.org/docs/stable/api/org/apache/hadoop/util/Tool.html 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 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 > 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. -- Harsh J