Search in sources :

Example 11 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowController method statusFlow.

/**
 * Gets flow status.
 *
 * @param flowId        flow id
 * @param correlationId correlation ID header value
 * @return list of flow
 */
@ApiOperation(value = "Gets flow status", response = FlowIdStatusPayload.class)
@ApiResponses(value = { @ApiResponse(code = 200, response = FlowIdStatusPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable") })
@RequestMapping(value = "/flows/status/{flow-id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<FlowIdStatusPayload> statusFlow(@PathVariable(name = "flow-id") String flowId, @RequestHeader(value = CORRELATION_ID, defaultValue = DEFAULT_CORRELATION_ID) String correlationId) {
    logger.debug("Flow status: {}={}", CORRELATION_ID, correlationId);
    FlowIdStatusPayload response = flowService.statusFlow(flowId, correlationId);
    return new ResponseEntity<>(response, new HttpHeaders(), HttpStatus.OK);
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowServiceImpl method pathFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowPathPayload pathFlow(final String id, final String correlationId) {
    LOGGER.debug("Flow path: {}={}", CORRELATION_ID, correlationId);
    FlowPathRequest data = new FlowPathRequest(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);
    FlowPathResponse response = (FlowPathResponse) validateInfoMessage(request, message, correlationId);
    return Converter.buildFlowPathPayloadByFlowPath(id, response.getPayload());
}
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) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowPathRequest(org.openkilda.messaging.command.flow.FlowPathRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 13 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowServiceImpl method statusFlow.

/**
 * {@inheritDoc}
 */
@Override
public FlowIdStatusPayload statusFlow(final String id, final String correlationId) {
    LOGGER.debug("Flow status: {}={}", CORRELATION_ID, correlationId);
    FlowStatusRequest data = new FlowStatusRequest(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);
    FlowStatusResponse response = (FlowStatusResponse) validateInfoMessage(request, message, correlationId);
    return response.getPayload();
}
Also used : FlowStatusResponse(org.openkilda.messaging.info.flow.FlowStatusResponse) InfoMessage(org.openkilda.messaging.info.InfoMessage) Message(org.openkilda.messaging.Message) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) FlowStatusRequest(org.openkilda.messaging.command.flow.FlowStatusRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 14 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload 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 15 with FlowIdStatusPayload

use of org.openkilda.messaging.payload.flow.FlowIdStatusPayload in project open-kilda by telstra.

the class FlowControllerTest method statusFlow.

@Test
@WithMockUser(username = USERNAME, password = PASSWORD, roles = ROLE)
public void statusFlow() throws Exception {
    MvcResult result = mockMvc.perform(get("/flows/status/{flow-id}", TestMessageMock.FLOW_ID).header(CORRELATION_ID, testCorrelationId()).contentType(APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andExpect(content().contentType(APPLICATION_JSON_UTF8_VALUE)).andReturn();
    FlowIdStatusPayload response = MAPPER.readValue(result.getResponse().getContentAsString(), FlowIdStatusPayload.class);
    assertEquals(TestMessageMock.flowStatus, response);
}
Also used : FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) MvcResult(org.springframework.test.web.servlet.MvcResult) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

FlowIdStatusPayload (org.openkilda.messaging.payload.flow.FlowIdStatusPayload)29 InfoMessage (org.openkilda.messaging.info.InfoMessage)16 CommandMessage (org.openkilda.messaging.command.CommandMessage)12 Test (org.junit.Test)9 FlowStatusResponse (org.openkilda.messaging.info.flow.FlowStatusResponse)8 Message (org.openkilda.messaging.Message)6 AbstractStormTest (org.openkilda.wfm.AbstractStormTest)6 FlowPayload (org.openkilda.messaging.payload.flow.FlowPayload)5 Then (cucumber.api.java.en.Then)3 Values (org.apache.storm.tuple.Values)3 FlowGetRequest (org.openkilda.messaging.command.flow.FlowGetRequest)3 FlowPathRequest (org.openkilda.messaging.command.flow.FlowPathRequest)3 FlowsGetRequest (org.openkilda.messaging.command.flow.FlowsGetRequest)3 Flow (org.openkilda.messaging.model.Flow)3 FlowState (org.openkilda.messaging.payload.flow.FlowState)3 FlowStatusRequest (org.openkilda.messaging.command.flow.FlowStatusRequest)2 InstallOneSwitchFlow (org.openkilda.messaging.command.flow.InstallOneSwitchFlow)2 RemoveFlow (org.openkilda.messaging.command.flow.RemoveFlow)2 ErrorData (org.openkilda.messaging.error.ErrorData)2 ErrorMessage (org.openkilda.messaging.error.ErrorMessage)2