Search in sources :

Example 31 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class RuleManagerImpl method buildIngressYFlowCommands.

private List<SpeakerData> buildIngressYFlowCommands(FlowPath flowPath, FlowPath altFlowPath, DataAdapter adapter) {
    Flow flow = adapter.getFlow(flowPath.getPathId());
    Flow altFlow = adapter.getFlow(altFlowPath.getPathId());
    if (flow.isProtectedPath(flowPath.getPathId()) || altFlow.isProtectedPath(altFlowPath.getPathId())) {
        return Collections.emptyList();
    }
    YFlow yFlow = adapter.getYFlow(flowPath.getPathId());
    if (yFlow == null) {
        return Collections.emptyList();
    }
    SwitchId sharedSwitchId = yFlow.getSharedEndpoint().getSwitchId();
    Switch sharedSwitch = adapter.getSwitch(sharedSwitchId);
    if (sharedSwitch == null || !sharedSwitchId.equals(flowPath.getSrcSwitchId()) || !sharedSwitchId.equals(altFlowPath.getSrcSwitchId())) {
        return Collections.emptyList();
    }
    FlowTransitEncapsulation encapsulation = getFlowTransitEncapsulation(flowPath.getPathId(), flow, adapter);
    FlowTransitEncapsulation altEncapsulation = getFlowTransitEncapsulation(altFlowPath.getPathId(), altFlow, adapter);
    MeterId sharedMeterId = yFlow.getSharedEndpointMeterId();
    RuleGenerator generator = flowRulesFactory.getIngressYRuleGenerator(flowPath, flow, encapsulation, new HashSet<>(), altFlowPath, altFlow, altEncapsulation, new HashSet<>(), sharedMeterId);
    return generator.generateCommands(sharedSwitch);
}
Also used : YFlow(org.openkilda.model.YFlow) Switch(org.openkilda.model.Switch) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) RuleGenerator(org.openkilda.rulemanager.factory.RuleGenerator) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) MeterId(org.openkilda.model.MeterId)

Example 32 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class RuleManagerImpl method buildTransitYFlowCommands.

private List<SpeakerData> buildTransitYFlowCommands(FlowPath flowPath, FlowPath altFlowPath, DataAdapter adapter) {
    Flow flow = adapter.getFlow(flowPath.getPathId());
    Flow altFlow = adapter.getFlow(altFlowPath.getPathId());
    YFlow yFlow = adapter.getYFlow(flowPath.getPathId());
    if (yFlow == null) {
        return Collections.emptyList();
    }
    SwitchId sharedSwitchId = yFlow.getSharedEndpoint().getSwitchId();
    if (sharedSwitchId.equals(flowPath.getSrcSwitchId()) || sharedSwitchId.equals(altFlowPath.getSrcSwitchId())) {
        return Collections.emptyList();
    }
    SwitchId yPointSwitchId = yFlow.getYPoint();
    MeterId yPointMeterId = yFlow.getMeterId();
    if (flow.isProtectedPath(flowPath.getPathId()) && altFlow.isProtectedPath(altFlowPath.getPathId())) {
        yPointSwitchId = yFlow.getProtectedPathYPoint();
        yPointMeterId = yFlow.getProtectedPathMeterId();
    }
    Switch yPointSwitch = adapter.getSwitch(yPointSwitchId);
    if (yPointSwitch == null) {
        return Collections.emptyList();
    }
    FlowTransitEncapsulation encapsulation = getFlowTransitEncapsulation(flowPath.getPathId(), flow, adapter);
    FlowTransitEncapsulation altEncapsulation = getFlowTransitEncapsulation(altFlowPath.getPathId(), altFlow, adapter);
    SwitchPathSegments switchPathSegments = findPathSegmentsForSwitch(yPointSwitchId, flowPath.getSegments());
    SwitchPathSegments altSwitchPathSegments = findPathSegmentsForSwitch(yPointSwitchId, altFlowPath.getSegments());
    if (switchPathSegments == null || altSwitchPathSegments == null) {
        return Collections.emptyList();
    }
    RuleGenerator generator = flowRulesFactory.getTransitYRuleGenerator(flowPath, encapsulation, switchPathSegments.getFirstPathSegment(), switchPathSegments.getSecondPathSegment(), altFlowPath, altEncapsulation, altSwitchPathSegments.getFirstPathSegment(), altSwitchPathSegments.getSecondPathSegment(), yPointMeterId);
    return generator.generateCommands(yPointSwitch);
}
Also used : YFlow(org.openkilda.model.YFlow) Switch(org.openkilda.model.Switch) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) RuleGenerator(org.openkilda.rulemanager.factory.RuleGenerator) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) MeterId(org.openkilda.model.MeterId)

Example 33 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class KildaEntryCacheService method refreshYFlowsCache.

