Search in sources :

Example 1 with FlowPathResponse

use of org.openkilda.messaging.info.flow.FlowPathResponse in project open-kilda by telstra.

the class FlowTopologyTest method pathFlowTest.

@Test
public void pathFlowTest() 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());
    PathInfoData payload = pathFlow(flowId);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    FlowPathResponse infoData = (FlowPathResponse) infoMessage.getData();
    assertNotNull(infoData);
    PathInfoData flowTePayload = infoData.getPayload();
    assertEquals(payload, flowTePayload);
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 2 with FlowPathResponse

use of org.openkilda.messaging.info.flow.FlowPathResponse 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);
}
Also used : FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowPathPayload(org.openkilda.messaging.payload.flow.FlowPathPayload) Flow(org.openkilda.topology.domain.Flow)

Example 3 with FlowPathResponse

use of org.openkilda.messaging.info.flow.FlowPathResponse in project open-kilda by telstra.

the class AbstractSerializerTest method flowPathResponseTest.

@Test
public void flowPathResponseTest() throws IOException, ClassNotFoundException {
    FlowPathResponse data = new FlowPathResponse(path);
    System.out.println(data);
    InfoMessage info = new InfoMessage(data, System.currentTimeMillis(), CORRELATION_ID, DESTINATION);
    serialize(info);
    Message message = (Message) deserialize();
    assertTrue(message instanceof InfoMessage);
    InfoMessage resultInfo = (InfoMessage) message;
    assertTrue(resultInfo.getData() instanceof FlowPathResponse);
    FlowPathResponse resultData = (FlowPathResponse) resultInfo.getData();
    System.out.println(resultData);
    assertEquals(data, resultData);
    assertEquals(data.hashCode(), resultData.hashCode());
    assertEquals(path.hashCode(), resultData.getPayload().hashCode());
}
Also used : FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) ErrorMessage(org.openkilda.messaging.error.ErrorMessage) InfoMessage(org.openkilda.messaging.info.InfoMessage) Test(org.junit.Test)

Example 4 with FlowPathResponse

use of org.openkilda.messaging.info.flow.FlowPathResponse in project open-kilda by telstra.

the class FlowTopologyTest method pathFlowCommand.

private PathInfoData pathFlowCommand(final String flowId) throws IOException {
    System.out.println("TOPOLOGY: Path flow");
    PathInfoData payload = new PathInfoData(0L, Collections.singletonList(new PathNode("test-switch", 1, 0, null)));
    FlowPathResponse infoData = new FlowPathResponse(payload);
    InfoMessage infoMessage = new InfoMessage(infoData, 0, "path-flow", Destination.WFM);
    sendTopologyEngineMessage(infoMessage);
    return payload;
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) PathNode(org.openkilda.messaging.info.event.PathNode)

Example 5 with FlowPathResponse

use of org.openkilda.messaging.info.flow.FlowPathResponse in project open-kilda by telstra.

the class FlowTopologyTest method getPathTopologyEngineBoltTest.

@Test
@Ignore
public void getPathTopologyEngineBoltTest() throws Exception {
    ConsumerRecord<String, String> nbRecord;
    String flowId = UUID.randomUUID().toString();
    PathInfoData payload = pathFlowCommand(flowId);
    nbRecord = nbConsumer.pollMessage();
    assertNotNull(nbRecord);
    assertNotNull(nbRecord.value());
    InfoMessage response = objectMapper.readValue(nbRecord.value(), InfoMessage.class);
    assertNotNull(response);
    FlowPathResponse responseData = (FlowPathResponse) response.getData();
    assertNotNull(responseData);
    assertEquals(payload, responseData.getPayload());
}
Also used : PathInfoData(org.openkilda.messaging.info.event.PathInfoData) FlowPathResponse(org.openkilda.messaging.info.flow.FlowPathResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) Ignore(org.junit.Ignore) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)6 FlowPathResponse (org.openkilda.messaging.info.flow.FlowPathResponse)6 Test (org.junit.Test)3 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)3 Message (org.openkilda.messaging.Message)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)2 Ignore (org.junit.Ignore)1 FlowRerouteRequest (org.openkilda.messaging.command.flow.FlowRerouteRequest)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 PathNode (org.openkilda.messaging.info.event.PathNode)1 Flow (org.openkilda.messaging.model.Flow)1 FlowPathPayload (org.openkilda.messaging.payload.flow.FlowPathPayload)1 Flow (org.openkilda.topology.domain.Flow)1