Search in sources :

Example 1 with FlowProtectedPathDto

use of org.openkilda.messaging.model.FlowPathDto.FlowProtectedPathDto in project open-kilda by telstra.

the class FlowServiceImpl method buildFlowPathPayload.

private FlowPathPayload buildFlowPathPayload(List<FlowPathDto> paths, String flowId) {
    FlowPathDto askedPathDto = paths.stream().filter(e -> e.getId().equals(flowId)).findAny().orElseThrow(() -> new IllegalStateException(format("Path for flow %s is not found.", flowId)));
    // fill primary flow path
    FlowPathPayload payload = new FlowPathPayload();
    payload.setId(askedPathDto.getId());
    payload.setForwardPath(askedPathDto.getForwardPath());
    payload.setReversePath(askedPathDto.getReversePath());
    if (askedPathDto.getProtectedPath() != null) {
        FlowProtectedPathDto protectedPath = askedPathDto.getProtectedPath();
        payload.setProtectedPath(FlowProtectedPath.builder().forwardPath(protectedPath.getForwardPath()).reversePath(protectedPath.getReversePath()).build());
    }
    // fill group paths
    if (paths.size() > 1) {
        payload.setDiverseGroupPayload(DiverseGroupPayload.builder().overlappingSegments(askedPathDto.getSegmentsStats()).otherFlows(mapGroupPaths(paths, flowId, FlowPathDto::isPrimaryPathCorrespondStat)).build());
        if (askedPathDto.getProtectedPath() != null) {
            payload.setDiverseGroupProtectedPayload(DiverseGroupPayload.builder().overlappingSegments(askedPathDto.getProtectedPath().getSegmentsStats()).otherFlows(mapGroupPaths(paths, flowId, e -> !e.isPrimaryPathCorrespondStat())).build());
        }
    }
    return payload;
}
Also used : FlowReadRequest(org.openkilda.messaging.nbtopology.request.FlowReadRequest) GetFlowStatusTimestampsRequest(org.openkilda.messaging.nbtopology.request.GetFlowStatusTimestampsRequest) FlowHistoryEntry(org.openkilda.messaging.payload.history.FlowHistoryEntry) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) MessageException(org.openkilda.messaging.error.MessageException) CommandMessage(org.openkilda.messaging.command.CommandMessage) FlowResponseV2(org.openkilda.northbound.dto.v2.flows.FlowResponseV2) DiverseGroupPayload(org.openkilda.messaging.payload.flow.DiverseGroupPayload) FlowMirrorPointsDumpResponse(org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse) FlowPathPayload(org.openkilda.messaging.payload.flow.FlowPathPayload) FlowPatchRequest(org.openkilda.messaging.nbtopology.request.FlowPatchRequest) GroupFlowPathPayload(org.openkilda.messaging.payload.flow.GroupFlowPathPayload) PingInput(org.openkilda.northbound.dto.v1.flows.PingInput) FlowDeleteRequest(org.openkilda.messaging.command.flow.FlowDeleteRequest) FlowResponsePayload(org.openkilda.messaging.payload.flow.FlowResponsePayload) SwapFlowEndpointRequest(org.openkilda.messaging.command.flow.SwapFlowEndpointRequest) FlowValidationResponse(org.openkilda.messaging.info.flow.FlowValidationResponse) FlowProtectedPath(org.openkilda.messaging.payload.flow.FlowPathPayload.FlowProtectedPath) FlowPatchDto(org.openkilda.northbound.dto.v1.flows.FlowPatchDto) FlowPatchV2(org.openkilda.northbound.dto.v2.flows.FlowPatchV2) FlowMirrorPointsDumpRequest(org.openkilda.messaging.nbtopology.request.FlowMirrorPointsDumpRequest) Predicate(java.util.function.Predicate) GetFlowPathRequest(org.openkilda.messaging.nbtopology.request.GetFlowPathRequest) FlowDto(org.openkilda.messaging.model.FlowDto) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) FlowMirrorPointPayload(org.openkilda.northbound.dto.v2.flows.FlowMirrorPointPayload) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) FlowService(org.openkilda.northbound.service.FlowService) FlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest) FLOW_ID(org.openkilda.messaging.Utils.FLOW_ID) List(java.util.List) FlowMirrorPointCreateRequest(org.openkilda.messaging.command.flow.FlowMirrorPointCreateRequest) BatchResults(org.openkilda.northbound.dto.BatchResults) FlowConnectedDevicesResponse(org.openkilda.northbound.dto.v1.flows.FlowConnectedDevicesResponse) FlowValidationRequest(org.openkilda.messaging.command.flow.FlowValidationRequest) FlowPatch(org.openkilda.messaging.model.FlowPatch) FlowsDumpRequest(org.openkilda.messaging.nbtopology.request.FlowsDumpRequest) Optional(java.util.Optional) FlowValidationDto(org.openkilda.northbound.dto.v1.flows.FlowValidationDto) GetFlowLoopsRequest(org.openkilda.messaging.nbtopology.request.GetFlowLoopsRequest) CreateFlowLoopRequest(org.openkilda.messaging.command.flow.CreateFlowLoopRequest) CompletableFuture(java.util.concurrent.CompletableFuture) SwapFlowEndpointPayload(org.openkilda.northbound.dto.v2.flows.SwapFlowEndpointPayload) Function(java.util.function.Function) FlowMirrorPointResponseV2(org.openkilda.northbound.dto.v2.flows.FlowMirrorPointResponseV2) PathMapper(org.openkilda.northbound.converter.PathMapper) FlowLoopResponse(org.openkilda.northbound.dto.v2.flows.FlowLoopResponse) ArrayList(java.util.ArrayList) PingOutput(org.openkilda.northbound.dto.v1.flows.PingOutput) Value(org.springframework.beans.factory.annotation.Value) FlowPingRequest(org.openkilda.messaging.command.flow.FlowPingRequest) Type(org.openkilda.messaging.command.flow.FlowRequest.Type) FlowIdStatusPayload(org.openkilda.messaging.payload.flow.FlowIdStatusPayload) MeterModifyRequest(org.openkilda.messaging.nbtopology.request.MeterModifyRequest) GetFlowPathResponse(org.openkilda.messaging.nbtopology.response.GetFlowPathResponse) FlowRequestV2(org.openkilda.northbound.dto.v2.flows.FlowRequestV2) Service(org.springframework.stereotype.Service) MessagingChannel(org.openkilda.northbound.messaging.MessagingChannel) FlowRerouteRequest.createManualFlowRerouteRequest(org.openkilda.messaging.command.flow.FlowRerouteRequest.createManualFlowRerouteRequest) FlowPathSwapRequest(org.openkilda.messaging.command.flow.FlowPathSwapRequest) FlowPathDto(org.openkilda.messaging.model.FlowPathDto) FlowLoopsResponse(org.openkilda.messaging.nbtopology.response.FlowLoopsResponse) FlowProtectedPathDto(org.openkilda.messaging.model.FlowPathDto.FlowProtectedPathDto) FlowMapper(org.openkilda.northbound.converter.FlowMapper) FlowRerouteResponse(org.openkilda.messaging.info.flow.FlowRerouteResponse) FlowMirrorPointDeleteRequest(org.openkilda.messaging.command.flow.FlowMirrorPointDeleteRequest) CorrelationIdFactory(org.openkilda.northbound.utils.CorrelationIdFactory) AsyncUtils.collectResponses(org.openkilda.northbound.utils.async.AsyncUtils.collectResponses) FlowRequest(org.openkilda.messaging.command.flow.FlowRequest) Logger(org.slf4j.Logger) DeleteFlowLoopRequest(org.openkilda.messaging.command.flow.DeleteFlowLoopRequest) ErrorType(org.openkilda.messaging.error.ErrorType) FlowMeterEntries(org.openkilda.messaging.info.meter.FlowMeterEntries) FlowStatusTimestampsEntry(org.openkilda.messaging.payload.history.FlowStatusTimestampsEntry) RequestCorrelationId(org.openkilda.northbound.utils.RequestCorrelationId) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse) FlowRerouteResponseV2(org.openkilda.northbound.dto.v2.flows.FlowRerouteResponseV2) FlowUpdatePayload(org.openkilda.messaging.payload.flow.FlowUpdatePayload) FlowConnectedDeviceRequest(org.openkilda.messaging.nbtopology.request.FlowConnectedDeviceRequest) SwitchId(org.openkilda.model.SwitchId) FlowReroutePayload(org.openkilda.messaging.payload.flow.FlowReroutePayload) ConnectedDeviceMapper(org.openkilda.northbound.converter.ConnectedDeviceMapper) Destination(org.openkilda.messaging.Destination) GetFlowHistoryRequest(org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest) FlowMirrorPointsResponseV2(org.openkilda.northbound.dto.v2.flows.FlowMirrorPointsResponseV2) Collections(java.util.Collections) FlowMirrorPointResponse(org.openkilda.messaging.info.flow.FlowMirrorPointResponse) FlowHistoryStatusesResponse(org.openkilda.northbound.dto.v2.flows.FlowHistoryStatusesResponse) SwapFlowResponse(org.openkilda.messaging.info.flow.SwapFlowResponse) FlowCreatePayload(org.openkilda.messaging.payload.flow.FlowCreatePayload) FlowPathDto(org.openkilda.messaging.model.FlowPathDto) FlowProtectedPathDto(org.openkilda.messaging.model.FlowPathDto.FlowProtectedPathDto) FlowPathPayload(org.openkilda.messaging.payload.flow.FlowPathPayload) GroupFlowPathPayload(org.openkilda.messaging.payload.flow.GroupFlowPathPayload)

Aggregations

String.format (java.lang.String.format)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 Optional (java.util.Optional)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Function (java.util.function.Function)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 Destination (org.openkilda.messaging.Destination)1 FLOW_ID (org.openkilda.messaging.Utils.FLOW_ID)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 CreateFlowLoopRequest (org.openkilda.messaging.command.flow.CreateFlowLoopRequest)1 DeleteFlowLoopRequest (org.openkilda.messaging.command.flow.DeleteFlowLoopRequest)1 FlowDeleteRequest (org.openkilda.messaging.command.flow.FlowDeleteRequest)1 FlowMirrorPointCreateRequest (org.openkilda.messaging.command.flow.FlowMirrorPointCreateRequest)1 FlowMirrorPointDeleteRequest (org.openkilda.messaging.command.flow.FlowMirrorPointDeleteRequest)1 FlowPathSwapRequest (org.openkilda.messaging.command.flow.FlowPathSwapRequest)1 FlowPingRequest (org.openkilda.messaging.command.flow.FlowPingRequest)1