use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.
the class BaseResourceAllocationAction method createFlowPathPair.
protected FlowPathPair createFlowPathPair(String flowId, FlowResources flowResources, GetPathsResult pathPair, boolean forceToIgnoreBandwidth, String sharedBandwidthGroupId) {
FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(flowResources.getUnmaskedCookie());
return transactionManager.doInTransaction(() -> {
Flow flow = getFlow(flowId);
updateSwitchRelatedFlowProperties(flow);
Path forward = pathPair.getForward();
List<PathSegment> forwardSegments = pathSegmentRepository.findByPathId(flowResources.getForward().getPathId());
FlowPath newForwardPath = flowPathBuilder.buildFlowPath(flow, flowResources.getForward(), forward.getLatency(), forward.getSrcSwitchId(), forward.getDestSwitchId(), forwardSegments, cookieBuilder.direction(FlowPathDirection.FORWARD).build(), forceToIgnoreBandwidth, sharedBandwidthGroupId);
newForwardPath.setStatus(FlowPathStatus.IN_PROGRESS);
Path reverse = pathPair.getReverse();
List<PathSegment> reverseSegments = pathSegmentRepository.findByPathId(flowResources.getReverse().getPathId());
FlowPath newReversePath = flowPathBuilder.buildFlowPath(flow, flowResources.getReverse(), reverse.getLatency(), reverse.getSrcSwitchId(), reverse.getDestSwitchId(), reverseSegments, cookieBuilder.direction(FlowPathDirection.REVERSE).build(), forceToIgnoreBandwidth, sharedBandwidthGroupId);
newReversePath.setStatus(FlowPathStatus.IN_PROGRESS);
log.debug("Persisting the paths {}/{}", newForwardPath, newReversePath);
flowPathRepository.add(newForwardPath);
flowPathRepository.add(newReversePath);
flow.addPaths(newForwardPath, newReversePath);
return FlowPathPair.builder().forward(newForwardPath).reverse(newReversePath).build();
});
}
use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.
the class ResourcesAllocationAction method allocateProtectedPath.
private void allocateProtectedPath(FlowCreateFsm stateMachine) throws UnroutableFlowException, RecoverableException, ResourceAllocationException, FlowNotFoundException {
String flowId = stateMachine.getFlowId();
Flow tmpFlow = getFlow(flowId);
if (!tmpFlow.isAllocateProtectedPath()) {
return;
}
tmpFlow.setDiverseGroupId(getFlowDiverseGroupFromContext(flowId).orElseThrow(() -> new FlowNotFoundException(flowId)));
GetPathsResult protectedPath = pathComputer.getPath(tmpFlow);
stateMachine.setBackUpProtectedPathComputationWayUsed(protectedPath.isBackUpPathComputationWayUsed());
boolean overlappingProtectedPathFound = flowPathBuilder.arePathsOverlapped(protectedPath.getForward(), tmpFlow.getForwardPath()) || flowPathBuilder.arePathsOverlapped(protectedPath.getReverse(), tmpFlow.getReversePath());
if (overlappingProtectedPathFound) {
log.info("Couldn't find non overlapping protected path. Result flow state: {}", tmpFlow);
throw new UnroutableFlowException("Couldn't find non overlapping protected path", tmpFlow.getFlowId());
}
log.debug("Creating the protected path {} for flow {}", protectedPath, tmpFlow);
transactionManager.doInTransaction(() -> {
Flow flow = getFlow(flowId);
FlowResources flowResources = resourcesManager.allocateFlowResources(flow);
final FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(flowResources.getUnmaskedCookie());
FlowPath forward = flowPathBuilder.buildFlowPath(flow, flowResources.getForward(), protectedPath.getForward(), cookieBuilder.direction(FlowPathDirection.FORWARD).build(), false, stateMachine.getSharedBandwidthGroupId());
forward.setStatus(FlowPathStatus.IN_PROGRESS);
flowPathRepository.add(forward);
flow.setProtectedForwardPath(forward);
FlowPath reverse = flowPathBuilder.buildFlowPath(flow, flowResources.getReverse(), protectedPath.getReverse(), cookieBuilder.direction(FlowPathDirection.REVERSE).build(), false, stateMachine.getSharedBandwidthGroupId());
reverse.setStatus(FlowPathStatus.IN_PROGRESS);
flowPathRepository.add(reverse);
flow.setProtectedReversePath(reverse);
updateIslsForFlowPath(forward.getPathId());
updateIslsForFlowPath(reverse.getPathId());
stateMachine.setProtectedForwardPathId(forward.getPathId());
stateMachine.setProtectedReversePathId(reverse.getPathId());
log.debug("Allocated resources for the flow {}: {}", flow.getFlowId(), flowResources);
stateMachine.getFlowResources().add(flowResources);
});
}
use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.
the class HistoryMapper method map.
/**
* Note: you have to additionally set {@link org.openkilda.wfm.share.history.model.FlowDumpData.DumpType}
* to the dump data.
*/
public FlowDumpData map(Flow flow, FlowResources resources, DumpType dumpType) {
FlowDumpData result = generatedMap(flow, resources, dumpType);
FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(resources.getUnmaskedCookie());
result.setForwardCookie(cookieBuilder.direction(FlowPathDirection.FORWARD).build());
result.setReverseCookie(cookieBuilder.direction(FlowPathDirection.REVERSE).build());
return result;
}
use of org.openkilda.model.cookie.FlowSegmentCookie.FlowSegmentCookieBuilder in project open-kilda by telstra.
the class ResourcesAllocationAction method allocateMainPath.
private void allocateMainPath(FlowCreateFsm stateMachine) throws UnroutableFlowException, RecoverableException, ResourceAllocationException {
GetPathsResult paths = pathComputer.getPath(getFlow(stateMachine.getFlowId()));
stateMachine.setBackUpPrimaryPathComputationWayUsed(paths.isBackUpPathComputationWayUsed());
log.debug("Creating the primary path {} for flow {}", paths, stateMachine.getFlowId());
transactionManager.doInTransaction(() -> {
Flow flow = getFlow(stateMachine.getFlowId());
FlowResources flowResources = resourcesManager.allocateFlowResources(flow);
final FlowSegmentCookieBuilder cookieBuilder = FlowSegmentCookie.builder().flowEffectiveId(flowResources.getUnmaskedCookie());
updateSwitchRelatedFlowProperties(flow);
FlowPath forward = flowPathBuilder.buildFlowPath(flow, flowResources.getForward(), paths.getForward(), cookieBuilder.direction(FlowPathDirection.FORWARD).build(), false, stateMachine.getSharedBandwidthGroupId());
forward.setStatus(FlowPathStatus.IN_PROGRESS);
flowPathRepository.add(forward);
flow.setForwardPath(forward);
FlowPath reverse = flowPathBuilder.buildFlowPath(flow, flowResources.getReverse(), paths.getReverse(), cookieBuilder.direction(FlowPathDirection.REVERSE).build(), false, stateMachine.getSharedBandwidthGroupId());
reverse.setStatus(FlowPathStatus.IN_PROGRESS);
flowPathRepository.add(reverse);
flow.setReversePath(reverse);
updateIslsForFlowPath(forward.getPathId());
updateIslsForFlowPath(reverse.getPathId());
stateMachine.setForwardPathId(forward.getPathId());
stateMachine.setReversePathId(reverse.getPathId());
log.debug("Allocated resources for the flow {}: {}", flow.getFlowId(), flowResources);
stateMachine.getFlowResources().add(flowResources);
});
}
Aggregations