Search in sources :

Example 1 with TimedExecution

use of org.openkilda.wfm.share.metrics.TimedExecution in project open-kilda by telstra.

the class CompleteFlowPathInstallationAction method perform.

@TimedExecution("fsm.complete_flow_path_install")
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
    if (stateMachine.getNewPrimaryForwardPath() != null && stateMachine.getNewPrimaryReversePath() != null) {
        PathId newForward = stateMachine.getNewPrimaryForwardPath();
        PathId newReverse = stateMachine.getNewPrimaryReversePath();
        log.debug("Completing installation of the flow primary path {} / {}", newForward, newReverse);
        FlowPathStatus primaryPathStatus;
        if (stateMachine.isIgnoreBandwidth() || stateMachine.isBackUpPrimaryPathComputationWayUsed()) {
            primaryPathStatus = FlowPathStatus.DEGRADED;
        } else {
            primaryPathStatus = FlowPathStatus.ACTIVE;
        }
        transactionManager.doInTransaction(() -> {
            flowPathRepository.updateStatus(newForward, primaryPathStatus);
            flowPathRepository.updateStatus(newReverse, primaryPathStatus);
        });
        stateMachine.saveActionToHistory("Flow paths were installed", format("The flow paths %s / %s were installed", newForward, newReverse));
    }
    if (stateMachine.getNewProtectedForwardPath() != null && stateMachine.getNewProtectedReversePath() != null) {
        PathId newForward = stateMachine.getNewProtectedForwardPath();
        PathId newReverse = stateMachine.getNewProtectedReversePath();
        FlowPathStatus protectedPathStatus;
        if (stateMachine.isIgnoreBandwidth() || stateMachine.isBackUpProtectedPathComputationWayUsed()) {
            protectedPathStatus = FlowPathStatus.DEGRADED;
        } else {
            protectedPathStatus = FlowPathStatus.ACTIVE;
        }
        log.debug("Completing installation of the flow protected path {} / {}", newForward, newReverse);
        transactionManager.doInTransaction(() -> {
            flowPathRepository.updateStatus(newForward, protectedPathStatus);
            flowPathRepository.updateStatus(newReverse, protectedPathStatus);
        });
        stateMachine.saveActionToHistory("Flow paths were installed", format("The flow paths %s / %s were installed", newForward, newReverse));
    }
}
Also used : PathId(org.openkilda.model.PathId) FlowPathStatus(org.openkilda.model.FlowPathStatus) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Example 2 with TimedExecution

use of org.openkilda.wfm.share.metrics.TimedExecution in project open-kilda by telstra.

the class UpdateFlowStatusAction method perform.

@TimedExecution("fsm.update_flow_status")
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
    String flowId = stateMachine.getFlowId();
    FlowStatus resultStatus = transactionManager.doInTransaction(() -> {
        Flow flow = getFlow(flowId);
        FlowStatus flowStatus = flow.computeFlowStatus();
        if (flowStatus != flow.getStatus()) {
            dashboardLogger.onFlowStatusUpdate(flowId, flowStatus);
            flow.setStatus(flowStatus);
            flow.setStatusInfo(getFlowStatusInfo(flow, flowStatus, stateMachine));
        } else if (FlowStatus.DEGRADED.equals(flowStatus)) {
            flow.setStatusInfo(getDegradedFlowStatusInfo(flow, stateMachine));
        }
        stateMachine.setNewFlowStatus(flowStatus);
        return flowStatus;
    });
    stateMachine.saveActionToHistory(format("The flow status was set to %s", resultStatus));
}
Also used : FlowStatus(org.openkilda.model.FlowStatus) Flow(org.openkilda.model.Flow) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Example 3 with TimedExecution

use of org.openkilda.wfm.share.metrics.TimedExecution in project open-kilda by telstra.

the class CompleteFlowPathRemovalAction method perform.

@TimedExecution("fsm.complete_flow_path_remove")
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
    Flow flow = getFlow(stateMachine.getFlowId());
    removeOldPrimaryFlowPaths(flow, stateMachine);
    removeOldProtectedFlowPaths(flow, stateMachine);
    removeRejectedFlowPaths(flow, stateMachine);
}
Also used : Flow(org.openkilda.model.Flow) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Example 4 with TimedExecution

