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