Search in sources :

Example 1 with FlowsResponse

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

the class FlowTopologyTest method dumpFlowsTopologyEngineBoltTest.

@Test
@Ignore
public void dumpFlowsTopologyEngineBoltTest() throws Exception {
    ConsumerRecord<String, String> nbRecord;
    String flowId = UUID.randomUUID().toString();
    List<Flow> payload = dumpFlowCommand(flowId);
    nbRecord = nbConsumer.pollMessage();
    assertNotNull(nbRecord);
    assertNotNull(nbRecord.value());
    InfoMessage response = objectMapper.readValue(nbRecord.value(), InfoMessage.class);
    assertNotNull(response);
    FlowsResponse responseData = (FlowsResponse) response.getData();
    assertNotNull(responseData);
    assertEquals(payload, responseData.getPayload());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) 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 2 with FlowsResponse

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

the class FlowTopologyTest method dumpFlowsTest.

@Test
public void dumpFlowsTest() 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());
    dumpFlows(null);
    record = nbConsumer.pollMessage();
    assertNotNull(record);
    assertNotNull(record.value());
    InfoMessage infoMessage = objectMapper.readValue(record.value(), InfoMessage.class);
    FlowsResponse infoData = (FlowsResponse) infoMessage.getData();
    assertNotNull(infoData);
    assertNotNull(infoData.getPayload());
    assertFalse(infoData.getPayload().isEmpty());
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) AbstractStormTest(org.openkilda.wfm.AbstractStormTest) Test(org.junit.Test)

Example 3 with FlowsResponse

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

the class FlowTopologyTest method dumpFlowCommand.

private List<Flow> dumpFlowCommand(final String flowId) throws IOException {
    System.out.println("TOPOLOGY: Get flows");
    Flow flow = new Flow(flowId, 10000, false, "", "test-switch", 1, 2, "test-switch", 1, 2);
    List<Flow> payload = Collections.singletonList(flow);
    FlowsResponse infoData = new FlowsResponse(payload);
    InfoMessage infoMessage = new InfoMessage(infoData, 0, "dump-flows", Destination.WFM);
    sendTopologyEngineMessage(infoMessage);
    return payload;
}
Also used : InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) Flow(org.openkilda.messaging.model.Flow) InstallOneSwitchFlow(org.openkilda.messaging.command.flow.InstallOneSwitchFlow)

Example 4 with FlowsResponse

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

the class TopologyController method flows.

/**
 * Dumps flows.
 *
 * @param correlationId correlation ID header value
 * @return flows
 */
@RequestMapping(value = "/flows", method = RequestMethod.GET, produces = APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<FlowsPayload> flows(@RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("Dump flows: {}={}", CORRELATION_ID, correlationId);
    InfoMessage message = flowService.getFlows(null, correlationId);
    FlowsResponse response = (FlowsResponse) message.getData();
    return new ResponseEntity<>(response.getPayload(), new HttpHeaders(), HttpStatus.OK);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with FlowsResponse

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

the class FlowServiceImpl method getFlows.

/**
 * {@inheritDoc}
 */
@Override
public InfoMessage getFlows(final FlowIdStatusPayload payload, final String correlationId) {
    Set<Flow> flows = flowRepository.findAll();
    List<FlowPayload> flowsPayload = new ArrayList<>(flows.size() / 2);
    for (Flow flow : flows) {
        if ((flow.getCookie() & DIRECT_FLOW_COOKIE) == DIRECT_FLOW_COOKIE) {
            flowsPayload.add(getFlowPayloadByFlow(flow));
        }
    }
    logger.debug("Flows get: {}", flowsPayload);
    return new InfoMessage(new FlowsResponse(new FlowsPayload(flowsPayload)), System.currentTimeMillis(), correlationId, Destination.WFM);
}
Also used : FlowPayload(org.openkilda.messaging.payload.flow.FlowPayload) InfoMessage(org.openkilda.messaging.info.InfoMessage) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) ArrayList(java.util.ArrayList) FlowsPayload(org.openkilda.messaging.payload.flow.FlowsPayload) Flow(org.openkilda.topology.domain.Flow)

Aggregations

InfoMessage (org.openkilda.messaging.info.InfoMessage)7 FlowsResponse (org.openkilda.messaging.info.flow.FlowsResponse)7 Test (org.junit.Test)3 Message (org.openkilda.messaging.Message)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)2 Flow (org.openkilda.messaging.model.Flow)2 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)2 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)2 ArrayList (java.util.ArrayList)1 Ignore (org.junit.Ignore)1 FlowsGetRequest (org.openkilda.messaging.command.flow.FlowsGetRequest)1 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)1 FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)1 FlowsPayload (org.openkilda.messaging.payload.flow.FlowsPayload)1 Flow (org.openkilda.topology.domain.Flow)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1