Search in sources :

Example 1 with FlowPingRequest

use of org.openkilda.messaging.command.flow.FlowPingRequest in project open-kilda by telstra.

the class FlowFetcher method handleOnDemandRequest.

private void handleOnDemandRequest(Tuple input) throws PipelineException {
    log.debug("Handle on demand ping request");
    FlowPingRequest request = pullOnDemandRequest(input);
    Optional<Flow> optionalFlow = flowRepository.findById(request.getFlowId());
    if (optionalFlow.isPresent()) {
        Flow flow = optionalFlow.get();
        flowRepository.detach(flow);
        if (!flow.isOneSwitchFlow()) {
            Optional<FlowTransitEncapsulation> transitEncapsulation = getTransitEncapsulation(flow);
            if (transitEncapsulation.isPresent()) {
                PingContext pingContext = PingContext.builder().group(new GroupId(DIRECTION_COUNT_PER_FLOW)).kind(Kinds.ON_DEMAND).flow(flow).transitEncapsulation(transitEncapsulation.get()).timeout(request.getTimeout()).build();
                emit(input, pingContext, pullContext(input));
            } else {
                emitOnDemandResponse(input, request, format("Encapsulation resource not found for flow %s", request.getFlowId()));
            }
        } else {
            emitOnDemandResponse(input, request, format("Flow %s should not be one switch flow", request.getFlowId()));
        }
    } else {
        emitOnDemandResponse(input, request, format("Flow %s does not exist", request.getFlowId()));
    }
}
Also used : FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) FlowPingRequest(org.openkilda.messaging.command.flow.FlowPingRequest) YFlowPingRequest(org.openkilda.messaging.command.flow.YFlowPingRequest) Flow(org.openkilda.model.Flow) YFlow(org.openkilda.model.YFlow) YSubFlow(org.openkilda.model.YSubFlow) GroupId(org.openkilda.wfm.topology.ping.model.GroupId)

Example 2 with FlowPingRequest

use of org.openkilda.messaging.command.flow.FlowPingRequest in project open-kilda by telstra.

the class FlowServiceImpl method pingFlow.

@Override
public CompletableFuture<PingOutput> pingFlow(String flowId, PingInput payload) {
    FlowPingRequest request = new FlowPingRequest(flowId, payload.getTimeoutMillis());
    final String correlationId = RequestCorrelationId.getId();
    CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId, Destination.WFM);
    return messagingChannel.sendAndGet(pingTopic, message).thenApply(FlowPingResponse.class::cast).thenApply(flowMapper::toPingOutput);
}
Also used : FlowPingRequest(org.openkilda.messaging.command.flow.FlowPingRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

FlowPingRequest (org.openkilda.messaging.command.flow.FlowPingRequest)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 YFlowPingRequest (org.openkilda.messaging.command.flow.YFlowPingRequest)1 Flow (org.openkilda.model.Flow)1 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)1 YFlow (org.openkilda.model.YFlow)1 YSubFlow (org.openkilda.model.YSubFlow)1 GroupId (org.openkilda.wfm.topology.ping.model.GroupId)1 PingContext (org.openkilda.wfm.topology.ping.model.PingContext)1