Search in sources :

Example 1 with State

use of org.openkilda.messaging.model.PingReport.State 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 2 with State

use of org.openkilda.messaging.model.PingReport.State 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)

Aggregations

Entry (java.util.Map.Entry)2 State (org.openkilda.messaging.model.PingReport.State)2 FlowObserver (org.openkilda.wfm.topology.ping.model.FlowObserver)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 Flow (org.openkilda.model.Flow)1 PipelineException (org.openkilda.wfm.error.PipelineException)1 PingContext (org.openkilda.wfm.topology.ping.model.PingContext)1 PingObserver (org.openkilda.wfm.topology.ping.model.PingObserver)1