Book Image

Storm Real-time Processing Cookbook

By : Quinton Anderson
Book Image

Storm Real-time Processing Cookbook

By: Quinton Anderson

Overview of this book

<p>Storm is a free and open source distributed real-time computation system. Storm makes it easy to reliably process unbounded streams of data, doing for real-time processing what Hadoop did for batch processing. Storm is simple, can be used with any programming language, and is a lot of fun to use!<br />Storm Real Time Processing Cookbook will have basic to advanced recipes on Storm for real-time computation.<br /><br />The book begins with setting up the development environment and then teaches log stream processing. This will be followed by real-time payments workflow, distributed RPC, integrating it with other software such as Hadoop and Apache Camel, and more.</p>
Table of Contents (16 chapters)
Storm Real-time Processing Cookbook
Credits
About the Author
About the Reviewers
www.packtpub.com
Preface
Index

Indexing and persisting the log data


Log data needs to be stored for some defined period of time in order to be useful; it also needs to be searchable. In order to achieve this, the recipe integrates with an open source product call Elastic Search, which is a general-use, clustered search engine with a RESTful API (http://www.elasticsearch.org/).

How to do it…

  1. Create a new BaseRichBolt class called IndexerBolt and declare the org.elasticsearch.client.Client client as a private member variable. You must initialize it as follows within the prepare method:

    if((Boolean)stormConf.get(backtype.storm.Config.TOPOLOGY_DEBUG) == true){
          node = NodeBuilder.nodeBuilder().local(true).node();
          } else {
             String clusterName = (String) stormConf.get(Conf.ELASTIC_CLUSTER_NAME);
             if(clusterName == null)
                clusterName = Conf.DEFAULT_ELASTIC_CLUSTER;
             node = NodeBuilder.nodeBuilder().clusterName(clusterName).node();
          }
          client = node.client();
  2. The LogEntry object...