Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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
Learning Real-time Analytics with Storm and Cassandra

You're reading from   Learning Real-time Analytics with Storm and Cassandra Solve real-time analytics problems effectively using Storm and Cassandra

Arrow left icon
Product type Paperback
Published in Mar 2015
Publisher
ISBN-13 9781784395490
Length 220 pages
Edition 1st Edition
Languages
Tools
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 (14) Chapters Close

Preface 1. Let's Understand Storm FREE CHAPTER 2. Getting Started with Your First Topology 3. Understanding Storm Internals by Examples 4. Storm in a Clustered Mode 5. Storm High Availability and Failover 6. Adding NoSQL Persistence to Storm 7. Cassandra Partitioning, High Availability, and Consistency 8. Cassandra Management and Maintenance 9. Storm Management and Maintenance 10. Advance Concepts in Storm 11. Distributed Cache and CEP with Storm A. Quiz Answers Index

Customizing Storm spouts


You have explored and understood WordCount topology provided by the Storm-starter project in previous chapters. Now it's time we move on to the next step, the do it yourself journey with Storm; so let's take up the next leap and do some exciting stuff with our own spouts that read from various sources.

Creating FileSpout

Here we will create our own spout to read the events or tuples from a file source and emit them into the topology; we would substitute spout in place of RandomSentenceSpout we used in the WordCount topology in the previous chapter.

To start, copy the project we created in Chapter 2, Getting Started with Your First Topology, into a new project and make the following changes in RandomSentenceSpout to make a new class called FileSpout within the Storm-starter project.

Now we will make changes in FileSpout so that it reads sentences from a file as shown in the following code:

public class FileSpout extends BaseRichSpout {
  //declaration section
  SpoutOutputCollector...
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