Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Real-Time Big Data Analytics

You're reading from   Real-Time Big Data Analytics Design, process, and analyze large sets of complex data in real time

Arrow left icon
Product type Paperback
Published in Feb 2016
Publisher
ISBN-13 9781784391409
Length 326 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Shilpi Saxena Shilpi Saxena
Author Profile Icon Shilpi Saxena
Shilpi Saxena
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Introducing the Big Data Technology Landscape and Analytics Platform FREE CHAPTER 2. Getting Acquainted with Storm 3. Processing Data with Storm 4. Introduction to Trident and Optimizing Storm Performance 5. Getting Acquainted with Kinesis 6. Getting Acquainted with Spark 7. Programming with RDDs 8. SQL Query Engine for Spark – Spark SQL 9. Analysis of Streaming Data Using Spark Streaming 10. Introducing Lambda Architecture Index

Coding our first Spark Streaming job


In this section, we will code and execute our first Spark Streaming job in Scala. We will also simulate the streaming data by creating a temporary stream.

Creating a stream producer

Perform the following steps to create a stream producer which continuously reads the input data provided by the user from the console and then further submits that data to a socket:

  1. Open and edit your Spark-Examples project and create a new Scala package and class named chapter.nine.StreamProducer.java.

  2. Next, edit StreamProducer.java and add the following piece of code:

    import java.net.*;
    import java.io.*;
    
    public class StreamProducer {
    
      public static void main(String[] args) {
    
        if (args == null || args.length < 1) {
          System.out.println("Usage - java chapter.nine.StreamProducer <port#>");
          System.exit(0);
        }
        System.out.println("Defining new Socket on " + args[0]);
    try (ServerSocket soc = new ServerSocket(Integer.parseInt(args[0]))) {
    
    System.out...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image