Search in sources :

Example 61 with Isl

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());
}
Also used : Isl(org.openkilda.model.Isl) PathComputer(org.openkilda.pce.PathComputer) Switch(org.openkilda.model.Switch) SwitchId(org.openkilda.model.SwitchId) Flow(org.openkilda.model.Flow) GetPathsResult(org.openkilda.pce.GetPathsResult) Test(org.junit.Test)

Example 62 with Isl

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);
}
Also used : Isl(org.openkilda.model.Isl)

Example 63 with 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);
}
Also used : Isl(org.openkilda.model.Isl) BfdProperties(org.openkilda.model.BfdProperties)

Example 64 with Isl

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());
    }
}
Also used : Isl(org.openkilda.model.Isl) Endpoint(org.openkilda.wfm.share.model.Endpoint) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 65 with Isl

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.");
    }
}
Also used : DeactivateIslInfoData(org.openkilda.messaging.info.event.DeactivateIslInfoData) Isl(org.openkilda.model.Isl) MessageException(org.openkilda.messaging.error.MessageException) Values(org.apache.storm.tuple.Values) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) DeactivateIslInfoData(org.openkilda.messaging.info.event.DeactivateIslInfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) IslMapper(org.openkilda.wfm.share.mappers.IslMapper) IllegalIslStateException(org.openkilda.wfm.error.IllegalIslStateException)

Aggregations

Isl (org.openkilda.model.Isl)83 Test (org.junit.Test)49 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)25 Endpoint (org.openkilda.wfm.share.model.Endpoint)18 Switch (org.openkilda.model.Switch)17 IslReference (org.openkilda.wfm.share.model.IslReference)11 SwitchId (org.openkilda.model.SwitchId)10 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)9 IslDataHolder (org.openkilda.wfm.topology.network.model.IslDataHolder)8 ArrayList (java.util.ArrayList)6 PathId (org.openkilda.model.PathId)6 Flow (org.openkilda.model.Flow)5 IslRepository (org.openkilda.persistence.repositories.IslRepository)5 Collection (java.util.Collection)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4 FlowPath (org.openkilda.model.FlowPath)4 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)4 IslFrame (org.openkilda.persistence.ferma.frames.IslFrame)4