Simple Stream Producer

Step 1: Download the file attached below.

Step 2: Open terminal and go to the folder in which you downloaded the file and compile the file using the command below. The command will produce will a Stream.class file in the same directory. The class file will be executed using java command next.

$ javac

Step 3: Use the following command to stream a file with a specified rate (lines/second)

Usage: stream <file name> <port number> <lines per seconds>


$ java Stream /etc/passwd 9999 1

Above line streams /etc/passwd file on port 9999 at rate 1 line per sec.

Start streaming the file tweeter.json - 1 message per sec

$ java Stream ~/Downloads/datasets/tweets.json 9999 1

If you get the following error message

$ java Stream ~/Downloads/datasets/tweets.json 9999 1 Address already in use

at Method)





at Stream.<init>(

at Stream.main(

Find process that is using port 9999

$ sudo netstat -tulpn | grep 9999

If a process already occupies the port 9999, terminal will show the process details. Using the process id, kill the process. Process Id will be different.

$ sudo netstat -tulpn | grep 9999

tcp 0 0* LISTEN 18616/nc

[cloudera@quickstart python]$ sudo kill -9 18616