use of org.openkilda.persistence.repositories.IslRepository in project open-kilda by telstra.
the class NetworkHistoryService method loadNetworkHistory.
// -- private --
private Collection<HistoryFacts> loadNetworkHistory() {
RepositoryFactory repositoryFactory = persistenceManager.getRepositoryFactory();
SwitchRepository switchRepository = repositoryFactory.createSwitchRepository();
HashMap<SwitchId, HistoryFacts> switchById = new HashMap<>();
for (Switch switchEntry : switchRepository.findAll()) {
SwitchId switchId = switchEntry.getSwitchId();
SwitchStatus switchStatus = switchEntry.getStatus();
switchById.put(switchId, new HistoryFacts(switchId, switchStatus));
}
IslRepository islRepository = repositoryFactory.createIslRepository();
for (Isl islEntry : islRepository.findAll()) {
HistoryFacts history = switchById.get(islEntry.getSrcSwitchId());
if (history == null) {
log.error("Orphaned ISL relation - {}-{} (read race condition?)", islEntry.getSrcSwitchId(), islEntry.getSrcPort());
continue;
}
islRepository.detach(islEntry);
history.addLink(islEntry);
}
return switchById.values();
}
use of org.openkilda.persistence.repositories.IslRepository in project open-kilda by telstra.
the class FlowRerouteServiceTest method shouldFailRerouteFlowIfMultipleOverprovisionBandwidth.
@Test
public void shouldFailRerouteFlowIfMultipleOverprovisionBandwidth() throws RecoverableException, UnroutableFlowException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
IslRepository repository = setupIslRepositorySpy();
doReturn(-1L).when(repository).updateAvailableBandwidth(any(), anyInt(), any(), anyInt());
FlowRerouteRequest request = new FlowRerouteRequest(origin.getFlowId(), false, false, false, Collections.emptySet(), null, false);
testExpectedFailure(dummyRequestKey, request, commandContext, origin, FlowStatus.UP, ErrorType.INTERNAL_ERROR);
verify(repository, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).updateAvailableBandwidth(any(), anyInt(), any(), anyInt());
}
use of org.openkilda.persistence.repositories.IslRepository in project open-kilda by telstra.
the class FlowUpdateServiceTest method shouldFailUpdateFlowIfMultipleOverprovisionBandwidth.
@Test
public void shouldFailUpdateFlowIfMultipleOverprovisionBandwidth() throws RecoverableException, UnroutableFlowException, DuplicateKeyException {
Flow origin = makeFlow();
preparePathComputation(origin.getFlowId(), make3SwitchesPathPair());
IslRepository repository = setupIslRepositorySpy();
doReturn(-1L).when(repository).updateAvailableBandwidth(any(), anyInt(), any(), anyInt());
FlowRequest request = makeRequest().flowId(origin.getFlowId()).build();
testExpectedFailure(request, origin, ErrorType.INTERNAL_ERROR);
verify(repository, times(PATH_ALLOCATION_RETRIES_LIMIT + 1)).updateAvailableBandwidth(any(), anyInt(), any(), anyInt());
}
use of org.openkilda.persistence.repositories.IslRepository in project open-kilda by telstra.
the class NetworkIslServiceTest method initialMoveEvent.
@Test
@Ignore("become invalid due to change initialisation logic")
public void initialMoveEvent() {
emulateEmptyPersistentDb();
IslReference ref = new IslReference(endpointAlpha1, endpointBeta2);
service.islMove(ref.getSource(), ref);
// System.out.println(mockingDetails(carrier).printInvocations());
verify(carrier, times(2)).triggerReroute(any(RerouteAffectedFlows.class));
// System.out.println(mockingDetails(islRepository).printInvocations());
verify(islRepository).add(argThat(link -> link.getSrcSwitchId().equals(endpointAlpha1.getDatapath()) && link.getSrcPort() == endpointAlpha1.getPortNumber() && link.getDestSwitchId().equals(endpointBeta2.getDatapath()) && link.getDestPort() == endpointBeta2.getPortNumber() && link.getActualStatus() == IslStatus.INACTIVE && link.getStatus() == IslStatus.INACTIVE));
verify(islRepository).add(argThat(link -> link.getSrcSwitchId().equals(endpointBeta2.getDatapath()) && link.getSrcPort() == endpointBeta2.getPortNumber() && link.getDestSwitchId().equals(endpointAlpha1.getDatapath()) && link.getDestPort() == endpointAlpha1.getPortNumber() && link.getActualStatus() == IslStatus.INACTIVE && link.getStatus() == IslStatus.INACTIVE));
verifyNoMoreInteractions(carrier);
}
Aggregations