Search in sources :

Example 1 with SwitchPortsSpout

use of org.openkilda.wfm.topology.portstate.spout.SwitchPortsSpout in project open-kilda by telstra.

the class PortStateTopology method createTopology.

@Override
public StormTopology createTopology() throws NameCollisionException {
    final String clazzName = this.getClass().getSimpleName();
    logger.debug("Building Topology - {}", clazzName);
    TopologyBuilder builder = new TopologyBuilder();
    /*
         *  Topology:
         *
         *  TOPO_DISCO_SPOUT ---> TopoDiscoParseBolt ---> ParsePortInfoBolt ---> OtsdbKafkaBolt(kilda.otsdb topic)
         *                                                         ^
         *                                                         |
         *  WFM_STATS_SPOUT ---> WfmStatsParseBolt -----------------
         *
         *
         *  SwitchPortsSpout ---> SpeakerKafkaBolt(kilda.speaker topic)
         *
         */
    // Setup spout and bolt for TOPO_DISCO_SPOUT line
    String topoDiscoTopic = config.getKafkaTopoDiscoTopic();
    checkAndCreateTopic(topoDiscoTopic);
    logger.debug("connecting to topic {}", topoDiscoTopic);
    builder.setSpout(TOPO_DISCO_SPOUT, createKafkaSpout(topoDiscoTopic, clazzName + topoDiscoTopic));
    TopoDiscoParseBolt topoDiscoParseBolt = new TopoDiscoParseBolt();
    builder.setBolt(TOPO_DISCO_PARSE_BOLT_NAME, topoDiscoParseBolt, config.getParallelism()).shuffleGrouping(TOPO_DISCO_SPOUT);
    ParsePortInfoBolt parsePortInfoBolt = new ParsePortInfoBolt();
    builder.setBolt(PARSE_PORT_INFO_BOLT_NAME, parsePortInfoBolt, config.getParallelism()).shuffleGrouping(TOPO_DISCO_PARSE_BOLT_NAME, TopoDiscoParseBolt.TOPO_TO_PORT_INFO_STREAM).shuffleGrouping(WFM_STATS_PARSE_BOLT_NAME, WfmStatsParseBolt.WFM_TO_PARSE_PORT_INFO_STREAM);
    final String openTsdbTopic = config.getKafkaOtsdbTopic();
    checkAndCreateTopic(openTsdbTopic);
    KafkaBolt openTsdbBolt = createKafkaBolt(openTsdbTopic);
    builder.setBolt(OtsdbKafkaBoltName, openTsdbBolt, config.getParallelism()).shuffleGrouping(PARSE_PORT_INFO_BOLT_NAME);
    // Setup spout and bolt for WFM_STATS_SPOUT line
    String wfmStatsTopic = config.getKafkaStatsTopic();
    checkAndCreateTopic(wfmStatsTopic);
    logger.debug("conencting to topic {}", wfmStatsTopic);
    builder.setSpout(WFM_STATS_SPOUT, createKafkaSpout(wfmStatsTopic, clazzName + wfmStatsTopic));
    WfmStatsParseBolt wfmStatsParseBolt = new WfmStatsParseBolt();
    builder.setBolt(WFM_STATS_PARSE_BOLT_NAME, wfmStatsParseBolt, config.getParallelism()).shuffleGrouping(WFM_STATS_SPOUT);
    // Setup spout and bolt for sending SwitchPortsCommand every frequency seconds
    SwitchPortsSpout switchPortsSpout = new SwitchPortsSpout(JANITOR_REFRESH);
    builder.setSpout(SWITCH_PORTS_SPOUT_NAME, switchPortsSpout);
    final String speakerTopic = config.getKafkaSpeakerTopic();
    checkAndCreateTopic(speakerTopic);
    KafkaBolt speakerBolt = createKafkaBolt(speakerTopic);
    builder.setBolt(SpeakerBoltName, speakerBolt, config.getParallelism()).shuffleGrouping(SWITCH_PORTS_SPOUT_NAME);
    return builder.createTopology();
}
Also used : ParsePortInfoBolt(org.openkilda.wfm.topology.portstate.bolt.ParsePortInfoBolt) SwitchPortsSpout(org.openkilda.wfm.topology.portstate.spout.SwitchPortsSpout) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) WfmStatsParseBolt(org.openkilda.wfm.topology.portstate.bolt.WfmStatsParseBolt) TopoDiscoParseBolt(org.openkilda.wfm.topology.portstate.bolt.TopoDiscoParseBolt) KafkaBolt(org.apache.storm.kafka.bolt.KafkaBolt)

Aggregations

KafkaBolt (org.apache.storm.kafka.bolt.KafkaBolt)1 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)1 ParsePortInfoBolt (org.openkilda.wfm.topology.portstate.bolt.ParsePortInfoBolt)1 TopoDiscoParseBolt (org.openkilda.wfm.topology.portstate.bolt.TopoDiscoParseBolt)1 WfmStatsParseBolt (org.openkilda.wfm.topology.portstate.bolt.WfmStatsParseBolt)1 SwitchPortsSpout (org.openkilda.wfm.topology.portstate.spout.SwitchPortsSpout)1