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 ED77611501 for ; Fri, 6 Jun 2014 10:52:42 +0000 (UTC) Received: (qmail 13323 invoked by uid 500); 6 Jun 2014 10:52:38 -0000 Delivered-To: apmail-hadoop-user-archive@hadoop.apache.org Received: (qmail 13205 invoked by uid 500); 6 Jun 2014 10:52:38 -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 13198 invoked by uid 99); 6 Jun 2014 10:52:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2014 10:52:38 +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 rajkrrsingh@gmail.com designates 209.85.216.51 as permitted sender) Received: from [209.85.216.51] (HELO mail-qa0-f51.google.com) (209.85.216.51) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2014 10:52:35 +0000 Received: by mail-qa0-f51.google.com with SMTP id w8so3468887qac.10 for ; Fri, 06 Jun 2014 03:52:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=frIMIo2J4daVKrhU2cd/o1KCiyir56T12X5kbTpg2cc=; b=JYsIWH4XZP/GrtsU4AZMQ5vo3IirB/oTHNEJVNuLyRQBT6i/AGjEivFmEvCCBsTNOo oZsUssvxdZK9ETShW2W439KAzQTqB2r7gUAFXrJY0JKREeDq6gItr0l7iALXrdNSRPKk FT5WIX/RCoIVA+DoDzW+DQ3IcKTKfZTfqf5dwg1knlrWBNoRMR5UMlsxNe6a3HQ8mcwy xa+09515fnvFRttbv1NzOob8Rsjch9XiFWgL49evbGcTk93GC3ZOx0N9+/x0Mj4PBb2e ThDEmJefMEZUhe+RR1aZ8raqjjbA4nRvInOhIShRaXcciWZqzo6XqsYFBVhBmOSwwbNr QdQA== X-Received: by 10.229.44.194 with SMTP id b2mr7414023qcf.0.1402051931236; Fri, 06 Jun 2014 03:52:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.82.36 with HTTP; Fri, 6 Jun 2014 03:51:40 -0700 (PDT) In-Reply-To: References: From: Raj K Singh Date: Fri, 6 Jun 2014 16:21:40 +0530 Message-ID: Subject: Re: hadoop java connection problem To: user@hadoop.apache.org Content-Type: multipart/alternative; boundary=001a1133c6ce51957204fb28a710 X-Virus-Checked: Checked by ClamAV on apache.org --001a1133c6ce51957204fb28a710 Content-Type: text/plain; charset=UTF-8 have you tried to run it through "hadoop jar" instead of directly running it through the eclipse. it seems problem with your path. try adding conf-site.xml using conf.addResource(new Path(Vars.HADOOP_HOME +"/conf/core-site.xml")); before passing the conf reference to the FileSystem.get() so that it can identify your filesystem correctly. :::::::::::::::::::::::::::::::::::::::: Raj K Singh http://in.linkedin.com/in/rajkrrsingh http://www.rajkrrsingh.blogspot.com Mobile Tel: +91 (0)9899821370 On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agrawal wrote: > Hi, > > I am trying to read and write the file from HDFS.I am trying to read it > and display it on console. It runs without giving any error, warning or > exception but also it is not printing the data from file on console, My > file is already saved in hdfs , I can see it on user interface. I think > there is some problem with the path I have given, I am not sure as I am > connecting hadoop first time to java .I am using eclipse as IDE. Can > somebody look into this? > > Code: > Path pt=new Path("hdfs://localhost:54310/user/hduser/project11/a.txt"); > FileSystem fs = FileSystem.get(new Configuration()); > BufferedReader br=new BufferedReader(new InputStreamReader(fs.open(pt))); > String line; > while (( line=br.readLine()) != null){ > System.out.println(line); > line=br.readLine(); > } > > if anybody has some idea of this. Please Share. > > Regards, > Ekta > --001a1133c6ce51957204fb28a710 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
have you tried to run it through "hadoop ja= r" instead of directly running it through the eclipse. it seems proble= m with your path.=C2=A0

try adding conf-site.xml using conf.addResour= ce(new Path(Vars.HADOOP_HOME +"/conf/core-site.xml")); before pas= sing the conf reference to the=C2=A0FileSystem.get() so that it can identi= fy your filesystem correctly.

:::::::::::::::::::::::::::::::::::::= :::
Raj K Singh
=


On Fri, Jun 6, 2014 at 3:49 PM, Ekta Agr= awal <ektacloudstack@gmail.com> wrote:
Hi,

I am trying to=C2=A0read= and write=C2=A0the file from HDFS.I am trying to read it and display it on= console. It runs without giving any error, warning or exception but also i= t is not printing the data from file on console, My file is already saved i= n hdfs ,=C2=A0I can see it on user interface.=C2=A0I think there is some pr= oblem with=C2=A0the path I have given, I am not sure=C2=A0as I am connectin= g hadoop first time to java=C2=A0.I am using eclipse as IDE.=C2=A0Can someb= ody look into this?=C2=A0

Code:
Path pt=3Dnew Path("hdfs://loc= alhost:54310/user/hduser/project11/a.txt");
=C2=A0FileSystem fs =3D= FileSystem.get(new Configuration());
=C2=A0 BufferedReader br=3Dnew Buf= feredReader(new InputStreamReader(fs.open(pt)));
=C2=A0=C2=A0 String line;
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 while (( line=3Dbr.readLine()= ) !=3D null){
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 System.out.println(l= ine);
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 line=3Dbr.readLine();
=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }

=C2=A0if anybody has some idea of this. Please Share.

Regards,
Ekta

--001a1133c6ce51957204fb28a710--