use of org.openkilda.wfm.topology.flowhs.fsm.yflow.reroute.YFlowRerouteFsm in project open-kilda by telstra.
the class StartReroutingYFlowAction method perform.
@Override
protected void perform(State from, State to, Event event, YFlowRerouteContext context, YFlowRerouteFsm stateMachine) {
String yFlowId = stateMachine.getYFlowId();
List<FlowPath> flowPaths = transactionManager.doInTransaction(() -> {
YFlow yFlow = getYFlow(yFlowId);
saveOldResources(stateMachine, yFlow);
stateMachine.setDeleteOldYFlowCommands(buildYFlowDeleteCommands(yFlow, stateMachine.getCommandContext()));
SwitchId sharedSwitchId = yFlow.getSharedEndpoint().getSwitchId();
return yFlow.getSubFlows().stream().map(YSubFlow::getFlow).flatMap(flow -> Stream.of(flow.getForwardPath(), flow.getReversePath())).filter(path -> sharedSwitchId.equals(path.getSrcSwitchId())).collect(Collectors.toList());
});
stateMachine.setOldYFlowPathCookies(flowPaths.stream().map(FlowPath::getCookie).map(FlowSegmentCookie::getValue).collect(Collectors.toList()));
List<PathSegment> sharedPathSegments = IntersectionComputer.calculatePathIntersectionFromSource(flowPaths);
PathInfoData sharedPath = FlowPathMapper.INSTANCE.map(sharedPathSegments);
stateMachine.setOldSharedPath(sharedPath);
List<SubFlowPathDto> subFlowPathDtos = flowPaths.stream().map(flowPath -> new SubFlowPathDto(flowPath.getFlowId(), FlowPathMapper.INSTANCE.map(flowPath))).sorted(Comparator.comparing(SubFlowPathDto::getFlowId)).collect(Collectors.toList());
stateMachine.setOldSubFlowPathDtos(subFlowPathDtos);
}
Aggregations