use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.
the class FlowFetcher method handlePeriodicRequest.
private void handlePeriodicRequest(Tuple input) throws PipelineException {
log.debug("Handle periodic ping request");
if (lastPeriodicPingCacheRefresh + periodicPingCacheExpiryInterval < System.currentTimeMillis()) {
refreshHeap(input, true);
}
final CommandContext commandContext = pullContext(input);
for (FlowWithTransitEncapsulation flow : flowsSet) {
PingContext pingContext = PingContext.builder().group(new GroupId(DIRECTION_COUNT_PER_FLOW)).kind(Kinds.PERIODIC).flow(flow.getFlow()).yFlowId(flow.yFlowId).transitEncapsulation(flow.getTransitEncapsulation()).build();
emit(input, pingContext, commandContext);
}
}
use of org.openkilda.wfm.topology.ping.model.PingContext in project open-kilda by telstra.
the class GroupCollector method saveCurrentRecord.
private CollectorDescriptor saveCurrentRecord(Tuple input) throws Exception {
final PingContext pingContext = pullPingContext(input);
// expiring is only a memory leakage protection in this place
// waiting ping command timeout + storm internal processing delay milliseconds
long expireAt = System.currentTimeMillis() + pingContext.getTimeout() + expireDelay;
CollectorDescriptor descriptor = new CollectorDescriptor(expireAt, pingContext.getGroup());
descriptor = cache.addIfAbsent(descriptor);
try {
int size = descriptor.add(pingContext);
GroupId group = descriptor.getGroupId();
log.debug("Group {} add {} of {} response {}", group.getId(), size, group.getSize(), pingContext);
} catch (IllegalArgumentException e) {
throw new WorkflowException(this, input, e.toString());
}
return descriptor;
}
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();
}
Aggregations