Search in sources :

Example 1 with RerouteFlowsForIslRequest

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

the class LinkServiceImpl method rerouteFlowsForLink.

@Override
public CompletableFuture<List<String>> rerouteFlowsForLink(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) {
    final String correlationId = RequestCorrelationId.getId();
    logger.debug("Reroute all flows for a particular link request processing");
    RerouteFlowsForIslRequest data = null;
    try {
        data = new RerouteFlowsForIslRequest(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), correlationId);
    } 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 \"reroute flows for link\" request");
    }
    CommandMessage message = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
    return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(FlowsResponse.class::cast).map(FlowsResponse::getFlowIds).flatMap(Collection::stream).collect(Collectors.toList()));
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) RerouteFlowsForIslRequest(org.openkilda.messaging.nbtopology.request.RerouteFlowsForIslRequest) MessageException(org.openkilda.messaging.error.MessageException) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) Collection(java.util.Collection) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

Collection (java.util.Collection)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 MessageException (org.openkilda.messaging.error.MessageException)1 FlowsResponse (org.openkilda.messaging.info.flow.FlowsResponse)1 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)1 RerouteFlowsForIslRequest (org.openkilda.messaging.nbtopology.request.RerouteFlowsForIslRequest)1