Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Hadoop, mail # user - Client and NN communication in Hadoop


Copy link to this message
-
Re: Client and NN communication in Hadoop
shashwat shriparv 2014-02-27, 05:03
The application that try to write the file, for example the binary "hadoop"
found in the bin dir of hadoop is a hadoop client, whoever wants to read or
write from to hadoop is a client, you can also write hadoop client using
java apis which hadoop provide.

like following is an example of hadoop client which tries to read file from
hadoop

import java.io.*;
import java.util.*;
import java.net.*;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;

public class Cat{
        public static void main (String [] args) throws Exception{
                try{
                        Path pt=new
Path("hdfs://shashwat:9000/home/shriparv/fileonhdfstoread.txt");
                        FileSystem filesysObject = FileSystem.get(new
Configuration());
                        BufferedReader bufferReaderObject=new
BufferedReader(new InputStreamReader(filesysObject.open(pt)));
                        String line;
                        line=bufferReaderObject.readLine();
                        while (line != null){
                                System.out.println(line);
                                line=bufferReaderObject.readLine();
                        }
                }catch(Exception e){
                }
        }
}

Hope this clear some of your doubts
* Warm Regards_**∞_*
* Shashwat Shriparv*
 [image: http://www.linkedin.com/pub/shashwat-shriparv/19/214/2a9]<http://www.linkedin.com/pub/shashwat-shriparv/19/214/2a9>[image:
https://twitter.com/shriparv] <https://twitter.com/shriparv>[image:
https://www.facebook.com/shriparv] <https://www.facebook.com/shriparv>[image:
http://google.com/+ShashwatShriparv]
<http://google.com/+ShashwatShriparv>[image:
http://www.youtube.com/user/sShriparv/videos]<http://www.youtube.com/user/sShriparv/videos>[image:
http://profile.yahoo.com/SWXSTW3DVSDTF2HHSRM47AV6DI/] <[EMAIL PROTECTED]>

On Thu, Feb 27, 2014 at 9:53 AM, navaz <[EMAIL PROTECTED]> wrote: