Appendix C. Real Life Example Setup

First, clone the GitHub repository for the example from:

> git clone git://github.com/storm-book/examples-ch06-real-life-app.git
src/main

Contains the Topology souce code

src/test

Has the tests for the Topology

webapps directory h

Has the Node.Js WebApp to play with the Topology

.
├── pom.xml
├── src
│   ├── main
│   │   └── java
│   └── test
│       └── groovy
└── webapp

Installing Redis

Installing Redis is very easy:

  1. Download the latest stable version from the Redis website (at the time of this writing, 2.4.14).

  2. Extract the file.

  3. Run make, followed by make install.

This will compile Redis and leave executable files in your PATH so you can start using Redis.

You’ll find more information on the Redis website as well as documentation on commands and design considerations.

Installing Node.js

Installing Node.js is pretty straightforward. Download the latest Node.js source from http://www.nodejs.org/#download.

At the time of this writing, the latest version of NodeJS is 0.6.19. Extract the content of the file and run ./configure, make, and make install.

You’ll find more information on the official site, as well as documentation on how to install Node.js on different platforms.

Building and Testing

In order to build the example, you should start the redis-server on your machine.

>nohup redis-server &

After that, run the mvn command to effectively compile and test the application.

>mvn package
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.163s
[INFO] Finished at: Sun Jun 17 18:55:10 GMT-03:00 2012
[INFO] Final Memory: 9M/81M
[INFO] ------------------------------------------------------------------------
>

Running the Topology

Once the redis-server is running and the build is successful, start the topology running in a LocalCluster.

>java -jar target/storm-analytics-0.0.1-jar-with-dependencies.jar

After the topology is started, you can start the Node.js Web Application by running the following:

>node webapp/app.js

Warning

Topology and Node.js commands block eachother. Try running them in different terminals.

Playing with the Example

Type http://localhost:3000/ and start playing with the example!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset