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/).
Create a new
BaseRichBolt
class calledIndexerBolt
and declare theorg.elasticsearch.client.Client
client as a private member variable. You must initialize it as follows within theprepare
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();
The
LogEntry
object...