Search in sources :

Example 1 with YFlowResponse

use of org.openkilda.messaging.command.yflow.YFlowResponse in project open-kilda by telstra.

the class YFlowReadServiceTest method shouldDumpYFlows.

@Test
public void shouldDumpYFlows() throws FlowNotFoundException {
    // given
    String yFlowId = "test_y_flow_1";
    createYFlowViaTransit(yFlowId);
    // when
    List<YFlowResponse> yFlows = yFlowReadService.getAllYFlows();
    // then
    assertEquals(1, yFlows.size());
    YFlowDto yFlow = yFlows.get(0).getYFlow();
    assertNotNull(yFlow);
    assertEquals(yFlowId, yFlow.getYFlowId());
    assertEquals(2, yFlow.getSubFlows().size());
}
Also used : YFlowDto(org.openkilda.messaging.command.yflow.YFlowDto) YFlowResponse(org.openkilda.messaging.command.yflow.YFlowResponse) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 2 with YFlowResponse

use of org.openkilda.messaging.command.yflow.YFlowResponse in project open-kilda by telstra.

the class YFlowReadServiceTest method shouldFetchYFlow.

@Test
public void shouldFetchYFlow() throws FlowNotFoundException {
    // given
    String yFlowId = "test_y_flow_1";
    createYFlowViaTransit(yFlowId);
    // when
    YFlowResponse yFlowResponse = yFlowReadService.getYFlow(yFlowId);
    // then
    YFlowDto yFlow = yFlowResponse.getYFlow();
    assertNotNull(yFlow);
    assertEquals(2, yFlow.getSubFlows().size());
}
Also used : YFlowDto(org.openkilda.messaging.command.yflow.YFlowDto) YFlowResponse(org.openkilda.messaging.command.yflow.YFlowResponse) Test(org.junit.Test) AbstractYFlowTest(org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)

Example 3 with YFlowResponse

use of org.openkilda.messaging.command.yflow.YFlowResponse in project open-kilda by telstra.

the class YFlowServiceImpl method getYFlow.

@Override
public CompletableFuture<YFlow> getYFlow(String yFlowId) {
    log.debug("Processing getting of y-flow: {}", yFlowId);
    YFlowReadRequest readRequest = new YFlowReadRequest(yFlowId);
    CommandMessage request = new CommandMessage(readRequest, System.currentTimeMillis(), RequestCorrelationId.getId());
    return messagingChannel.sendAndGet(flowHsTopic, request).thenApply(YFlowResponse.class::cast).thenApply(YFlowResponse::getYFlow).thenApply(flowMapper::toYFlow);
}
Also used : YFlowReadRequest(org.openkilda.messaging.command.yflow.YFlowReadRequest) YFlowResponse(org.openkilda.messaging.command.yflow.YFlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 4 with YFlowResponse

use of org.openkilda.messaging.command.yflow.YFlowResponse in project open-kilda by telstra.

the class YFlowServiceImpl method patchYFlow.

@Override
public CompletableFuture<YFlow> patchYFlow(String yFlowId, YFlowPatchPayload patchPayload) {
    log.debug("Processing y-flow patch: {}", yFlowId);
    String correlationId = RequestCorrelationId.getId();
    YFlowPartialUpdateRequest yFlowPartialUpdateRequest;
    try {
        yFlowPartialUpdateRequest = flowMapper.toYFlowPatchRequest(yFlowId, patchPayload);
    } catch (IllegalArgumentException e) {
        throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the flow patch request");
    }
    CommandMessage request = new CommandMessage(yFlowPartialUpdateRequest, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGet(flowHsTopic, request).thenApply(YFlowResponse.class::cast).thenApply(YFlowResponse::getYFlow).thenApply(flowMapper::toYFlow);
}
Also used : MessageException(org.openkilda.messaging.error.MessageException) YFlowPartialUpdateRequest(org.openkilda.messaging.command.yflow.YFlowPartialUpdateRequest) YFlowResponse(org.openkilda.messaging.command.yflow.YFlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 5 with YFlowResponse

use of org.openkilda.messaging.command.yflow.YFlowResponse in project open-kilda by telstra.

the class YFlowServiceImpl method deleteYFlow.

@Override
public CompletableFuture<YFlow> deleteYFlow(String yFlowId) {
    log.debug("Processing y-flow delete: {}", yFlowId);
    CommandMessage command = new CommandMessage(new YFlowDeleteRequest(yFlowId), System.currentTimeMillis(), RequestCorrelationId.getId());
    return messagingChannel.sendAndGet(flowHsTopic, command).thenApply(YFlowResponse.class::cast).thenApply(YFlowResponse::getYFlow).thenApply(flowMapper::toYFlow);
}
Also used : YFlowDeleteRequest(org.openkilda.messaging.command.yflow.YFlowDeleteRequest) YFlowResponse(org.openkilda.messaging.command.yflow.YFlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

YFlowResponse (org.openkilda.messaging.command.yflow.YFlowResponse)10 CommandMessage (org.openkilda.messaging.command.CommandMessage)6 MessageException (org.openkilda.messaging.error.MessageException)5 Test (org.junit.Test)3 YFlowDto (org.openkilda.messaging.command.yflow.YFlowDto)3 YFlowPathsResponse (org.openkilda.messaging.command.yflow.YFlowPathsResponse)3 YFlowReadRequest (org.openkilda.messaging.command.yflow.YFlowReadRequest)3 YFlowRequest (org.openkilda.messaging.command.yflow.YFlowRequest)3 SubFlowsReadRequest (org.openkilda.messaging.command.yflow.SubFlowsReadRequest)2 SubFlowsResponse (org.openkilda.messaging.command.yflow.SubFlowsResponse)2 YFlowDeleteRequest (org.openkilda.messaging.command.yflow.YFlowDeleteRequest)2 YFlowPartialUpdateRequest (org.openkilda.messaging.command.yflow.YFlowPartialUpdateRequest)2 YFlowPathsReadRequest (org.openkilda.messaging.command.yflow.YFlowPathsReadRequest)2 YFlowsDumpRequest (org.openkilda.messaging.command.yflow.YFlowsDumpRequest)2 AbstractYFlowTest (org.openkilda.wfm.topology.flowhs.service.AbstractYFlowTest)2 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Values (org.apache.storm.tuple.Values)1 Message (org.openkilda.messaging.Message)1