use of org.openkilda.messaging.model.FlowDirection in project open-kilda by telstra.
the class PingProducer method buildPing.
private Ping buildPing(PingContext pingContext, FlowDirection direction) {
Flow flow = pingContext.getFlow();
FlowEndpoint ingress;
FlowEndpoint egress;
int islPort;
if (FlowDirection.FORWARD == direction) {
ingress = new FlowSourceAdapter(flow).getEndpoint();
egress = new FlowDestAdapter(flow).getEndpoint();
islPort = getIslPort(flow, flow.getForwardPath());
} else if (FlowDirection.REVERSE == direction) {
ingress = new FlowDestAdapter(flow).getEndpoint();
egress = new FlowSourceAdapter(flow).getEndpoint();
islPort = getIslPort(flow, flow.getReversePath());
} else {
throw new IllegalArgumentException(String.format("Unexpected %s value: %s", FlowDirection.class.getCanonicalName(), direction));
}
return new Ping(new NetworkEndpoint(ingress.getSwitchId(), ingress.getPortNumber()), new NetworkEndpoint(egress.getSwitchId(), egress.getPortNumber()), pingContext.getTransitEncapsulation(), islPort);
}
Aggregations