Search in sources :

Example 1 with SwitchFlowEntriesBuilder

use of org.openkilda.wfm.topology.flowhs.fsm.validation.SwitchFlowEntriesBuilder in project open-kilda by telstra.

the class YFlowSwitchFlowEntriesBuilder method getGroupEntries.

/**
 * Construct a set of {@link GroupEntry} that corresponds to the builder's y-flow.
 */
public Map<SwitchId, Collection<GroupEntry>> getGroupEntries() {
    MultiValuedMap<SwitchId, GroupEntry> groupEntries = new ArrayListValuedHashMap<>();
    yFlow.getSubFlows().forEach(subFlow -> {
        Flow flow = subFlow.getFlow();
        SwitchFlowEntriesBuilder builder = new SwitchFlowEntriesBuilder(flow);
        builder.getSwitchGroupEntries().forEach(entries -> groupEntries.putAll(entries.getSwitchId(), entries.getGroupEntries()));
    });
    return groupEntries.asMap();
}
Also used : GroupEntry(org.openkilda.messaging.info.rule.GroupEntry) SwitchFlowEntriesBuilder(org.openkilda.wfm.topology.flowhs.fsm.validation.SwitchFlowEntriesBuilder) SwitchId(org.openkilda.model.SwitchId) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow)

Example 2 with SwitchFlowEntriesBuilder

use of org.openkilda.wfm.topology.flowhs.fsm.validation.SwitchFlowEntriesBuilder in project open-kilda by telstra.

the class YFlowSwitchFlowEntriesBuilder method getMeterEntries.

/**
 * Construct a set of {@link MeterEntry} that corresponds to the builder's y-flow.
 */
public Map<SwitchId, Collection<MeterEntry>> getMeterEntries() {
    MultiValuedMap<SwitchId, MeterEntry> meterEntries = new ArrayListValuedHashMap<>();
    yFlow.getSubFlows().forEach(subFlow -> {
        Flow flow = subFlow.getFlow();
        SwitchFlowEntriesBuilder builder = new SwitchFlowEntriesBuilder(flow);
        builder.getSwitchMeterEntries().forEach(entries -> meterEntries.putAll(entries.getSwitchId(), entries.getMeterEntries()));
        FlowPath forwardPath = flow.getForwardPath();
        meterEntries.put(flow.getSrcSwitchId(), MeterEntry.builder().meterId(yFlow.getSharedEndpointMeterId().getValue()).rate(forwardPath.getBandwidth()).burstSize(Meter.calculateBurstSize(forwardPath.getBandwidth(), MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT, "")).flags(Meter.getMeterKbpsFlags()).build());
        if (!yFlow.getYPoint().equals(flow.getSrcSwitchId())) {
            FlowPath reversePath = flow.getReversePath();
            meterEntries.put(yFlow.getYPoint(), MeterEntry.builder().meterId(yFlow.getMeterId().getValue()).rate(reversePath.getBandwidth()).burstSize(Meter.calculateBurstSize(reversePath.getBandwidth(), MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT, "")).flags(Meter.getMeterKbpsFlags()).build());
        }
        if (yFlow.isAllocateProtectedPath() && yFlow.getProtectedPathYPoint() != null && !yFlow.getProtectedPathYPoint().equals(flow.getSrcSwitchId())) {
            FlowPath reversePath = flow.getProtectedReversePath();
            meterEntries.put(yFlow.getProtectedPathYPoint(), MeterEntry.builder().meterId(yFlow.getProtectedPathMeterId().getValue()).rate(reversePath.getBandwidth()).burstSize(Meter.calculateBurstSize(reversePath.getBandwidth(), MIN_BURST_SIZE_IN_KBITS, BURST_COEFFICIENT, "")).flags(Meter.getMeterKbpsFlags()).build());
        }
    });
    return meterEntries.asMap();
}
Also used : SwitchFlowEntriesBuilder(org.openkilda.wfm.topology.flowhs.fsm.validation.SwitchFlowEntriesBuilder) MeterEntry(org.openkilda.messaging.info.meter.MeterEntry) SwitchId(org.openkilda.model.SwitchId) FlowPath(org.openkilda.model.FlowPath) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow)

Example 3 with SwitchFlowEntriesBuilder

use of org.openkilda.wfm.topology.flowhs.fsm.validation.SwitchFlowEntriesBuilder in project open-kilda by telstra.

the class YFlowSwitchFlowEntriesBuilder method getFlowEntries.

/**
 * Construct a set of {@link FlowEntry} that corresponds to the builder's y-flow.
 */
