Databases Reference
In-Depth Information
the repository where Storm dependencies are located. Maven will automatically down-
load all subdependencies required by Storm to run in Local Mode.
The application will have the following structure, typical of a Maven Java project:
our-application-folder/
├── pom.xml
└── src
└── main
└── java
| ├── spouts
| └── bolts
└── resources
The folders under Java will contain our source code and we'll put our Word files into
the resource folder to process.
mkdir -p creates all required parent directories.
Creating Our First Topology
To build our first topology, we'll create all classes required to run the word count. It's
possible that some parts of the example may not be clear at this stage, but we'll explain
them further in subsequent chapters.
Spout
The WordReader spout is a class that implements IRichSpout. We'll see more detail in
Chapter 4 . WordReader will be responsible for reading the file and providing each line
to a bolt.
A spout emits a list of defined fields. This architecture allows you to have
different kinds of bolts reading the same spout stream, which can then
define fields for other bolts to consume and so on.
Example 2-1 contains the complete code for the class (we'll analyze each part of the
code following the example).
Example 2-1. src/main/java/spouts/WordReader.java
package spouts ;
import java.io.BufferedReader ;
import java.io.FileNotFoundException ;
import java.io.FileReader ;
 
Search WWH ::




Custom Search