Search in sources :

Example 11 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class OnDemandResultManager method buildYFlowPingResponse.

private YFlowPingResponse buildYFlowPingResponse(Group group) {
    Map<String, SubFlowPingPayload> subFlowMap = new HashMap<>();
    Set<String> yFlowIdSet = new HashSet<>();
    for (PingContext record : group.getRecords()) {
        if (record.getYFlowId() == null) {
            throw new IllegalArgumentException(format("Ping report %s has no yFlowId", record));
        }
        yFlowIdSet.add(record.getYFlowId());
        SubFlowPingPayload subFlow = subFlowMap.computeIfAbsent(record.getFlowId(), mappingFunction -> new SubFlowPingPayload(record.getFlowId(), null, null));
        switch(record.getDirection()) {
            case FORWARD:
                validateSubFlow(subFlow.getForward(), FORWARD, group, record, subFlow.getFlowId());
                subFlow.setForward(makeSubFlowPayload(record));
                break;
            case REVERSE:
                validateSubFlow(subFlow.getReverse(), REVERSE, group, record, subFlow.getFlowId());
                subFlow.setReverse(makeSubFlowPayload(record));
                break;
            default:
                throw new IllegalArgumentException(format("Unsupported %s.%s value", record.getDirection().getClass().getName(), record.getDirection()));
        }
    }
    if (subFlowMap.size() * 2 != group.getRecords().size()) {
        throw new IllegalArgumentException(format("Expect %d unique Flow IDs in ping group responses, but got responses about %d Flows: %s", group.getRecords().size() / 2, subFlowMap.size(), subFlowMap.keySet()));
    }
    if (yFlowIdSet.size() != 1) {
        throw new IllegalArgumentException(format("Expect exact one Y Flow id in pings group response, got - %s", yFlowIdSet));
    }
    return new YFlowPingResponse(yFlowIdSet.iterator().next(), null, new ArrayList<>(subFlowMap.values()));
}
Also used : HashMap(java.util.HashMap) YFlowPingResponse(org.openkilda.messaging.info.flow.YFlowPingResponse) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) UniSubFlowPingPayload(org.openkilda.messaging.info.flow.UniSubFlowPingPayload) SubFlowPingPayload(org.openkilda.messaging.info.flow.SubFlowPingPayload) HashSet(java.util.HashSet)

Example 12 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class OnDemandResultManager method produceFlowErrors.

private List<FlowPingResponse> produceFlowErrors(Group group, String errorMessage) {
    HashSet<String> seen = new HashSet<>();
    ArrayList<FlowPingResponse> results = new ArrayList<>();
    for (PingContext pingContext : group.getRecords()) {
        if (!seen.add(pingContext.getFlowId())) {
            continue;
        }
        log.info("Produce error response (group={}, flow={}): {}", group.getId(), pingContext.getFlowId(), errorMessage);
        results.add(new FlowPingResponse(pingContext.getFlowId(), errorMessage));
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) YFlowPingResponse(org.openkilda.messaging.info.flow.YFlowPingResponse) UniFlowPingResponse(org.openkilda.messaging.info.flow.UniFlowPingResponse) FlowPingResponse(org.openkilda.messaging.info.flow.FlowPingResponse) HashSet(java.util.HashSet)

Example 13 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class PeriodicPingShaping method handlePing.

private void handlePing(Tuple input) throws PipelineException {
    Values output = extract(input);
    if (burstCalculator == null) {
        // ping-shaping disabled, silently proxying
        emit(input, output);
        return;
    }
    PingContext ping = pullPingContext(input);
    if (ping.getKind() != Kinds.PERIODIC) {
        emit(input, output);
        return;
    }
    burstCalculator.increment();
    proxy(input, output, ping);
    logStats();
}
Also used : Values(org.apache.storm.tuple.Values) PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Example 14 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class PingProducer method handleInput.

@Override
protected void handleInput(Tuple input) throws Exception {
    PingContext pingContext = pullPingContext(input);
    // TODO(surabujin): add one switch flow filter
    emit(input, produce(pingContext, FlowDirection.FORWARD));
    emit(input, produce(pingContext, FlowDirection.REVERSE));
}
Also used : PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Example 15 with PingContext

use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.

the class StatsProducer method handleInput.

@Override
protected void handleInput(Tuple input) throws Exception {
    PingContext pingContext = pullPingContext(input);
    HashMap<String, String> tags = new HashMap<>();
    tags.put("flowid", pingContext.getFlowId());
    if (pingContext.getYFlowId() != null) {
        tags.put("y_flow_id", pingContext.getYFlowId());
    }
    produceMetersStats(input, tags, pingContext);
}
Also used : HashMap(java.util.HashMap) PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Aggregations

PingContext (org.openkilda.wfm.topology.ping.model.PingContext)19 Values (org.apache.storm.tuple.Values)5 GroupId (org.openkilda.wfm.topology.ping.model.GroupId)4 HashSet (java.util.HashSet)3 YFlowPingResponse (org.openkilda.messaging.info.flow.YFlowPingResponse)3 CommandContext (org.openkilda.wfm.CommandContext)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 YFlowPingRequest (org.openkilda.messaging.command.flow.YFlowPingRequest)2 Flow (org.openkilda.model.Flow)2 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)2 YFlow (org.openkilda.model.YFlow)2 YSubFlow (org.openkilda.model.YSubFlow)2 FlowPingRequest (org.openkilda.messaging.command.flow.FlowPingRequest)1 FlowPingResponse (org.openkilda.messaging.info.flow.FlowPingResponse)1 FlowPingResponseBuilder (org.openkilda.messaging.info.flow.FlowPingResponse.FlowPingResponseBuilder)1 SubFlowPingPayload (org.openkilda.messaging.info.flow.SubFlowPingPayload)1 UniFlowPingResponse (org.openkilda.messaging.info.flow.UniFlowPingResponse)1 UniSubFlowPingPayload (org.openkilda.messaging.info.flow.UniSubFlowPingPayload)1 WorkflowException (org.openkilda.wfm.error.WorkflowException)1