use of org.openkilda.wfm.topology.flow.model.FlowPathPair in project open-kilda by telstra.
the class RevertPathsSwapAction method perform.
@Override
protected void perform(State from, State to, Event event, FlowPathSwapContext context, FlowPathSwapFsm stateMachine) {
FlowPathPair pathPair = transactionManager.doInTransaction(() -> {
String flowId = stateMachine.getFlowId();
Flow flow = getFlow(flowId);
log.debug("Reverting primary and protected paths swap for flow {}", flowId);
FlowPath oldPrimaryForward = flow.getForwardPath();
FlowPath oldPrimaryReverse = flow.getReversePath();
PathId newPrimaryForward = flow.getProtectedForwardPathId();
PathId newPrimaryReverse = flow.getProtectedReversePathId();
setMirrorPointsToNewPath(oldPrimaryForward.getPathId(), newPrimaryForward);
setMirrorPointsToNewPath(oldPrimaryReverse.getPathId(), newPrimaryReverse);
flow.setForwardPathId(newPrimaryForward);
flow.setReversePathId(newPrimaryReverse);
flow.setProtectedForwardPathId(oldPrimaryForward.getPathId());
flow.setProtectedReversePathId(oldPrimaryReverse.getPathId());
return new FlowPathPair(oldPrimaryForward, oldPrimaryReverse);
});
saveHistory(stateMachine, stateMachine.getFlowId(), pathPair.getForwardPathId(), pathPair.getReversePathId());
}
use of org.openkilda.wfm.topology.flow.model.FlowPathPair 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");
}
}
Aggregations