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();
}
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();
}
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();
}
Aggregations