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 7F411DFB6 for ; Thu, 9 Aug 2012 08:35:06 +0000 (UTC) Received: (qmail 8591 invoked by uid 500); 9 Aug 2012 08:35:01 -0000 Delivered-To: apmail-hadoop-user-archive@hadoop.apache.org Received: (qmail 8381 invoked by uid 500); 9 Aug 2012 08:35:01 -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 8363 invoked by uid 99); 9 Aug 2012 08:35:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2012 08:35:00 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=FSL_RCVD_USER,HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.161.176] (HELO mail-gg0-f176.google.com) (209.85.161.176) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2012 08:34:54 +0000 Received: by ggcs6 with SMTP id s6so177374ggc.35 for ; Thu, 09 Aug 2012 01:34:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:date :message-id:subject:from:to:content-type:x-gm-message-state; bh=B+KWgtUiOoWlqvWG7xu/oLrFIvaUFOvso2WT9MVpP6U=; b=YonOuEWrOg2dEM4t2+NIF7w7b5VQJcza6e1J/B4sm/xI+tyT/7x9qYgp2GO3HWEn1d gvNAgxuYDPha5F/Gqd5oC26t/SeGqyEkvG3fENAPJSbMrm3L1EOCke6pWba/FlwQOIJo +JOZ55XYe4Gd+P2YFoxaHahED0NQwIZinZN8bz82JWZTUs10eI9ucD9hJFXGrURgz1ln n8/LInYtxkN8+1SMBg7uQ2ViMyHZXctLreiUwRAuGSstkMOCxicMkNEahS3qGLdjEhUi ebfgCk1BtAWB/vN3vv+ieyqwqFB29SnAf0gqf1MVNuIwtRr9k0xPTep9ER1O3Q3vj+44 nzcw== MIME-Version: 1.0 Received: by 10.50.46.232 with SMTP id y8mr215089igm.57.1344501273334; Thu, 09 Aug 2012 01:34:33 -0700 (PDT) Received: by 10.50.87.230 with HTTP; Thu, 9 Aug 2012 01:34:33 -0700 (PDT) X-Originating-IP: [143.252.1.30] In-Reply-To: References: Date: Thu, 9 Aug 2012 09:34:33 +0100 Message-ID: Subject: Re: Question on adding Hadoop XML to Configuration Object From: Dave Beech To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=14dae9340cbbcc119504c6d11842 X-Gm-Message-State: ALoCoQns/Dv1SQbBSzf8DtCO6vWpNa6FHg3e6DAYCmBBiwckjj/oXLRaSFVWUYExbRaEfEhSI7mz X-Virus-Checked: Checked by ClamAV on apache.org --14dae9340cbbcc119504c6d11842 Content-Type: text/plain; charset=ISO-8859-1 Also - make sure the fs.default.name parameter is actually in core-site.xml, not hdfs-site.xml On 9 August 2012 09:32, Mohammad Tariq wrote: > Try this and let me know if it works, > > Configuration conf = new Configuration(); > conf.addResource(new > Path("YOUR_HADOOP_HOME/conf/core-site.xml")); > conf.addResource(new > Path("YOUR_HADOOP_HOME/conf/hdfs-site.xml")); > FileSystem fs = FileSystem.get(conf); > Regards, > Mohammad Tariq > > > On Thu, Aug 9, 2012 at 1:58 PM, Chandra Mohan, Ananda Vel Murugan > wrote: > > Hi, > > > > I have added other xml files too. But the issue is configuration object > is not getting updated with the xml conents. > > > > When I add > > > > System.out.println(configuration.get("fs.default.name")); > > > > I am not getting my hdfs url which I have in core-site.xml. When I run > my code in eclipse, it works. But when I make it as a runnable jar file, it > outputs file:/// > > > > Regards, > > Anand.C > > > > -----Original Message----- > > From: Mohammad Tariq [mailto:dontariq@gmail.com] > > Sent: Thursday, August 09, 2012 1:28 PM > > To: user@hadoop.apache.org > > Subject: Re: Question on adding Hadoop XML to Configuration Object > > > > Hello there, > > > > Add the "conf/core-site.xml" file as well. > > > > Regards, > > Mohammad Tariq > > > > > > On Thu, Aug 9, 2012 at 12:37 PM, Chandra Mohan, Ananda Vel Murugan > > wrote: > >> Hi, > >> > >> > >> > >> I am trying to add a file to HDFS programmatically. > >> > >> > >> > >> In my code, I am adding hdfs-site.xml and other xml to Hadoop > Configuration > >> object as follows > >> > >> > >> > >> Configuration configuration = null; > >> > >> configuration.addResource(new > >> URL("file:///usr/local/hadoop-1.0.2/conf/hdfs-site.xml")); > >> > >> configuration.addResource(new > >> Path("usr/local/hadoop-1.0.2/conf/hdfs-site.xml")); > >> > >> configuration.reloadConfiguration(); > >> > >> fileSystem = FileSystem.get(configuration); > >> > >> System.out.println(fileSystem.getName()); > >> > >> > >> > >> This code prints file system as file:/// instead of hdfs://. > >> > >> > >> > >> When I manually set HDFS configuration parameter like below, it works > well > >> > >> > >> > >> //configuration.set("fs.default.name", "hdfs://10.78.32.252:54310"); > >> > >> > >> > >> How can I make my code work? Any inputs would be greatly appreciated. > >> > >> > >> > >> Regards, > >> > >> Anand.C > >> > >> > >> > >> > --14dae9340cbbcc119504c6d11842 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Also - make sure the fs.default.name= parameter is actually in core-site.xml, not hdfs-site.xml

