use of org.openkilda.wfm.topology.flow.bolts.SpeakerBolt in project open-kilda by telstra.
the class FlowTopology method createTopology.
@Override
public StormTopology createTopology() throws StreamNameCollisionException {
logger.info("Creating Topology: {}", topologyName);
TopologyBuilder builder = new TopologyBuilder();
List<CtrlBoltRef> ctrlTargets = new ArrayList<>();
BoltDeclarer boltSetup;
Integer parallelism = config.getParallelism();
/*
* Spout receives all Northbound requests.
*/
KafkaSpout northboundKafkaSpout = createKafkaSpout(config.getKafkaFlowTopic(), ComponentType.NORTHBOUND_KAFKA_SPOUT.toString());
builder.setSpout(ComponentType.NORTHBOUND_KAFKA_SPOUT.toString(), northboundKafkaSpout, parallelism);
/*
* Bolt splits requests on streams.
* It groups requests by flow-id.
*/
SplitterBolt splitterBolt = new SplitterBolt();
builder.setBolt(ComponentType.SPLITTER_BOLT.toString(), splitterBolt, parallelism).shuffleGrouping(ComponentType.NORTHBOUND_KAFKA_SPOUT.toString());
/*
* Bolt handles flow CRUD operations.
* It groups requests by flow-id.
*/
CrudBolt crudBolt = new CrudBolt(pathComputerAuth);
ComponentObject.serialized_java(org.apache.storm.utils.Utils.javaSerialize(pathComputerAuth));
boltSetup = builder.setBolt(ComponentType.CRUD_BOLT.toString(), crudBolt, parallelism).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.CREATE.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.READ.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.UPDATE.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.DELETE.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.PUSH.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.UNPUSH.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.PATH.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.RESTORE.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.REROUTE.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.STATUS.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.CACHE_SYNC.toString(), fieldFlowId).fieldsGrouping(ComponentType.TRANSACTION_BOLT.toString(), StreamType.STATUS.toString(), fieldFlowId).fieldsGrouping(ComponentType.SPEAKER_BOLT.toString(), StreamType.STATUS.toString(), fieldFlowId).fieldsGrouping(ComponentType.TOPOLOGY_ENGINE_BOLT.toString(), StreamType.STATUS.toString(), fieldFlowId);
ctrlTargets.add(new CtrlBoltRef(ComponentType.CRUD_BOLT.toString(), crudBolt, boltSetup));
/*
* Bolt sends cache updates.
*/
KafkaBolt cacheKafkaBolt = createKafkaBolt(config.getKafkaTopoCacheTopic());
builder.setBolt(ComponentType.CACHE_KAFKA_BOLT.toString(), cacheKafkaBolt, parallelism).shuffleGrouping(ComponentType.CRUD_BOLT.toString(), StreamType.CREATE.toString()).shuffleGrouping(ComponentType.CRUD_BOLT.toString(), StreamType.UPDATE.toString()).shuffleGrouping(ComponentType.CRUD_BOLT.toString(), StreamType.DELETE.toString()).shuffleGrouping(ComponentType.CRUD_BOLT.toString(), StreamType.STATUS.toString());
/*
* Spout receives Topology Engine response
*/
KafkaSpout topologyKafkaSpout = createKafkaSpout(config.getKafkaFlowTopic(), ComponentType.TOPOLOGY_ENGINE_KAFKA_SPOUT.toString());
builder.setSpout(ComponentType.TOPOLOGY_ENGINE_KAFKA_SPOUT.toString(), topologyKafkaSpout, parallelism);
/*
* Bolt processes Topology Engine responses, groups by flow-id field
*/
TopologyEngineBolt topologyEngineBolt = new TopologyEngineBolt();
builder.setBolt(ComponentType.TOPOLOGY_ENGINE_BOLT.toString(), topologyEngineBolt, parallelism).shuffleGrouping(ComponentType.TOPOLOGY_ENGINE_KAFKA_SPOUT.toString());
/*
* Bolt sends Speaker requests
*/
KafkaBolt speakerKafkaBolt = createKafkaBolt(config.getKafkaSpeakerTopic());
builder.setBolt(ComponentType.SPEAKER_KAFKA_BOLT.toString(), speakerKafkaBolt, parallelism).shuffleGrouping(ComponentType.TRANSACTION_BOLT.toString(), StreamType.CREATE.toString()).shuffleGrouping(ComponentType.TRANSACTION_BOLT.toString(), StreamType.DELETE.toString());
/*
* Spout receives Speaker responses
*/
KafkaSpout speakerKafkaSpout = createKafkaSpout(config.getKafkaFlowTopic(), ComponentType.SPEAKER_KAFKA_SPOUT.toString());
builder.setSpout(ComponentType.SPEAKER_KAFKA_SPOUT.toString(), speakerKafkaSpout, parallelism);
/*
* Bolt processes Speaker responses, groups by flow-id field
*/
SpeakerBolt speakerBolt = new SpeakerBolt();
builder.setBolt(ComponentType.SPEAKER_BOLT.toString(), speakerBolt, parallelism).shuffleGrouping(ComponentType.SPEAKER_KAFKA_SPOUT.toString());
/*
* Transaction bolt.
*/
TransactionBolt transactionBolt = new TransactionBolt();
boltSetup = builder.setBolt(ComponentType.TRANSACTION_BOLT.toString(), transactionBolt, parallelism).fieldsGrouping(ComponentType.TOPOLOGY_ENGINE_BOLT.toString(), StreamType.CREATE.toString(), fieldSwitchId).fieldsGrouping(ComponentType.TOPOLOGY_ENGINE_BOLT.toString(), StreamType.DELETE.toString(), fieldSwitchId).fieldsGrouping(ComponentType.SPEAKER_BOLT.toString(), StreamType.CREATE.toString(), fieldSwitchId).fieldsGrouping(ComponentType.SPEAKER_BOLT.toString(), StreamType.DELETE.toString(), fieldSwitchId);
ctrlTargets.add(new CtrlBoltRef(ComponentType.TRANSACTION_BOLT.toString(), transactionBolt, boltSetup));
/*
* Error processing bolt
*/
ErrorBolt errorProcessingBolt = new ErrorBolt();
builder.setBolt(ComponentType.ERROR_BOLT.toString(), errorProcessingBolt, parallelism).shuffleGrouping(ComponentType.SPLITTER_BOLT.toString(), StreamType.ERROR.toString()).shuffleGrouping(ComponentType.CRUD_BOLT.toString(), StreamType.ERROR.toString());
/*
* Bolt forms Northbound responses
*/
NorthboundReplyBolt northboundReplyBolt = new NorthboundReplyBolt();
builder.setBolt(ComponentType.NORTHBOUND_REPLY_BOLT.toString(), northboundReplyBolt, parallelism).shuffleGrouping(ComponentType.CRUD_BOLT.toString(), StreamType.RESPONSE.toString()).shuffleGrouping(ComponentType.ERROR_BOLT.toString(), StreamType.RESPONSE.toString());
/*
* Bolt sends Northbound responses
*/
KafkaBolt northboundKafkaBolt = createKafkaBolt(config.getKafkaNorthboundTopic());
builder.setBolt(ComponentType.NORTHBOUND_KAFKA_BOLT.toString(), northboundKafkaBolt, parallelism).shuffleGrouping(ComponentType.NORTHBOUND_REPLY_BOLT.toString(), StreamType.RESPONSE.toString());
createCtrlBranch(builder, ctrlTargets);
createHealthCheckHandler(builder, ServiceType.FLOW_TOPOLOGY.getId());
return builder.createTopology();
}
Aggregations