Search in sources :

Example 66 with Isl

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

Example 67 with 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);
    });
}
Also used : Isl(org.openkilda.model.Isl) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 68 with Isl

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

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

Example 70 with Isl

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

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