use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.
the class UpdateYFlowRulesAction method buildYFlowOfCommands.
private List<OfCommand> buildYFlowOfCommands(SwitchId switchId, PathId pathId) {
DataAdapter dataAdapter = PersistenceDataAdapter.builder().persistenceManager(persistenceManager).switchIds(singleton(switchId)).pathIds(singleton(pathId)).build();
List<SpeakerData> speakerData = ruleManager.buildRulesForSwitch(switchId, dataAdapter);
return speakerData.stream().filter(data -> data instanceof FlowSpeakerData).map(data -> new FlowCommand((FlowSpeakerData) data)).collect(toList());
}
use of org.openkilda.persistence.PersistenceManager in project open-kilda by telstra.
the class SwitchManagerTopology method createTopology.
@Override
public StormTopology createTopology() {
logger.info("Creating SwitchManagerTopology - {}", topologyName);
TopologyBuilder builder = new TopologyBuilder();
ZooKeeperSpout zooKeeperSpout = new ZooKeeperSpout(getConfig().getBlueGreenMode(), getZkTopoName(), getZookeeperConfig());
declareSpout(builder, zooKeeperSpout, ZooKeeperSpout.SPOUT_ID);
declareSpout(builder, new CoordinatorSpout(), CoordinatorSpout.ID);
declareBolt(builder, new CoordinatorBolt(), CoordinatorBolt.ID).allGrouping(CoordinatorSpout.ID).fieldsGrouping(SwitchManagerHub.ID, CoordinatorBolt.INCOME_STREAM, FIELDS_KEY);
PersistenceManager persistenceManager = new PersistenceManager(configurationProvider);
HubBolt.Config hubConfig = HubBolt.Config.builder().requestSenderComponent(HUB_SPOUT).workerComponent(SpeakerWorkerBolt.ID).lifeCycleEventComponent(ZooKeeperSpout.SPOUT_ID).timeoutMs((int) TimeUnit.SECONDS.toMillis(topologyConfig.getProcessTimeout())).build();
List<String> inputTopics = Lists.newArrayList(topologyConfig.getKafkaSwitchManagerNbTopic(), topologyConfig.getKafkaSwitchManagerNetworkTopic(), topologyConfig.getKafkaSwitchManagerNbWorkerTopic());
declareKafkaSpout(builder, inputTopics, HUB_SPOUT);
declareBolt(builder, new SwitchManagerHub(hubConfig, persistenceManager, topologyConfig, configurationProvider.getConfiguration(FlowResourcesConfig.class), configurationProvider.getConfiguration(RuleManagerConfig.class)), SwitchManagerHub.ID).allGrouping(ZooKeeperSpout.SPOUT_ID).fieldsGrouping(HUB_SPOUT, FIELDS_KEY).directGrouping(SpeakerWorkerBolt.ID, SwitchManagerHub.INCOME_STREAM).directGrouping(CoordinatorBolt.ID);
WorkerBolt.Config speakerWorkerConfig = WorkerBolt.Config.builder().hubComponent(SwitchManagerHub.ID).streamToHub(SwitchManagerHub.INCOME_STREAM).workerSpoutComponent(WORKER_SPOUT).defaultTimeout((int) TimeUnit.SECONDS.toMillis(topologyConfig.getOperationTimeout())).build();
declareKafkaSpout(builder, Lists.newArrayList(topologyConfig.getKafkaSwitchManagerTopic(), topologyConfig.getGrpcResponseTopic()), WORKER_SPOUT);
declareBolt(builder, new SpeakerWorkerBolt(speakerWorkerConfig), SpeakerWorkerBolt.ID).fieldsGrouping(WORKER_SPOUT, FIELDS_KEY).fieldsGrouping(SwitchManagerHub.ID, SpeakerWorkerBolt.INCOME_STREAM, FIELDS_KEY).directGrouping(CoordinatorBolt.ID);
declareBolt(builder, buildKafkaBolt(topologyConfig.getKafkaNorthboundTopic()), NB_KAFKA_BOLT).shuffleGrouping(SwitchManagerHub.ID, StreamType.TO_NORTHBOUND.toString());
declareBolt(builder, buildKafkaBolt(topologyConfig.getKafkaSpeakerTopic()), SPEAKER_KAFKA_BOLT).shuffleGrouping(SpeakerWorkerBolt.ID, StreamType.TO_FLOODLIGHT.toString());
declareBolt(builder, buildKafkaBolt(topologyConfig.getGrpcSpeakerTopic()), GRPC_SPEAKER_KAFKA_BOLT).shuffleGrouping(SpeakerWorkerBolt.ID, StreamType.TO_GRPC.toString());
ZooKeeperBolt zooKeeperBolt = new ZooKeeperBolt(getConfig().getBlueGreenMode(), getZkTopoName(), getZookeeperConfig(), getBoltInstancesCount(SwitchManagerHub.ID));
declareBolt(builder, zooKeeperBolt, ZooKeeperBolt.BOLT_ID).allGrouping(SwitchManagerHub.ID, ZkStreams.ZK.toString());
metrics(builder);
return builder.createTopology();
}
Aggregations