Question

I'm using a bolt that receives tuples from another bolt (exclamation bolt ) and writes it on a file , the problem I got is that I have duplicated results four times , like when I emit a word , I found the word Written four times . where's the problem possibly could be ?

public class PrinterBolty extends BaseBasicBolt {

    @Override
    public void execute(Tuple tuple, BasicOutputCollector collector) {

        try {
            BufferedWriter output;
            output = new BufferedWriter(new FileWriter("/root/src/storm-starter/hh.txt", true));
            output.newLine();
            output.append(tuple.getString(0));
            output.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer ofd) {
    }
}
Was it helpful?

Solution

The solution was to specify 1 spout in the main class :

builder.setSpout("spout", new RandomSentenceSpout(), 1);

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top