Search in sources :

Example 11 with FlowEncapsulationType

use of org.openkilda.model.FlowEncapsulationType in project open-kilda by telstra.

the class NetworkServiceImpl method getPaths.

@Override
public CompletableFuture<PathsDto> getPaths(SwitchId srcSwitch, SwitchId dstSwitch, FlowEncapsulationType encapsulationType, PathComputationStrategy pathComputationStrategy, Duration maxLatency, Duration maxLatencyTier2) {
    String correlationId = RequestCorrelationId.getId();
    if (PathComputationStrategy.MAX_LATENCY.equals(pathComputationStrategy) && maxLatency == null) {
        throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.PARAMETERS_INVALID, "Missed max_latency parameter.", "MAX_LATENCY path computation strategy requires non null " + "max_latency parameter. If max_latency will be equal to 0 LATENCY strategy will be used instead " + "of MAX_LATENCY.");
    }
    GetPathsRequest request = new GetPathsRequest(srcSwitch, dstSwitch, encapsulationType, pathComputationStrategy, maxLatency, maxLatencyTier2);
    CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(paths -> {
        List<PathDto> pathsDtoList = paths.stream().map(PathsInfoData.class::cast).map(p -> pathMapper.mapToPath(p.getPath())).collect(Collectors.toList());
        return new PathsDto(pathsDtoList);
    });
}
Also used : FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) PathComputationStrategy(org.openkilda.model.PathComputationStrategy) ErrorType(org.openkilda.messaging.error.ErrorType) Autowired(org.springframework.beans.factory.annotation.Autowired) NetworkService(org.openkilda.northbound.service.NetworkService) CompletableFuture(java.util.concurrent.CompletableFuture) RequestCorrelationId(org.openkilda.northbound.utils.RequestCorrelationId) Collectors(java.util.stream.Collectors) PathsInfoData(org.openkilda.messaging.info.network.PathsInfoData) PathMapper(org.openkilda.northbound.converter.PathMapper) MessageException(org.openkilda.messaging.error.MessageException) Value(org.springframework.beans.factory.annotation.Value) CommandMessage(org.openkilda.messaging.command.CommandMessage) List(java.util.List) PathDto(org.openkilda.messaging.payload.network.PathDto) SwitchId(org.openkilda.model.SwitchId) Service(org.springframework.stereotype.Service) MessagingChannel(org.openkilda.northbound.messaging.MessagingChannel) Duration(java.time.Duration) GetPathsRequest(org.openkilda.messaging.nbtopology.request.GetPathsRequest) PathsDto(org.openkilda.messaging.payload.network.PathsDto) PathDto(org.openkilda.messaging.payload.network.PathDto) PathsInfoData(org.openkilda.messaging.info.network.PathsInfoData) MessageException(org.openkilda.messaging.error.MessageException) PathsDto(org.openkilda.messaging.payload.network.PathsDto) GetPathsRequest(org.openkilda.messaging.nbtopology.request.GetPathsRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

FlowEncapsulationType (org.openkilda.model.FlowEncapsulationType)11 Flow (org.openkilda.model.Flow)7 FlowPath (org.openkilda.model.FlowPath)7 ArrayList (java.util.ArrayList)5 FlowSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.FlowSegmentRequestFactory)4 SwitchId (org.openkilda.model.SwitchId)4 MirrorContext (org.openkilda.wfm.share.model.MirrorContext)4 SpeakerRequestBuildContext (org.openkilda.wfm.share.model.SpeakerRequestBuildContext)4 FlowCommandBuilder (org.openkilda.wfm.topology.flowhs.service.FlowCommandBuilder)4 Duration (java.time.Duration)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 PathComputationStrategy (org.openkilda.model.PathComputationStrategy)3 PathId (org.openkilda.model.PathId)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Objects (java.util.Objects)2 Optional (java.util.Optional)2 Slf4j (lombok.extern.slf4j.Slf4j)2 IngressFlowLoopSegmentRequestFactory (org.openkilda.floodlight.api.request.factory.IngressFlowLoopSegmentRequestFactory)2 DeleteRulesCriteria (org.openkilda.messaging.command.switches.DeleteRulesCriteria)2