use of org.openkilda.persistence.exceptions.EntityNotFoundException in project open-kilda by telstra.
the class RerouteServiceTest method shouldSkipRerouteRequestsForFlowWithoutAffectedPathSegment.
@Test
public void shouldSkipRerouteRequestsForFlowWithoutAffectedPathSegment() {
PathNode islSide = new PathNode(SWITCH_A.getSwitchId(), 1, 0);
FlowPathRepository pathRepository = mock(FlowPathRepository.class);
when(pathRepository.findBySegmentEndpoint(eq(islSide.getSwitchId()), eq(islSide.getPortNo()))).thenReturn(asList(regularFlow.getForwardPath(), regularFlow.getReversePath()));
FlowRepository flowRepository = mock(FlowRepository.class);
PathSegmentRepository pathSegmentRepository = mock(PathSegmentRepository.class);
doThrow(new EntityNotFoundException("Not found")).when(pathSegmentRepository).updateFailedStatus(any(), any(), anyBoolean());
RepositoryFactory repositoryFactory = mock(RepositoryFactory.class);
when(repositoryFactory.createPathSegmentRepository()).thenReturn(pathSegmentRepository);
when(repositoryFactory.createFlowPathRepository()).thenReturn(pathRepository);
when(repositoryFactory.createFlowRepository()).thenReturn(flowRepository);
PersistenceManager persistenceManager = mock(PersistenceManager.class);
when(persistenceManager.getRepositoryFactory()).thenReturn(repositoryFactory);
when(persistenceManager.getTransactionManager()).thenReturn(transactionManager);
RerouteService rerouteService = new RerouteService(persistenceManager);
RerouteAffectedFlows request = new RerouteAffectedFlows(islSide, "dummy-reason - unittest");
rerouteService.rerouteAffectedFlows(carrier, CORRELATION_ID, request);
verifyZeroInteractions(carrier);
}
use of org.openkilda.persistence.exceptions.EntityNotFoundException in project open-kilda by telstra.
the class RerouteService method updateFlowPathsStateForFlow.
private boolean updateFlowPathsStateForFlow(SwitchId switchId, int port, List<FlowPath> paths) {
boolean rerouteRequired = false;
for (FlowPath fp : paths) {
boolean failedFlowPath = false;
for (PathSegment pathSegment : fp.getSegments()) {
if (pathSegment.getSrcPort() == port && switchId.equals(pathSegment.getSrcSwitchId()) || (pathSegment.getDestPort() == port && switchId.equals(pathSegment.getDestSwitchId()))) {
pathSegment.setFailed(true);
try {
pathSegmentRepository.updateFailedStatus(fp, pathSegment, true);
failedFlowPath = true;
rerouteRequired = true;
} catch (EntityNotFoundException e) {
log.warn("Path segment not found for flow {} and path {}. Skipping path segment status update.", fp.getFlow().getFlowId(), fp.getPathId(), e);
}
break;
}
}
if (failedFlowPath) {
updateFlowPathStatus(fp, FlowPathStatus.INACTIVE);
}
}
return rerouteRequired;
}
Aggregations