use of org.openkilda.model.Isl in project open-kilda by telstra.
the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverDiamondWithUnstableIslByLatency.
@Test
public void shouldFindPathOverDiamondWithUnstableIslByLatency() throws UnroutableFlowException, RecoverableException {
createDiamond(IslStatus.ACTIVE, IslStatus.ACTIVE, 100L, 1000L);
Switch srcSwitch = getSwitchById("00:01");
Switch destSwitch = getSwitchById("00:04");
Isl linkAB = islRepository.findBySrcSwitch(srcSwitch.getSwitchId()).stream().filter(isl -> isl.getDestSwitchId().equals(new SwitchId("00:02"))).findAny().orElseThrow(() -> new IllegalStateException("Link A-B not found"));
linkAB.setTimeUnstable(Instant.now());
Flow flow = new TestFlowBuilder().srcSwitch(srcSwitch).destSwitch(destSwitch).bandwidth(100).pathComputationStrategy(PathComputationStrategy.LATENCY).build();
PathComputer pathComputer = pathComputerFactory.getPathComputer();
GetPathsResult path = pathComputer.getPath(flow);
assertNotNull(path);
assertThat(path.getForward().getSegments(), Matchers.hasSize(2));
// should now have C as first hop since A - B link is unstable
assertEquals(new SwitchId("00:03"), path.getForward().getSegments().get(0).getDestSwitchId());
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class LinkOperationsServiceTest method createIsl.
private void createIsl(IslStatus status) {
Isl isl = Isl.builder().srcSwitch(createSwitchIfNotExist(TEST_SWITCH_A_ID)).srcPort(TEST_SWITCH_A_PORT).destSwitch(createSwitchIfNotExist(TEST_SWITCH_B_ID)).destPort(TEST_SWITCH_B_PORT).cost(0).build();
isl.setStatus(status);
islRepository.add(isl);
isl = Isl.builder().srcSwitch(createSwitchIfNotExist(TEST_SWITCH_B_ID)).srcPort(TEST_SWITCH_B_PORT).destSwitch(createSwitchIfNotExist(TEST_SWITCH_A_ID)).destPort(TEST_SWITCH_A_PORT).cost(0).build();
isl.setStatus(status);
islRepository.add(isl);
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class LinkOperationsServiceTest method verifyBfdProperties.
private void verifyBfdProperties(Endpoint leftEnd, Endpoint rightEnd, BfdProperties expectedValue) {
Optional<Isl> potentialIsl = islRepository.findByEndpoints(leftEnd.getDatapath(), leftEnd.getPortNumber(), rightEnd.getDatapath(), rightEnd.getPortNumber());
Assert.assertTrue(potentialIsl.isPresent());
BfdProperties actualValue = IslMapper.INSTANCE.readBfdProperties(potentialIsl.get());
Assert.assertEquals(expectedValue, actualValue);
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class LinkOperationsServiceTest method shouldUpdateLinkUnderMaintenanceFlag.
@Test
public void shouldUpdateLinkUnderMaintenanceFlag() throws IslNotFoundException {
createIsl(IslStatus.ACTIVE);
for (int i = 0; i < 2; i++) {
List<Isl> link = linkOperationsService.updateLinkUnderMaintenanceFlag(TEST_SWITCH_A_ID, TEST_SWITCH_A_PORT, TEST_SWITCH_B_ID, TEST_SWITCH_B_PORT, true);
assertEquals(2, link.size());
assertTrue(link.get(0).isUnderMaintenance());
assertTrue(link.get(1).isUnderMaintenance());
}
for (int i = 0; i < 2; i++) {
List<Isl> link = linkOperationsService.updateLinkUnderMaintenanceFlag(TEST_SWITCH_A_ID, TEST_SWITCH_A_PORT, TEST_SWITCH_B_ID, TEST_SWITCH_B_PORT, false);
assertEquals(2, link.size());
assertFalse(link.get(0).isUnderMaintenance());
assertFalse(link.get(1).isUnderMaintenance());
}
}
use of org.openkilda.model.Isl in project open-kilda by telstra.
the class LinkOperationsBolt method deleteLink.
private List<IslInfoData> deleteLink(DeleteLinkRequest request) {
try {
Collection<Isl> operationsResult = linkOperationsService.deleteIsl(request.getSrcSwitch(), request.getSrcPort(), request.getDstSwitch(), request.getDstPort(), request.isForce());
List<IslInfoData> responseResult = operationsResult.stream().map(IslMapper.INSTANCE::map).collect(Collectors.toList());
for (IslInfoData isl : responseResult) {
DeactivateIslInfoData data = new DeactivateIslInfoData(isl.getSource(), isl.getDestination());
getOutput().emit(StreamType.DISCO.toString(), getCurrentTuple(), new Values(data, getCorrelationId()));
}
return responseResult;
} catch (IslNotFoundException e) {
throw new MessageException(ErrorType.NOT_FOUND, e.getMessage(), "ISL was not found.");
} catch (IllegalIslStateException e) {
throw new MessageException(ErrorType.REQUEST_INVALID, e.getMessage(), "ISL is in illegal state.");
}
}
Aggregations