private void refreshYFlowsCache() {
    CacheAddUpdateHandler cacheHandler = new CacheAddUpdateHandler(cookieToFlow, switchAndMeterToFlow);
    for (YFlow entry : yFlowRepository.findAll()) {
        if (entry.getSharedEndpointMeterId() == null) {
            continue;
        }
        if (entry.getMeterId() == null) {
            continue;
        }
        updateCache(cacheHandler, entry.getYFlowId(), entry.getSharedEndpoint().getSwitchId(), entry.getSharedEndpointMeterId(), MeasurePoint.Y_FLOW_SHARED);
        updateCache(cacheHandler, entry.getYFlowId(), entry.getYPoint(), entry.getMeterId(), MeasurePoint.Y_FLOW_Y_POINT);
    }
}
Also used : YFlow(org.openkilda.model.YFlow)

Example 34 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class TestYFlowBuilder method build.

/**
 * Build {@link YFlow} instance.
 */
public YFlow build() {
    boolean allocateProtectedPath = false;
    if (protectedPathYPoint != null || protectedPathMeterId != null) {
        checkArgument(protectedPathYPoint != null && protectedPathMeterId != null, "Insufficient data provided to make YFlow with protected path");
        allocateProtectedPath = true;
    }
    YFlow.YFlowBuilder yFlowBuilder = YFlow.builder().yFlowId(yFlowId).sharedEndpoint(sharedEndpoint).sharedEndpointMeterId(sharedEndpointMeterId).yPoint(yPoint).meterId(meterId).allocateProtectedPath(allocateProtectedPath).maximumBandwidth(maximumBandwidth).ignoreBandwidth(ignoreBandwidth).strictBandwidth(strictBandwidth).description(description).periodicPings(periodicPings).encapsulationType(encapsulationType).status(status).maxLatency(maxLatency).maxLatencyTier2(maxLatencyTier2).priority(priority).pinned(pinned).pathComputationStrategy(pathComputationStrategy);
    if (allocateProtectedPath) {
        yFlowBuilder = yFlowBuilder.protectedPathYPoint(protectedPathYPoint).protectedPathMeterId(protectedPathMeterId);
    }
    YFlow yFlow = yFlowBuilder.build();
    Set<YSubFlow> subFlowsGoal = new HashSet<>();
    for (TestYSubFlowBuilder subFlowBuilder : subFlows) {
        subFlowsGoal.add(subFlowBuilder.yFlow(yFlow).build());
    }
    yFlow.setSubFlows(subFlowsGoal);
    yFlow.setTimeCreate(timeCreate);
    yFlow.setTimeModify(timeModify);
    return yFlow;
}
Also used : YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow) HashSet(java.util.HashSet)

Example 35 with YFlow

use of org.openkilda.model.YFlow in project open-kilda by telstra.

the class UpdateYFlowAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowUpdateContext context, YFlowUpdateFsm stateMachine) {
    YFlowRequest targetFlow = stateMachine.getTargetFlow();
    stateMachine.setDiverseFlowId(targetFlow.getDiverseFlowId());
    FlowStatus flowStatus = transactionManager.doInTransaction(() -> {
        YFlow yFlow = getYFlow(targetFlow.getYFlowId());
        saveOldResources(stateMachine, yFlow);
        stateMachine.setDeleteOldYFlowCommands(buildYFlowDeleteCommands(yFlow, stateMachine.getCommandContext()));
        updateFlow(yFlow, YFlowRequestMapper.INSTANCE.toYFlow(targetFlow));
        return yFlow.getStatus();
    });
    stateMachine.saveActionToHistory(format("The y-flow was updated. The status %s", flowStatus));
}
Also used : YFlow(org.openkilda.model.YFlow) YFlowRequest(org.openkilda.messaging.command.yflow.YFlowRequest) FlowStatus(org.openkilda.model.FlowStatus)

Aggregations

YFlow (org.openkilda.model.YFlow)74 Flow (org.openkilda.model.Flow)30 SwitchId (org.openkilda.model.SwitchId)29 YSubFlow (org.openkilda.model.YSubFlow)26 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)19 Test (org.junit.Test)12 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)12 ArrayList (java.util.ArrayList)11 FlowStatus (org.openkilda.model.FlowStatus)10 CommandContext (org.openkilda.wfm.CommandContext)10 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)10 FlowPath (org.openkilda.model.FlowPath)9 FlowEndpoint (org.openkilda.model.FlowEndpoint)8 InstallSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.InstallSpeakerCommandsRequest)6 Switch (org.openkilda.model.Switch)6 HashSet (java.util.HashSet)5 DeleteSpeakerCommandsRequest (org.openkilda.floodlight.api.request.rulemanager.DeleteSpeakerCommandsRequest)5 SharedEndpoint (org.openkilda.model.YFlow.SharedEndpoint)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4