On 9 August 2012 09:32, Mohammad Tariq = <dontariq@gmail.= com> wrote:
Try this and let me know if it works,

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Configuration conf =3D new Configuration();=
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 conf.addResource(new Path("YOUR_HADOOP= _HOME/conf/core-site.xml"));
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 conf.addResource(new Path("YOUR_HADOOP= _HOME/conf/hdfs-site.xml"));
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 FileSystem fs =3D FileSystem.get(conf);
Regards,
=A0 =A0 Mohammad Tariq


On Thu, Aug 9, 2012 at 1:58 PM, Chandra Mohan, Ananda Vel Murugan
<Ananda.Murugan@honeywell.com> wrote:
> Hi,
>
> I have added other xml files too. But the issue is configuration objec= t is not getting updated with the xml conents.
>
> When I add
>
> =A0 =A0 =A0 =A0 System.out.println(configuration.get("fs.default.name"));
>
> I am not getting my hdfs url which I have in core-site.xml. When I run= my code in eclipse, it works. But when I make it as a runnable jar file, i= t outputs file:///
>
> Regards,
> Anand.C
>
> -----Original Message-----
> From: Mohammad Tariq [mailto:don= tariq@gmail.com]
> Sent: Thursday, August 09, 2012 1:28 PM
> To: user@hadoop.apache.org
> Subject: Re: Question on adding Hadoop XML to Configuration Object
>
> Hello there,
>
> =A0 =A0 =A0 =A0 Add the "conf/core-site.xml" file as well. >
> Regards,
> =A0 =A0 Mohammad Tariq
>
>
> On Thu, Aug 9, 2012 at 12:37 PM, Chandra Mohan, Ananda Vel Murugan
> <
Ananda.Murugan@hon= eywell.com> wrote:
>> Hi,
>>
>>
>>
>> I am trying to add a file to HDFS programmatically.
>>
>>
>>
>> In my code, I am adding hdfs-site.xml and other xml to Hadoop Conf= iguration
>> object as follows
>>
>>
>>
>> Configuration configuration =3D null;
>>
>> configuration.addResource(new
>> URL("file:///usr/local/hadoop-1.0.2/conf/hdfs-site.xml")= );
>>
>> configuration.addResource(new
>> Path("usr/local/hadoop-1.0.2/conf/hdfs-site.xml"));
>>
>> configuration.reloadConfiguration();
>>
>> fileSystem =3D FileSystem.get(configuration);
>>
>> System.out.println(fileSystem.getName());
>>
>>
>>
>> This code prints file system as file:/// instead of hdfs://.
>>
>>
>>
>> When I manually set HDFS configuration parameter like below, it wo= rks well
>>
>>
>>
>> //configuration.set("fs.default.name", "hdfs://10.78.32.252:54310");
>>
>>
>>
>> How can I make my code work? Any inputs would be greatly appreciat= ed.
>>
>>
>>
>> Regards,
>>
>> Anand.C
>>
>>
>>
>>

--14dae9340cbbcc119504c6d11842--