use of org.openkilda.messaging.info.flow.FlowResponse in project open-kilda by telstra.
the class FlowTopologyTest method getFlowCommand.
private Flow getFlowCommand(final String flowId) throws IOException {
System.out.println("TOPOLOGY: Get flow");
Flow flowPayload = new Flow(flowId, 10000, false, "", "test-switch", 1, 2, "test-switch", 1, 2);
FlowResponse infoData = new FlowResponse(flowPayload);
InfoMessage infoMessage = new InfoMessage(infoData, 0, "get-flow", Destination.WFM);
sendTopologyEngineMessage(infoMessage);
return flowPayload;
}
use of org.openkilda.messaging.info.flow.FlowResponse in project open-kilda by telstra.
the class FlowTopologyTest method getFlowTest.
@Test
public void getFlowTest() throws Exception {
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> record;
Flow flow = createFlow(flowId);
flow.setCookie(1);
flow.setFlowPath(new PathInfoData(0L, Collections.emptyList()));
flow.setMeterId(1);
flow.setTransitVlan(2);
flow.setState(FlowState.ALLOCATED);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
getFlow(flowId);
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
FlowResponse infoData = (FlowResponse) infoMessage.getData();
assertNotNull(infoData);
Flow flowTePayload = infoData.getPayload();
assertEquals(flow, flowTePayload);
}
use of org.openkilda.messaging.info.flow.FlowResponse in project open-kilda by telstra.
the class FlowTopologyTest method updateFlowCommandBoltTest.
@Test
public void updateFlowCommandBoltTest() throws Exception {
String flowId = UUID.randomUUID().toString();
ConsumerRecord<String, String> record;
createFlow(flowId);
record = cacheConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
updateFlow(flowId);
record = cacheConsumer.pollMessage();
assertNotNull(record);
InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
assertNotNull(message);
ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
assertNotNull(flow);
Flow flowTePayload = flow.getLeft();
record = nbConsumer.pollMessage();
assertNotNull(record);
assertNotNull(record.value());
InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
FlowResponse payload = (FlowResponse) infoMessage.getData();
assertNotNull(payload);
Flow flowNbPayload = payload.getPayload();
assertEquals(flowNbPayload, flowTePayload);
}
use of org.openkilda.messaging.info.flow.FlowResponse in project open-kilda by telstra.
the class FlowServiceImpl method getFlow.
/**
* {@inheritDoc}
*/
@Override
public InfoMessage getFlow(final FlowIdStatusPayload payload, final String correlationId) {
Set<Flow> flows = flowRepository.findByFlowId(payload.getId());
if (flows == null || flows.isEmpty()) {
logger.error("Flow with id={} not found", payload.getId());
throw new MessageException(ErrorType.NOT_FOUND, System.currentTimeMillis());
}
FlowResponse response = null;
for (Flow flow : flows) {
if ((flow.getCookie() & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
response = new FlowResponse(getFlowPayloadByFlow(flow));
}
}
logger.debug("Flow with id={} get: {}", payload.getId(), response);
return new InfoMessage(response, System.currentTimeMillis(), correlationId, Destination.WFM);
}
use of org.openkilda.messaging.info.flow.FlowResponse in project open-kilda by telstra.
the class FlowServiceImpl method updateFlow.
/**
* {@inheritDoc}
*/
@Override
public FlowPayload updateFlow(final FlowPayload flow, final String correlationId) {
LOGGER.debug("Update flow: {}={}", CORRELATION_ID, correlationId);
FlowUpdateRequest data = new FlowUpdateRequest(Converter.buildFlowByFlowPayload(flow));
CommandMessage request = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
messageConsumer.clear();
messageProducer.send(topic, request);
Message message = (Message) messageConsumer.poll(correlationId);
FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
return Converter.buildFlowPayloadByFlow(response.getPayload());
}
Aggregations