Search in sources :

Example 1 with GetLinksRequest

use of org.openkilda.messaging.nbtopology.request.GetLinksRequest in project open-kilda by telstra.

the class LinkServiceImpl method getLinks.

@Override
public CompletableFuture<List<LinkDto>> getLinks(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) {
    final String correlationId = RequestCorrelationId.getId();
    logger.debug("Get links request received");
    GetLinksRequest request = null;
    try {
        request = new GetLinksRequest(new NetworkEndpointMask(srcSwitch, srcPort), new NetworkEndpointMask(dstSwitch, dstPort));
    } catch (IllegalArgumentException e) {
        logger.error("Can not parse arguments: {}", e.getMessage());
        throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments when create 'get links' request");
    }
    CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(IslInfoData.class::cast).map(linkMapper::mapResponse).collect(Collectors.toList()));
}
Also used : GetLinksRequest(org.openkilda.messaging.nbtopology.request.GetLinksRequest) NetworkEndpointMask(org.openkilda.messaging.model.NetworkEndpointMask) MessageException(org.openkilda.messaging.error.MessageException) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

CommandMessage (org.openkilda.messaging.command.CommandMessage)1 MessageException (org.openkilda.messaging.error.MessageException)1 NetworkEndpointMask (org.openkilda.messaging.model.NetworkEndpointMask)1 GetLinksRequest (org.openkilda.messaging.nbtopology.request.GetLinksRequest)1