Search in sources :

Example 21 with PersistenceManager

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());
}
Also used : FlowProcessingWithHistorySupportAction(org.openkilda.wfm.topology.flowhs.fsm.common.actions.FlowProcessingWithHistorySupportAction) DeleteSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest) Collections.singleton(java.util.Collections.singleton) InstallSpeakerCommandsRequest(org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) PersistenceManager(org.openkilda.persistence.PersistenceManager) PathId(org.openkilda.model.PathId) FlowPathSwapContext(org.openkilda.wfm.topology.flowhs.fsm.pathswap.FlowPathSwapContext) FlowCommand(org.openkilda.floodlight.api.request.rulemanager.FlowCommand) FlowPathSwapFsm(org.openkilda.wfm.topology.flowhs.fsm.pathswap.FlowPathSwapFsm) State(org.openkilda.wfm.topology.flowhs.fsm.pathswap.FlowPathSwapFsm.State) ErrorType(org.openkilda.messaging.error.ErrorType) DataAdapter(org.openkilda.rulemanager.DataAdapter) MessageContext(org.openkilda.messaging.MessageContext) PersistenceDataAdapter(org.openkilda.rulemanager.adapter.PersistenceDataAdapter) CommandContext(org.openkilda.wfm.CommandContext) Event(org.openkilda.wfm.topology.flowhs.fsm.pathswap.FlowPathSwapFsm.Event) SpeakerData(org.openkilda.rulemanager.SpeakerData) UUID(java.util.UUID) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) String.format(java.lang.String.format) OfCommand(org.openkilda.floodlight.api.request.rulemanager.OfCommand) RuleManager(org.openkilda.rulemanager.RuleManager) YFlowRepository(org.openkilda.persistence.repositories.YFlowRepository) Collectors.toList(java.util.stream.Collectors.toList) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Stream(java.util.stream.Stream) SwitchId(org.openkilda.model.SwitchId) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) FlowCommand(org.openkilda.floodlight.api.request.rulemanager.FlowCommand) DataAdapter(org.openkilda.rulemanager.DataAdapter) PersistenceDataAdapter(org.openkilda.rulemanager.adapter.PersistenceDataAdapter) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

Example 22 with PersistenceManager

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();
}
Also used : SpeakerWorkerBolt(org.openkilda.wfm.topology.switchmanager.bolt.SpeakerWorkerBolt) TopologyBuilder(org.apache.storm.topology.TopologyBuilder) PersistenceManager(org.openkilda.persistence.PersistenceManager) HubBolt(org.openkilda.wfm.share.hubandspoke.HubBolt) CoordinatorSpout(org.openkilda.wfm.share.hubandspoke.CoordinatorSpout) CoordinatorBolt(org.openkilda.wfm.share.hubandspoke.CoordinatorBolt) WorkerBolt(org.openkilda.wfm.share.hubandspoke.WorkerBolt) SpeakerWorkerBolt(org.openkilda.wfm.topology.switchmanager.bolt.SpeakerWorkerBolt) ZooKeeperSpout(org.openkilda.wfm.share.zk.ZooKeeperSpout) ZooKeeperBolt(org.openkilda.wfm.share.zk.ZooKeeperBolt) SwitchManagerHub(org.openkilda.wfm.topology.switchmanager.bolt.SwitchManagerHub)

Aggregations

PersistenceManager (org.openkilda.persistence.PersistenceManager)22 RepositoryFactory (org.openkilda.persistence.repositories.RepositoryFactory)13 YFlowRepository (org.openkilda.persistence.repositories.YFlowRepository)11 Test (org.junit.Test)10 FlowRepository (org.openkilda.persistence.repositories.FlowRepository)9 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)8 TopologyBuilder (org.apache.storm.topology.TopologyBuilder)6 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)6 PathSegmentRepository (org.openkilda.persistence.repositories.PathSegmentRepository)5 RerouteAffectedFlows (org.openkilda.messaging.command.reroute.RerouteAffectedFlows)3 PathNode (org.openkilda.messaging.info.event.PathNode)3 BeforeClass (org.junit.BeforeClass)2 YFlowRerouteRequest (org.openkilda.messaging.command.yflow.YFlowRerouteRequest)2 FlowPath (org.openkilda.model.FlowPath)2 PathSegment (org.openkilda.model.PathSegment)2 CoordinatorBolt (org.openkilda.wfm.share.hubandspoke.CoordinatorBolt)2 CoordinatorSpout (org.openkilda.wfm.share.hubandspoke.CoordinatorSpout)2 HubBolt (org.openkilda.wfm.share.hubandspoke.HubBolt)2 WorkerBolt (org.openkilda.wfm.share.hubandspoke.WorkerBolt)2 ZooKeeperBolt (org.openkilda.wfm.share.zk.ZooKeeperBolt)2