Search in sources :

Example 1 with Context

use of org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.Context in project open-kilda by telstra.

the class ActionService method processTick.

/**
 * Process tick.
 */
public void processTick() {
    Context context = Context.builder().carrier(this).build();
    fsms.values().forEach(fsm -> fsmExecutor.fire(fsm, Event.TICK, context));
}
Also used : Context(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.Context)

Example 2 with Context

use of org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.Context in project open-kilda by telstra.

the class ActionService method processFlowLatencyMeasurement.

/**
 * Check flow SLA is violated.
 */
public void processFlowLatencyMeasurement(String flowId, FlowDirection direction, Duration latency) {
    String key = getFsmKey(flowId, direction);
    FlowLatencyMonitoringFsm fsm = fsms.get(key);
    if (fsm == null) {
        Flow flow = flowRepository.findById(flowId).orElseThrow(() -> new IllegalStateException(format("Flow %s not found.", flowId)));
        long maxLatency = flow.getMaxLatency() == null || flow.getMaxLatency() == 0 ? Long.MAX_VALUE : flow.getMaxLatency();
        long maxLatencyTier2 = flow.getMaxLatencyTier2() == null || flow.getMaxLatencyTier2() == 0 ? Long.MAX_VALUE : flow.getMaxLatencyTier2();
        fsm = fsmFactory.produce(flowId, direction.name().toLowerCase(), maxLatency, maxLatencyTier2);
        fsms.put(key, fsm);
    }
    Context context = Context.builder().latency(latency.toNanos()).carrier(this).build();
    fsm.processLatencyMeasurement(context);
}
Also used : Context(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.Context) FlowLatencyMonitoringFsm(org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm) Flow(org.openkilda.model.Flow)

Aggregations

Context (org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm.Context)2 Flow (org.openkilda.model.Flow)1 FlowLatencyMonitoringFsm (org.openkilda.wfm.topology.flowmonitoring.fsm.FlowLatencyMonitoringFsm)1