use of org.openkilda.wfm.share.metrics.TimedExecution in project open-kilda by telstra.

the class SwapFlowPathsAction method perform.

@TimedExecution("fsm.swap_flow_paths")
@Override
protected void perform(State from, State to, Event event, FlowRerouteContext context, FlowRerouteFsm stateMachine) {
    swapPrimaryPaths(stateMachine);
    swapProtectedPaths(stateMachine);
    if (stateMachine.getNewEncapsulationType() != null) {
        transactionManager.doInTransaction(() -> {
            Flow flow = getFlow(stateMachine.getFlowId());
            flow.setEncapsulationType(stateMachine.getNewEncapsulationType());
        });
    }
}
Also used : Flow(org.openkilda.model.Flow) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Example 5 with TimedExecution

use of org.openkilda.wfm.share.metrics.TimedExecution in project open-kilda by telstra.

the class HistoryOperationsBolt method getFlowHistory.

@TimedExecution("get_flow_history")
private List<InfoData> getFlowHistory(GetFlowHistoryRequest request) {
    Instant timeFrom = Instant.ofEpochSecond(request.getTimestampFrom());
    Instant timeTo = Instant.ofEpochSecond(request.getTimestampTo() + 1).minusMillis(1);
    return historyService.listFlowEvents(request.getFlowId(), timeFrom, timeTo, request.getMaxCount()).stream().map(entry -> {
        List<FlowHistoryPayload> payload = listFlowHistories(entry);
        List<FlowDumpPayload> dumps = listFlowDumps(entry);
        return HistoryMapper.INSTANCE.map(entry, payload, dumps);
    }).collect(Collectors.toList());
}
Also used : BaseRequest(org.openkilda.messaging.nbtopology.request.BaseRequest) FlowDumpPayload(org.openkilda.messaging.payload.history.FlowDumpPayload) FlowEvent(org.openkilda.model.history.FlowEvent) GetFlowStatusTimestampsRequest(org.openkilda.messaging.nbtopology.request.GetFlowStatusTimestampsRequest) PortHistoryRequest(org.openkilda.messaging.nbtopology.request.PortHistoryRequest) HistoryMapper(org.openkilda.wfm.share.mappers.HistoryMapper) InfoData(org.openkilda.messaging.info.InfoData) StreamType(org.openkilda.wfm.topology.nbworker.StreamType) Instant(java.time.Instant) HistoryService(org.openkilda.wfm.share.history.service.HistoryService) Collectors(java.util.stream.Collectors) List(java.util.List) Tuple(org.apache.storm.tuple.Tuple) FlowHistoryPayload(org.openkilda.messaging.payload.history.FlowHistoryPayload) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution) GetFlowHistoryRequest(org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest) PersistenceManager(org.openkilda.persistence.PersistenceManager) Instant(java.time.Instant) List(java.util.List) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Aggregations

TimedExecution (org.openkilda.wfm.share.metrics.TimedExecution)16 Flow (org.openkilda.model.Flow)11 SwitchId (org.openkilda.model.SwitchId)6 FlowPath (org.openkilda.model.FlowPath)5 MessageException (org.openkilda.messaging.error.MessageException)4 IslEndpoint (org.openkilda.model.IslEndpoint)4 HashSet (java.util.HashSet)3 FlowStatus (org.openkilda.model.FlowStatus)3 PathId (org.openkilda.model.PathId)3 IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 PathNode (org.openkilda.messaging.info.event.PathNode)2 YFlow (org.openkilda.model.YFlow)2 GetPathsResult (org.openkilda.pce.GetPathsResult)2 PersistenceManager (org.openkilda.persistence.PersistenceManager)2 SwitchNotFoundException (org.openkilda.wfm.error.SwitchNotFoundException)2 FlowResources (org.openkilda.wfm.share.flow.resources.FlowResources)2 FlowPathPair (org.openkilda.wfm.topology.flow.model.FlowPathPair)2 FlowThrottlingData (org.openkilda.wfm.topology.reroute.model.FlowThrottlingData)2