public class JuggaloaderTopology {
public StormTopology createJuggaloaderTopology() {
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("eventSpout", new EventSpout());
builder.setSpout("commandSpout", new JuggaloaderCommandSpout());
builder.setBolt("accountMetricsBolt", new AccountMetricsBolt())
.shuffleGrouping("eventSpout", GroupingNameConstants.ACCOUNT_GROUPING_NAME);
builder.setBolt("connectionMetricsBolt", new ConnectionMetricsBolt())
.shuffleGrouping("eventSpout", GroupingNameConstants.CONNECTION_GROUPING_NAME);
builder.setBolt("inventoryItemMetricsBolt", new InventoryItemMetricsBolt())
.shuffleGrouping("eventSpout", GroupingNameConstants.INVENTORY_ITEM_GROUPING_NAME);
builder.setBolt("userMetricsBolt", new UserMetricsBolt())
.shuffleGrouping("eventSpout", GroupingNameConstants.USER_GROUPING_NAME);
builder.setBolt("messageMetricsBolt", new SobaMessageMetricsBolt())
.shuffleGrouping("eventSpout", GroupingNameConstants.MESSAGE_GROUPING_NAME);
builder.setBolt("second", new JuggaloaderTimeBaseBolt(0))
.fieldsGrouping("accountMetricsBolt", new Fields("metricAccount", "metricName"))
.fieldsGrouping("connectionMetricsBolt", new Fields("metricAccount", "metricName"))
.fieldsGrouping("inventoryItemMetricsBolt", new Fields("metricAccount", "metricName"))
.fieldsGrouping("userMetricsBolt", new Fields("metricAccount", "metricName"))
.fieldsGrouping("messageMetricsBolt", new Fields("metricAccount", "metricName"))
.fieldsGrouping("commandSpout", new Fields("metricAccount", "metricName"));
builder.setBolt("minute", new JuggaloaderTimeBaseBolt(Constants.PERIOD_MINUTE))
.fieldsGrouping("second", new Fields("metricAccount", "metricName"));
builder.setBolt("hour", new JuggaloaderTimeBaseBolt(Constants.PERIOD_HOUR))
.fieldsGrouping("minute", new Fields("metricAccount", "metricName"));
builder.setBolt("day", new JuggaloaderTimeBaseBolt(Constants.PERIOD_DAY))
.fieldsGrouping("hour", new Fields("metricAccount", "metricName"));
builder.setBolt("week", new JuggaloaderTimeBaseBolt(Constants.PERIOD_WEEK))
.fieldsGrouping("day", new Fields("metricAccount", "metricName"));
builder.setBolt("month", new JuggaloaderTimeBaseBolt(Constants.PERIOD_MONTH))
.fieldsGrouping("week", new Fields("metricAccount", "metricName"));
builder.setBolt("persistence", new PersistMetricsBolt())
.shuffleGrouping("minute")
.shuffleGrouping("hour")
.shuffleGrouping("day")
.shuffleGrouping("week")
.shuffleGrouping("month");
// builder.setBolt("message", new JuggaloaderAnomalyGeneratorBolt()) // TODO - replace the next line with this one when SOBA-1521 is done
builder.setBolt("message", new JuggaloaderMessageGeneratorBolt())
.fieldsGrouping("second", new Fields("metricAccount", "metricName"))
.fieldsGrouping("minute", new Fields("metricAccount", "metricName"))
.fieldsGrouping("hour", new Fields("metricAccount", "metricName"))
.fieldsGrouping("day", new Fields("metricAccount", "metricName"))
.fieldsGrouping("week", new Fields("metricAccount", "metricName"))
.fieldsGrouping("month", new Fields("metricAccount", "metricName"));
return builder.createTopology();
}