Search in sources :

Example 41 with FlowRequest

use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.

the class FlowMapperTest method testFlowCreatePayloadToFlowRequest.

@Test
public void testFlowCreatePayloadToFlowRequest() {
    FlowRequest flowRequest = flowMapper.toFlowCreateRequest(FLOW_CREATE_PAYLOAD);
    assertEquals(FLOW_CREATE_PAYLOAD.getDiverseFlowId(), flowRequest.getDiverseFlowId());
    assertEquals(Type.CREATE, flowRequest.getType());
    assertFlowDtos(FLOW_CREATE_PAYLOAD, flowRequest);
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) Test(org.junit.Test)

Example 42 with FlowRequest

use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.

the class FlowMapperTest method testFlowUpdatePayloadToFlowRequest.

@Test
public void testFlowUpdatePayloadToFlowRequest() {
    FlowRequest flowRequest = flowMapper.toFlowUpdateRequest(FLOW_UPDATE_PAYLOAD);
    assertEquals(FLOW_UPDATE_PAYLOAD.getDiverseFlowId(), flowRequest.getDiverseFlowId());
    assertEquals(Type.UPDATE, flowRequest.getType());
    assertFlowDtos(FLOW_UPDATE_PAYLOAD, flowRequest);
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) Test(org.junit.Test)

Example 43 with FlowRequest

use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.

the class FlowServiceImpl method createFlow.

@Override
public CompletableFuture<FlowResponseV2> createFlow(FlowRequestV2 request) {
    logger.info("Processing flow creation: {}", request);
    final String correlationId = RequestCorrelationId.getId();
    FlowRequest flowRequest;
    try {
        flowRequest = flowMapper.toFlowCreateRequest(request);
    } catch (IllegalArgumentException e) {
        logger.error("Can not parse arguments: {}", e.getMessage(), e);
        throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the create flow request");
    }
    CommandMessage command = new CommandMessage(flowRequest, System.currentTimeMillis(), correlationId, Destination.WFM);
    return messagingChannel.sendAndGet(flowHsTopic, command).thenApply(FlowResponse.class::cast).thenApply(FlowResponse::getPayload).thenApply(flowMapper::toFlowResponseV2);
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) MessageException(org.openkilda.messaging.error.MessageException) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) SwapFlowResponse(org.openkilda.messaging.info.flow.SwapFlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 44 with FlowRequest

use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.

the class FlowServiceImpl method updateFlow.

@Override
public CompletableFuture<FlowResponseV2> updateFlow(FlowRequestV2 request) {
    logger.info("Processing flow update: {}", request);
    final String correlationId = RequestCorrelationId.getId();
    FlowRequest updateRequest;
    try {
        updateRequest = flowMapper.toFlowRequest(request).toBuilder().type(Type.UPDATE).build();
    } catch (IllegalArgumentException e) {
        logger.error("Can not parse arguments: {}", e.getMessage(), e);
        throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments of the update flow request");
    }
    CommandMessage command = new CommandMessage(updateRequest, System.currentTimeMillis(), correlationId, Destination.WFM);
    return messagingChannel.sendAndGet(flowHsTopic, command).thenApply(FlowResponse.class::cast).thenApply(FlowResponse::getPayload).thenApply(flowMapper::toFlowResponseV2);
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) MessageException(org.openkilda.messaging.error.MessageException) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) SwapFlowResponse(org.openkilda.messaging.info.flow.SwapFlowResponse) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 45 with FlowRequest

use of org.openkilda.messaging.command.flow.FlowRequest in project open-kilda by telstra.

the class FlowMapper method toFlowUpdateRequest.

/**
 * Map FlowUpdatePayload.
 *
 * @param source {@link FlowUpdatePayload} instance.
 * @return {@link FlowRequest} instance.
 */
public FlowRequest toFlowUpdateRequest(FlowUpdatePayload source) {
    FlowRequest target = toFlowRequest(source).toBuilder().diverseFlowId(source.getDiverseFlowId()).type(Type.UPDATE).build();
    if (source.getSource().getDetectConnectedDevices() != null) {
        DetectConnectedDevicesPayload srcDevs = source.getSource().getDetectConnectedDevices();
        target.getDetectConnectedDevices().setSrcArp(srcDevs.isArp());
        target.getDetectConnectedDevices().setSrcLldp(srcDevs.isLldp());
    }
    if (source.getDestination().getDetectConnectedDevices() != null) {
        DetectConnectedDevicesPayload dstDevs = source.getDestination().getDetectConnectedDevices();
        target.getDetectConnectedDevices().setDstArp(dstDevs.isArp());
        target.getDetectConnectedDevices().setDstLldp(dstDevs.isLldp());
    }
    return target;
}
Also used : FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) DetectConnectedDevicesPayload(org.openkilda.messaging.payload.flow.DetectConnectedDevicesPayload)

Aggregations

FlowRequest (org.openkilda.messaging.command.flow.FlowRequest)45 Test (org.junit.Test)28 Flow (org.openkilda.model.Flow)25 FlowSegmentRequest (org.openkilda.floodlight.api.request.FlowSegmentRequest)12 FlowEndpoint (org.openkilda.model.FlowEndpoint)6 CommandMessage (org.openkilda.messaging.command.CommandMessage)5 MessageException (org.openkilda.messaging.error.MessageException)5 FlowResponse (org.openkilda.messaging.info.flow.FlowResponse)5 SwapFlowResponse (org.openkilda.messaging.info.flow.SwapFlowResponse)4 FlowPathRepository (org.openkilda.persistence.repositories.FlowPathRepository)4 CommandContext (org.openkilda.wfm.CommandContext)4 UnknownKeyException (org.openkilda.wfm.topology.flowhs.exception.UnknownKeyException)4 DetectConnectedDevicesDto (org.openkilda.messaging.model.DetectConnectedDevicesDto)3 Sets (com.google.common.collect.Sets)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Set (java.util.Set)2 UUID (java.util.UUID)2 Collectors (java.util.stream.Collectors)2 Ignore (org.junit.Ignore)2