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()));
}
}
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);
}
Aggregations