Search in sources :

Example 1 with GetPathsRequest

use of org.openkilda.messaging.nbtopology.request.GetPathsRequest 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

Duration (java.time.Duration)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 ErrorType (org.openkilda.messaging.error.ErrorType)1 MessageException (org.openkilda.messaging.error.MessageException)1 PathsInfoData (org.openkilda.messaging.info.network.PathsInfoData)1 GetPathsRequest (org.openkilda.messaging.nbtopology.request.GetPathsRequest)1 PathDto (org.openkilda.messaging.payload.network.PathDto)1 PathsDto (org.openkilda.messaging.payload.network.PathsDto)1 FlowEncapsulationType (org.openkilda.model.FlowEncapsulationType)1 PathComputationStrategy (org.openkilda.model.PathComputationStrategy)1 SwitchId (org.openkilda.model.SwitchId)1 PathMapper (org.openkilda.northbound.converter.PathMapper)1 MessagingChannel (org.openkilda.northbound.messaging.MessagingChannel)1 NetworkService (org.openkilda.northbound.service.NetworkService)1 RequestCorrelationId (org.openkilda.northbound.utils.RequestCorrelationId)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Value (org.springframework.beans.factory.annotation.Value)1