use of org.openkilda.messaging.payload.network.PathDto 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);
});
}
Aggregations