use of org.openkilda.model.Isl in project open-kilda by telstra.
the class FlowCacheServiceTest method createIsl.
private void createIsl(Switch srcSwitch, int srcPort, Switch dstSwitch, int dstPort) {
Isl isl = Isl.builder().srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(dstSwitch).destPort(dstPort).status(ACTIVE).latency(100).build();
islRepository.add(isl);
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class IslLatencyService method updateIslLatency.
/**
* Update latency of isl by source and destination endpoint.
*
* @param srcSwitchId ID of source switch.
* @param srcPort source port.
* @param dstSwitchId ID of destination switch.
* @param dstPort destination port.
* @param latency latency to update
*
* @throws SwitchNotFoundException if src or dst switch is not found
* @throws IslNotFoundException if isl is not found
*/
@VisibleForTesting
void updateIslLatency(SwitchId srcSwitchId, int srcPort, SwitchId dstSwitchId, int dstPort, long latency) throws SwitchNotFoundException, IslNotFoundException {
transactionManager.doInTransaction(() -> {
Isl isl = islRepository.findByEndpoints(srcSwitchId, srcPort, dstSwitchId, dstPort).orElseThrow(() -> new IslNotFoundException(srcSwitchId, srcPort, dstSwitchId, dstPort));
isl.setLatency(latency);
});
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class IslLatencyServiceTest method createIsl.
private void createIsl(Switch srcSwitch, int srcPort, Switch dstSwitch, int dstPort, int latency) {
Isl isl = Isl.builder().srcSwitch(srcSwitch).srcPort(srcPort).destSwitch(dstSwitch).destPort(dstPort).actualStatus(IslStatus.ACTIVE).latency(latency).build();
islRepository.add(isl);
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class FermaIslRepositoryTest method shouldDeleteIsl.
@Test
public void shouldDeleteIsl() {
Isl isl = createIsl(switchA, switchB);
transactionManager.doInTransaction(() -> islRepository.remove(isl));
assertThat(islRepository.findAll(), Matchers.empty());
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class FermaIslRepositoryTest method shouldNotUpdateAvailableBandwidthIfEndpointDoesntMatch.
@Test
public void shouldNotUpdateAvailableBandwidthIfEndpointDoesntMatch() {
Isl isl = createIsl(switchA, 1, switchB, 2, IslStatus.ACTIVE, 100L);
isl.setMaxBandwidth(100L);
try {
createPathWithSegment(TEST_FLOW_ID + "_1", switchA, 1, switchB, 3, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 3);
fail();
} catch (PersistenceException ex) {
// expected
}
Isl islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
try {
createPathWithSegment(TEST_FLOW_ID + "_2", switchA, 2, switchB, 2, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 2, TEST_SWITCH_B_ID, 2);
fail();
} catch (PersistenceException ex) {
// expected
}
islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
try {
createPathWithSegment(TEST_FLOW_ID + "_3", switchC, 1, switchB, 2, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_C_ID, 1, TEST_SWITCH_B_ID, 2);
fail();
} catch (PersistenceException ex) {
// expected
}
islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
try {
createPathWithSegment(TEST_FLOW_ID + "_4", switchA, 1, switchC, 2, 33L);
islRepository.updateAvailableBandwidth(TEST_SWITCH_A_ID, 1, TEST_SWITCH_C_ID, 2);
fail();
} catch (PersistenceException ex) {
// expected
}
islAfter = islRepository.findByEndpoints(TEST_SWITCH_A_ID, 1, TEST_SWITCH_B_ID, 2).get();
assertEquals(100, islAfter.getAvailableBandwidth());
}
Aggregations