16 package org.openkilda.atdd.staging.helpers;
31 import java.util.HashMap;
33 import java.util.Optional;
39 private Map<NetworkEndpoint, TraffGen> endpointToTraffGen =
new HashMap<>();
42 this.traffExam = traffExam;
44 for (TraffGen traffGen :
topology.getActiveTraffGens()) {
46 traffGen.getSwitchConnected().getDpId(), traffGen.getSwitchPort());
47 endpointToTraffGen.put(endpoint, traffGen);
56 Optional<TraffGen>
source = Optional.ofNullable(
57 endpointToTraffGen.get(makeComparableEndpoint(flow.getSource())));
58 Optional<TraffGen> dest = Optional.ofNullable(
59 endpointToTraffGen.get(makeComparableEndpoint(flow.getDestination())));
61 checkIsFlowApplicable(flow,
source.isPresent(), dest.isPresent());
73 .sourceVlan(
new Vlan(flow.getSource().getVlanId()))
75 .destVlan(
new Vlan(flow.getDestination().getVlanId()))
82 .sourceVlan(
new Vlan(flow.getDestination().getVlanId()))
84 .destVlan(
new Vlan(flow.getSource().getVlanId()))
96 Optional<TraffGen>
source = Optional.ofNullable(
97 endpointToTraffGen.get(makeComparableEndpoint(flow.getSource())));
98 Optional<TraffGen> dest = Optional.ofNullable(
99 endpointToTraffGen.get(makeComparableEndpoint(flow.getDestination())));
101 checkIsFlowApplicable(flow,
source.isPresent(), dest.isPresent());
110 return Exam.builder()
113 .sourceVlan(
new Vlan(flow.getSource().getVlanId()))
115 .destVlan(
new Vlan(flow.getDestination().getVlanId()))
116 .bandwidthLimit(
new Bandwidth(bandwidth))
121 private void checkIsFlowApplicable(
FlowPayload flow,
boolean sourceApplicable,
boolean destApplicable)
125 if (!sourceApplicable && !destApplicable) {
126 message =
"source endpoint and destination endpoint are";
127 }
else if (!sourceApplicable) {
128 message =
"source endpoint is";
129 }
else if (!destApplicable) {
130 message =
"dest endpoint is";
135 if (message != null) {
136 throw new FlowNotApplicableException(String.format(
137 "Flow's %s %s not applicable for traffic examination.", flow.getId(), message));
141 private NetworkEndpoint makeComparableEndpoint(FlowEndpointPayload flowEndpoint) {
142 return new NetworkEndpoint(flowEndpoint);
FlowTrafficExamBuilder(TopologyDefinition topology, TraffExamService traffExam)
FlowBidirectionalExam buildBidirectionalExam(FlowPayload flow, int bandwidth)
Host hostByName(String name)
Exam buildExam(FlowPayload flow, int bandwidth)