Search in sources :

Example 1 with DataAdapter

use of org.openkilda.rulemanager.DataAdapter in project open-kilda by telstra.

the class YFlowRuleManagerProcessingAction method buildYFlowSpeakerData.

private Map<SwitchId, List<SpeakerData>> buildYFlowSpeakerData(YFlow yFlow) {
    List<FlowPath> flowPaths = yFlow.getSubFlows().stream().map(YSubFlow::getFlow).map(Flow::getPaths).flatMap(Collection::stream).collect(toList());
    Set<SwitchId> switchIds = Sets.newHashSet(yFlow.getSharedEndpoint().getSwitchId(), yFlow.getYPoint(), yFlow.getProtectedPathYPoint());
    Set<PathId> pathIds = flowPaths.stream().map(FlowPath::getPathId).collect(Collectors.toSet());
    DataAdapter dataAdapter = PersistenceDataAdapter.builder().persistenceManager(persistenceManager).switchIds(switchIds).pathIds(pathIds).build();
    return ruleManager.buildRulesForYFlow(flowPaths, dataAdapter).stream().collect(Collectors.groupingBy(SpeakerData::getSwitchId, Collectors.mapping(Function.identity(), toList())));
}
Also used : PathId(org.openkilda.model.PathId) DataAdapter(org.openkilda.rulemanager.DataAdapter) PersistenceDataAdapter(org.openkilda.rulemanager.adapter.PersistenceDataAdapter) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow)

Example 2 with DataAdapter

use of org.openkilda.rulemanager.DataAdapter 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)

Aggregations

Flow (org.openkilda.model.Flow)2 PathId (org.openkilda.model.PathId)2 SwitchId (org.openkilda.model.SwitchId)2 YFlow (org.openkilda.model.YFlow)2 DataAdapter (org.openkilda.rulemanager.DataAdapter)2 PersistenceDataAdapter (org.openkilda.rulemanager.adapter.PersistenceDataAdapter)2 String.format (java.lang.String.format)1 Collections.singleton (java.util.Collections.singleton)1 List (java.util.List)1 UUID (java.util.UUID)1 Collectors.toList (java.util.stream.Collectors.toList)1 Stream (java.util.stream.Stream)1 Slf4j (lombok.extern.slf4j.Slf4j)1 DeleteSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest)1 FlowCommand (org.openkilda.floodlight.api.request.rulemanager.FlowCommand)1 InstallSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest)1 OfCommand (org.openkilda.floodlight.api.request.rulemanager.OfCommand)1 MessageContext (org.openkilda.messaging.MessageContext)1 ErrorType (org.openkilda.messaging.error.ErrorType)1 FlowPath (org.openkilda.model.FlowPath)1