Search in sources :

Example 16 with TimedExecution

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

the class AllocatePrimaryResourcesAction method allocate.

@TimedExecution("fsm.resource_allocation_primary")
@Override
protected void allocate(FlowRerouteFsm stateMachine) throws RecoverableException, UnroutableFlowException, ResourceAllocationException {
    String flowId = stateMachine.getFlowId();
    Flow tmpFlowCopy = getFlow(flowId);
    // Detach the entity to avoid propagation to the database.
    flowRepository.detach(tmpFlowCopy);
    if (stateMachine.getNewEncapsulationType() != null) {
        // This is for PCE to use proper (updated) encapsulation type.
        tmpFlowCopy.setEncapsulationType(stateMachine.getNewEncapsulationType());
    }
    FlowPathPair oldPaths = new FlowPathPair(tmpFlowCopy.getForwardPath(), tmpFlowCopy.getReversePath());
    PathId newForwardPathId = resourcesManager.generatePathId(flowId);
    PathId newReversePathId = resourcesManager.generatePathId(flowId);
    List<PathId> pathsToReuse = Lists.newArrayList(tmpFlowCopy.getForwardPathId(), tmpFlowCopy.getReversePathId());
    pathsToReuse.addAll(stateMachine.getRejectedPaths());
    log.debug("Finding a new primary path for flow {}", flowId);
    GetPathsResult allocatedPaths = allocatePathPair(tmpFlowCopy, newForwardPathId, newReversePathId, stateMachine.isIgnoreBandwidth(), pathsToReuse, oldPaths, stateMachine.isRecreateIfSamePath(), stateMachine.getSharedBandwidthGroupId(), path -> true);
    if (allocatedPaths != null) {
        log.debug("New primary paths have been allocated: {}", allocatedPaths);
        stateMachine.setBackUpPrimaryPathComputationWayUsed(allocatedPaths.isBackUpPathComputationWayUsed());
        stateMachine.setNewPrimaryForwardPath(newForwardPathId);
        stateMachine.setNewPrimaryReversePath(newReversePathId);
        log.debug("Allocating resources for a new primary path of flow {}", flowId);
        FlowResources flowResources = allocateFlowResources(tmpFlowCopy, newForwardPathId, newReversePathId);
        stateMachine.setNewPrimaryResources(flowResources);
        FlowPathPair createdPaths = createFlowPathPair(flowId, flowResources, allocatedPaths, stateMachine.isIgnoreBandwidth(), stateMachine.getSharedBandwidthGroupId());
        log.debug("New primary paths have been created: {}", createdPaths);
        setMirrorPointsToNewPath(oldPaths.getForwardPathId(), newForwardPathId);
        setMirrorPointsToNewPath(oldPaths.getReversePathId(), newReversePathId);
        saveAllocationActionWithDumpsToHistory(stateMachine, tmpFlowCopy, "primary", createdPaths);
    } else {
        stateMachine.saveActionToHistory("Found the same primary path. Skipped creating of it");
    }
}
Also used : PathId(org.openkilda.model.PathId) FlowResources(org.openkilda.wfm.share.flow.resources.FlowResources) Flow(org.openkilda.model.Flow) FlowPathPair(org.openkilda.wfm.topology.flow.model.FlowPathPair) GetPathsResult(org.openkilda.pce.GetPathsResult) 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