Search in sources :

Example 1 with FlowObserver

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

the class FailReporter method handlePing.

private void handlePing(Tuple input) throws PipelineException {
    PingContext pingContext = pullPingContext(input);
    if (pingContext.isPermanentError()) {
        log.warn("Do not include permanent ping error in report ({})", pingContext);
        return;
    }
    FlowObserver flowObserver = this.flowsStatusMap.computeIfAbsent(pingContext.getFlowId(), k -> new FlowObserver(pingContext.getFlowId(), pingStatusBuilder));
    flowObserver.update(pingContext);
}
Also used : FlowObserver(org.openkilda.wfm.topology.ping.model.FlowObserver) PingContext(org.openkilda.wfm.topology.ping.model.PingContext)

Example 2 with FlowObserver

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

the class FailReporter method report.

private void report(Tuple input, String flowId, FlowObserver flowObserver, State state) throws PipelineException {
    String logMessage = String.format("{FLOW-PING} Flow %s become %s", flowId, state);
    if (state != State.OPERATIONAL) {
        String cookies = flowObserver.getFlowTreadsInState(state).stream().map(cookie -> String.format("0x%016x", cookie)).collect(Collectors.joining(", "));
        if (!cookies.isEmpty()) {
            logMessage += String.format("(%s)", cookies);
        }
    }
    log.info(logMessage);
    Values output = new Values(new PingReport(flowId, state), pullContext(input));
    getOutput().emit(input, output);
}
Also used : OutputFieldsDeclarer(org.apache.storm.topology.OutputFieldsDeclarer) PingObserver(org.openkilda.wfm.topology.ping.model.PingObserver) Iterator(java.util.Iterator) PingReport(org.openkilda.messaging.model.PingReport) HashMap(java.util.HashMap) Fields(org.apache.storm.tuple.Fields) FlowObserver(org.openkilda.wfm.topology.ping.model.FlowObserver) Collectors(java.util.stream.Collectors) State(org.openkilda.messaging.model.PingReport.State) TimeUnit(java.util.concurrent.TimeUnit) Values(org.apache.storm.tuple.Values) Tuple(org.apache.storm.tuple.Tuple) Flow(org.openkilda.model.Flow) PipelineException(org.openkilda.wfm.error.PipelineException) PingContext(org.openkilda.wfm.topology.ping.model.PingContext) Entry(java.util.Map.Entry) Values(org.apache.storm.tuple.Values) PingReport(org.openkilda.messaging.model.PingReport)

Example 3 with FlowObserver

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

the class FailReporter method handleTick.

private void handleTick(Tuple input) throws PipelineException {
    final long now = input.getLongByField(MonotonicTick.FIELD_ID_TIME_MILLIS);
    for (Iterator<Entry<String, FlowObserver>> iterator = flowsStatusMap.entrySet().iterator(); iterator.hasNext(); ) {
        Entry<String, FlowObserver> entry = iterator.next();
        FlowObserver flowObserver = entry.getValue();
        final String flowId = entry.getKey();
        if (flowObserver.isGarbage()) {
            iterator.remove();
            log.info("Remove flow observer (flowId: {})", flowId);
            continue;
        }
        State state = flowObserver.timeTick(now);
        if (state != null) {
            report(input, flowId, flowObserver, state);
        }
    }
}
Also used : Entry(java.util.Map.Entry) FlowObserver(org.openkilda.wfm.topology.ping.model.FlowObserver) State(org.openkilda.messaging.model.PingReport.State)

Example 4 with FlowObserver

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

the class FailReporter method handleCacheExpiration.

private void handleCacheExpiration(Tuple input) throws PipelineException {
    Flow ref = pullFlow(input);
    FlowObserver status = flowsStatusMap.get(ref.getFlowId());
    if (status != null) {
        status.remove(ref.getForwardPath().getCookie().getValue());
        status.remove(ref.getReversePath().getCookie().getValue());
    }
}
Also used : FlowObserver(org.openkilda.wfm.topology.ping.model.FlowObserver) Flow(org.openkilda.model.Flow)

Aggregations

FlowObserver (org.openkilda.wfm.topology.ping.model.FlowObserver)4 Entry (java.util.Map.Entry)2 State (org.openkilda.messaging.model.PingReport.State)2 Flow (org.openkilda.model.Flow)2 PingContext (org.openkilda.wfm.topology.ping.model.PingContext)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 OutputFieldsDeclarer (org.apache.storm.topology.OutputFieldsDeclarer)1 Fields (org.apache.storm.tuple.Fields)1 Tuple (org.apache.storm.tuple.Tuple)1 Values (org.apache.storm.tuple.Values)1 PingReport (org.openkilda.messaging.model.PingReport)1 PipelineException (org.openkilda.wfm.error.PipelineException)1 PingObserver (org.openkilda.wfm.topology.ping.model.PingObserver)1