Search in sources :

Example 1 with FlowLatencyRequest

use of org.openkilda.wfm.topology.flowmonitoring.model.FlowLatencyRequest in project open-kilda by telstra.

the class CalculateFlowLatencyService method handleGetLinkLatencyResponse.

/**
 * Handle get link latency response. Send check flow latency request if ready.
 */
public void handleGetLinkLatencyResponse(String requestId, Link link, Duration latency) {
    log.debug("Get link latency response for link {} with {} and requestId {}", link, latency, requestId);
    FlowLatencyRequest flowLatencyRequest = requests.get(requestId);
    if (flowLatencyRequest == null) {
        log.warn("Link latency response for unknown request found {}", link);
        return;
    }
    flowLatencyRequest.handleResponse(link, latency);
    if (flowLatencyRequest.isFulfilled()) {
        log.debug("Process calculated latency for requestId {}", requestId);
        String flowId = flowLatencyRequest.getFlowId();
        FlowDirection direction = flowLatencyRequest.getDirection();
        Duration result = flowLatencyRequest.getResult();
        carrier.emitCheckFlowLatencyRequest(flowId, direction, result);
        carrier.emitLatencyStats(flowId, direction, result);
        requests.remove(requestId);
    }
}
Also used : FlowLatencyRequest(org.openkilda.wfm.topology.flowmonitoring.model.FlowLatencyRequest) FlowDirection(org.openkilda.server42.messaging.FlowDirection) Duration(java.time.Duration)

Example 2 with FlowLatencyRequest

use of org.openkilda.wfm.topology.flowmonitoring.model.FlowLatencyRequest in project open-kilda by telstra.

the class CalculateFlowLatencyService method handleCalculateFlowLatencyRequest.

/**
 * Handle calculate flow latency request.
 */
public void handleCalculateFlowLatencyRequest(String flowId, FlowDirection direction, List<Link> flowPath) {
    requests.values().stream().filter(request -> request.getFlowId().equals(flowId) && request.getDirection() == direction).findAny().ifPresent(flowLatencyRequest -> {
        FlowLatencyRequest remove = requests.remove(flowLatencyRequest.getRequestId());
        log.warn("Removing previous calculate flow latency request for {} {} for requestId {}", flowId, direction, remove.getRequestId());
    });
    String requestId = UUID.randomUUID().toString();
    requests.put(requestId, FlowLatencyRequest.builder().requestId(requestId).flowId(flowId).direction(direction).flowPath(flowPath).build());
    flowPath.forEach(link -> carrier.emitGetLinkLatencyRequest(flowId, requestId, link));
}
Also used : FlowLatencyRequest(org.openkilda.wfm.topology.flowmonitoring.model.FlowLatencyRequest)

Aggregations

FlowLatencyRequest (org.openkilda.wfm.topology.flowmonitoring.model.FlowLatencyRequest)2 Duration (java.time.Duration)1 FlowDirection (org.openkilda.server42.messaging.FlowDirection)1