Database Reference
In-Depth Information
public void
declareOutputFields(OutputFieldsDeclarer declarer) {
declarer.declare(new Fields("word", "count"));
}
2. Next we have to make changes to the main() method to use this new bolt in-
stead of WordCount Bolt() ; here is the snippet:
// instantiates the new builder object
TopologyBuilder builder = new TopologyBuilder();
// Adds a new spout of type "RandomSentenceSpout"
with a parallelism hint of 5
builder.setSpout("spout", new RandomSentenceSpout(),
5);
//Adds a new bolt to the topology of type
"SplitSentence" with parallelism of 8
builder.setBolt("split", new SplitSentence(),
8).shuffleGrouping("spout");
//Adds a new bolt to the topology of type
"SplitSentence" with parallelism of 8
//builder.setBolt("count", new FileWriterBolt()(),
12).fieldsGrouping("split", new Fields("word"));
3. Next, you can execute the topology using Eclipse, run it as Java, and the output
will be saved into a file called wordCount.txt in your home directory.
4. To run in distributed mode, use the following steps:
1. Compile the topology changes to generate a new Storm-starter project us-
ing the following command line:
mvn clean install
2. Copy storm-starter-0.0.1-SNAPSHOT-jar-with-depend-
encies.jar from the target folder under the starter project to Nimbus,
let's say, at /home/admin/topology/ .
3. Submit the topology using the following command:
storm jar /home/admin/topology/
storm-starter-0.0.1-SNAPSHOT-
jar-with-dependencies.jar
Search WWH ::




Custom Search