public Map<SwitchId, Collection<FlowEntry>> getFlowEntries() {
    MultiValuedMap<SwitchId, FlowEntry> flowEntries = new ArrayListValuedHashMap<>();
    yFlow.getSubFlows().forEach(subFlow -> {
        Flow flow = subFlow.getFlow();
        SwitchFlowEntriesBuilder builder = new SwitchFlowEntriesBuilder(flow);
        int forwardTransitEncId = getEncapsulationId(flow.getEncapsulationType(), flow.getForwardPathId()).orElseThrow(IllegalStateException::new);
        int reverseTransitEncId = getEncapsulationId(flow.getEncapsulationType(), flow.getReversePathId()).orElseThrow(IllegalStateException::new);
        Integer protectedForwardTransitEncId = getEncapsulationId(flow.getEncapsulationType(), flow.getProtectedForwardPathId()).orElse(null);
        Integer protectedReverseTransitEncId = getEncapsulationId(flow.getEncapsulationType(), flow.getProtectedReversePathId()).orElse(null);
        builder.getSwitchFlowEntries(forwardTransitEncId, reverseTransitEncId, protectedForwardTransitEncId, protectedReverseTransitEncId).forEach(entries -> flowEntries.putAll(entries.getSwitchId(), entries.getFlowEntries()));
        FlowPath forwardPath = flow.getForwardPath();
        PathSegment firstSegment = forwardPath.getSegments().get(0);
        FlowSegmentCookie forwardCookie = forwardPath.getCookie().toBuilder().yFlow(true).build();
        boolean isVxlan = flow.getEncapsulationType() == VXLAN;
        flowEntries.put(forwardPath.getSrcSwitchId(), builder.getFlowEntry(forwardCookie.getValue(), flow.getSrcPort(), flow.getSrcVlan(), null, firstSegment.getSrcPort(), isVxlan ? null : forwardTransitEncId, isVxlan ? forwardTransitEncId : null, yFlow.getSharedEndpointMeterId().getValue()));
        if (!yFlow.getYPoint().equals(flow.getSrcSwitchId())) {
            FlowPath reversePath = flow.getReversePath();
            FlowSegmentCookie reverseCookie = reversePath.getCookie().toBuilder().yFlow(true).build();
            List<PathSegment> reverseSegments = reversePath.getSegments();
            for (int i = 0; i < reverseSegments.size() - 1; i++) {
                PathSegment nsegment = reverseSegments.get(i);
                PathSegment n1segment = reverseSegments.get(i + 1);
                if (nsegment.getDestSwitchId().equals(yFlow.getYPoint())) {
                    flowEntries.put(yFlow.getYPoint(), builder.getFlowEntry(reverseCookie.getValue(), n1segment.getSrcPort(), isVxlan ? null : reverseTransitEncId, isVxlan ? reverseTransitEncId : null, nsegment.getDestPort(), null, null, yFlow.getMeterId().getValue()));
                }
            }
        }
        if (yFlow.isAllocateProtectedPath() && yFlow.getProtectedPathYPoint() != null && !yFlow.getProtectedPathYPoint().equals(flow.getSrcSwitchId())) {
            FlowPath reversePath = flow.getProtectedReversePath();
            FlowSegmentCookie reverseCookie = reversePath.getCookie().toBuilder().yFlow(true).build();
            List<PathSegment> reverseSegments = reversePath.getSegments();
            for (int i = 0; i < reverseSegments.size() - 1; i++) {
                PathSegment nsegment = reverseSegments.get(i);
                PathSegment n1segment = reverseSegments.get(i + 1);
                if (nsegment.getDestSwitchId().equals(yFlow.getProtectedPathYPoint())) {
                    flowEntries.put(yFlow.getProtectedPathYPoint(), builder.getFlowEntry(reverseCookie.getValue(), n1segment.getSrcPort(), isVxlan ? null : reverseTransitEncId, isVxlan ? reverseTransitEncId : null, nsegment.getDestPort(), null, null, yFlow.getProtectedPathMeterId().getValue()));
                }
            }
        }
    });
    return flowEntries.asMap();
}
Also used : FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) SwitchId(org.openkilda.model.SwitchId) PathSegment(org.openkilda.model.PathSegment) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) SwitchFlowEntriesBuilder(org.openkilda.wfm.topology.flowhs.fsm.validation.SwitchFlowEntriesBuilder) FlowPath(org.openkilda.model.FlowPath) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) ArrayListValuedHashMap(org.apache.commons.collections4.multimap.ArrayListValuedHashMap)

Aggregations

ArrayListValuedHashMap (org.apache.commons.collections4.multimap.ArrayListValuedHashMap)3 Flow (org.openkilda.model.Flow)3 SwitchId (org.openkilda.model.SwitchId)3 YFlow (org.openkilda.model.YFlow)3 SwitchFlowEntriesBuilder (org.openkilda.wfm.topology.flowhs.fsm.validation.SwitchFlowEntriesBuilder)3 FlowPath (org.openkilda.model.FlowPath)2 MeterEntry (org.openkilda.messaging.info.meter.MeterEntry)1 FlowEntry (org.openkilda.messaging.info.rule.FlowEntry)1 GroupEntry (org.openkilda.messaging.info.rule.GroupEntry)1 PathSegment (org.openkilda.model.PathSegment)1 FlowSegmentCookie (org.openkilda.model.cookie.FlowSegmentCookie)1