use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.
the class FlowUtils method getFlowPath.
/**
* Gets flow path through Northbound service.
*
* @param flowId flow id
* @return The JSON document of the specified flow path
*/
public static FlowPathPayload getFlowPath(final String flowId) {
System.out.println("\n==> Northbound Get Flow Path");
long current = System.currentTimeMillis();
Client client = clientFactory();
Response response = client.target(northboundEndpoint).path("/api/v1/flows/path").path("{flowid}").resolveTemplate("flowid", flowId).request(MediaType.APPLICATION_JSON).header(HttpHeaders.AUTHORIZATION, authHeaderValue).header(Utils.CORRELATION_ID, String.valueOf(System.currentTimeMillis())).get();
System.out.println(format("===> Response = %s", response.toString()));
System.out.println(format("===> Northbound Get Flow Path Time: %,.3f", getTimeDuration(current)));
int responseCode = response.getStatus();
if (responseCode == 200) {
FlowPathPayload flowPath = response.readEntity(FlowPathPayload.class);
System.out.println(format("====> Northbound Get Flow Path = %s", flowPath));
return flowPath;
} else {
System.out.println(format("====> Error: Northbound Get Flow Path = %s", response.readEntity(MessageError.class)));
return null;
}
}
use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.
the class FlowServiceImpl method pathFlow.
/**
* {@inheritDoc}
*/
@Override
public InfoMessage pathFlow(final FlowIdStatusPayload payload, final String correlationId) {
Set<Flow> flows = flowRepository.findByFlowId(payload.getId());
FlowPathPayload flowPathPayload = null;
for (Flow flow : flows) {
if ((flow.getCookie() & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
flowPathPayload = new FlowPathPayload(flow.getFlowId(), flow.getFlowPath());
}
}
logger.debug("Flow with id={} path: {}", payload.getId(), flowPathPayload);
return new InfoMessage(new FlowPathResponse(flowPathPayload), System.currentTimeMillis(), correlationId, Destination.WFM);
}
use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.
the class FlowFFRTest method getFlowPath.
private FlowPathPayload getFlowPath(String flowName, PathInfoData expectedPath) throws Exception {
FlowPathPayload payload = FlowUtils.getFlowPath(flowName);
for (int i = 0; i < 10; i++) {
payload = FlowUtils.getFlowPath(flowName);
if (payload != null && expectedPath.equals(payload.getPath())) {
break;
}
TimeUnit.SECONDS.sleep(2);
}
return payload;
}
use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.
the class FlowFFRTest method flowPathIsAlternate.
@When("^flow (.+) path is alternate$")
public void flowPathIsAlternate(String flowId) throws Throwable {
String flowName = FlowUtils.getFlowName(flowId);
FlowPathPayload payload = getFlowPath(flowName, FlowPathTest.expectedAlternatePath.getLeft());
assertNotNull(payload);
assertEquals(flowName, payload.getId());
assertEquals(FlowPathTest.expectedAlternatePath.getLeft(), payload.getPath());
}
use of org.openkilda.messaging.payload.flow.FlowPathPayload in project open-kilda by telstra.
the class FlowReinstallTest method flowPathContainsSwitch.
@Then("^flow (.*) is(.*) built through (.*) switch")
public void flowPathContainsSwitch(final String flow, final String shouldNotContain, final String switchId) throws InterruptedException {
await().atMost(20, TimeUnit.SECONDS).pollInterval(Duration.ONE_SECOND).until(() -> {
FlowPathPayload payload = FlowUtils.getFlowPath(FlowUtils.getFlowName(flow));
assertTrue("Flow path should exist", payload != null && payload.getPath() != null);
List<PathNode> path = payload.getPath().getPath();
boolean contains = path.stream().anyMatch(node -> switchId.equalsIgnoreCase(node.getSwitchId()));
if (StringUtils.isBlank(shouldNotContain)) {
return contains;
} else {
return !contains;
}
});
}
Aggregations