Search in sources :

Example 1 with FlowLoopsResponse

use of org.openkilda.messaging.nbtopology.response.FlowLoopsResponse in project open-kilda by telstra.

the class FlowOperationsBolt method processGetFlowLoopsRequest.

private List<InfoData> processGetFlowLoopsRequest(GetFlowLoopsRequest request) {
    try {
        SwitchId switchId = request.getSwitchId() == null ? null : new SwitchId(request.getSwitchId());
        List<FlowLoopDto> flowLoops = flowOperationsService.getLoopedFlows(request.getFlowId(), switchId).stream().map(this::map).collect(Collectors.toList());
        FlowLoopsResponse flowLoopsResponse = new FlowLoopsResponse();
        flowLoopsResponse.setPayload(flowLoops);
        return Collections.singletonList(flowLoopsResponse);
    } catch (Exception e) {
        throw new MessageException(ErrorType.INTERNAL_ERROR, "Can not dump flow loops", "Internal Error");
    }
}
Also used : MessageException(org.openkilda.messaging.error.MessageException) SwitchId(org.openkilda.model.SwitchId) FlowLoopDto(org.openkilda.messaging.nbtopology.response.FlowLoopDto) FlowLoopsResponse(org.openkilda.messaging.nbtopology.response.FlowLoopsResponse) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) SwitchNotFoundException(org.openkilda.wfm.error.SwitchNotFoundException) MessageException(org.openkilda.messaging.error.MessageException) FlowNotFoundException(org.openkilda.wfm.error.FlowNotFoundException)

Example 2 with FlowLoopsResponse

use of org.openkilda.messaging.nbtopology.response.FlowLoopsResponse in project open-kilda by telstra.

the class FlowServiceImpl method getFlowLoops.

@Override
public CompletableFuture<List<FlowLoopResponse>> getFlowLoops(String flowId, String switchId) {
    logger.info("Get flow loops for flow {} and switch {}", flowId, switchId);
    GetFlowLoopsRequest request = new GetFlowLoopsRequest(flowId, switchId);
    CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), RequestCorrelationId.getId(), Destination.WFM);
    return messagingChannel.sendAndGet(nbworkerTopic, message).thenApply(result -> Optional.of(result).map(FlowLoopsResponse.class::cast).map(FlowLoopsResponse::getPayload).orElse(Collections.emptyList()).stream().map(flowMapper::toFlowLoopResponse).collect(Collectors.toList()));
}
Also used : FlowLoopsResponse(org.openkilda.messaging.nbtopology.response.FlowLoopsResponse) GetFlowLoopsRequest(org.openkilda.messaging.nbtopology.request.GetFlowLoopsRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

FlowLoopsResponse (org.openkilda.messaging.nbtopology.response.FlowLoopsResponse)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 MessageException (org.openkilda.messaging.error.MessageException)1 GetFlowLoopsRequest (org.openkilda.messaging.nbtopology.request.GetFlowLoopsRequest)1 FlowLoopDto (org.openkilda.messaging.nbtopology.response.FlowLoopDto)1 SwitchId (org.openkilda.model.SwitchId)1 FlowNotFoundException (org.openkilda.wfm.error.FlowNotFoundException)1 IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)1 SwitchNotFoundException (org.openkilda.wfm.error.SwitchNotFoundException)1