Search in sources :

Example 6 with FlowResponse

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

the class FlowServiceImpl method createFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPayload createFlow(final FlowPayload flow, final String correlationId) {
    LOGGER.debug("Create flow: {}={}", CORRELATION_ID, correlationId);
    FlowCreateRequest data = new FlowCreateRequest(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());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowCreateRequest(org.openkilda.messaging.command.flow.FlowCreateRequest) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 7 with FlowResponse

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

the class FlowServiceImpl method getFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPayload getFlow(final String id, final String correlationId) {
    LOGGER.debug("Get flow: {}={}", CORRELATION_ID, correlationId);
    FlowGetRequest data = new FlowGetRequest(new FlowIdStatusPayload(id, null));
    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());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowGetRequest(org.openkilda.messaging.command.flow.FlowGetRequest) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 8 with FlowResponse

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

the class FlowServiceImpl method _deleteFlowRespone.

/**
 * Blocking primitive .. waits for the response .. and then converts to FlowPayload.
 * @return the deleted flow.
 */
private FlowPayload _deleteFlowRespone(final String correlationId, CommandMessage request) {
    Message message = (Message) messageConsumer.poll(correlationId);
    FlowResponse response = (FlowResponse) validateInfoMessage(request, message, correlationId);
    return Converter.buildFlowPayloadByFlow(response.getPayload());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse)

Example 9 with FlowResponse

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

the class FlowTopologyTest method getFlowTopologyEngineBoltTest.

@Test
@Ignore
public void getFlowTopologyEngineBoltTest() throws Exception {
    ConsumerRecord<String, String> nbRecord;
    String flowId = UUID.randomUUID().toString();
    Flow payload = getFlowCommand(flowId);
    nbRecord = nbConsumer.pollMessage();
    assertNotNull(nbRecord);
    assertNotNull(nbRecord.value());
    InfoMessage response = objectMapper.readValue(nbRecord.value(), InfoMessage.class);
    assertNotNull(response);
    FlowResponse responseData = (FlowResponse) response.getData();
    assertNotNull(responseData);
    assertEquals(payload, responseData.getPayload());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) Ignore(org.junit.Ignore) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 10 with FlowResponse

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

the class FlowTopologyTest method deleteFlowCommandBoltTest.

@Test
public void deleteFlowCommandBoltTest() 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());
    Flow payload = deleteFlow(flowId);
    record = cacheConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage message = objectMapper.readValue(record.value(), InfoMessage.class);
    assertNotNull(message);
    ImmutablePair<Flow, Flow> flow = getFlowPayload(message);
    assertNotNull(flow);
    Flow flowTePayload = flow.getLeft();
    assertEquals(payload.getFlowId(), flowTePayload.getFlowId());
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    System.out.println("record = " + record);
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    FlowResponse response = (FlowResponse) infoMessage.getData();
    assertNotNull(response);
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)12 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)12 Test (org.junit.Test)6 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)6 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)6 Flow (org.openkilda.messaging.model.Flow)6 Message (org.openkilda.messaging.Message)5 CommandMessage (org.openkilda.messaging.command.CommandMessage)5 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)5 Ignore (org.junit.Ignore)1 FlowCreateRequest (org.openkilda.messaging.command.flow.FlowCreateRequest)1 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)1 FlowUpdateRequest (org.openkilda.messaging.command.flow.FlowUpdateRequest)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 MessageException (org.openkilda.messaging.error.MessageException)1 PathInfoData (org.openkilda.messaging.info.event.PathInfoData)1 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)1 Flow (org.openkilda.topology.domain.Flow)1