January 2019
Beginner to intermediate
154 pages
4h 31m
English
Let's start with a simple word-count example using streaming APIs. As a data source, let's install the NC package on Linux:
Installation on CentOS/Red Hat# Removes the old packageyum erase ncyum install ncInstallation on Ubuntusudo apt-get install netcat
The nc or ncat is similar to the cat command but is used for network-streaming data. It is used for reading and writing data across a network.
Start nc on port 8888, as follows:
nc -lk 8888
The following is the Python code of Spark's Streaming API, to count the stream of words coming over the TCP port:
from pyspark import SparkContextfrom pyspark.streaming import StreamingContext# Create a StreamingContext with two thread on local machine and batch interval of 1 second ...
Read now
Unlock full access