Search in sources :

Example 26 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class InMemoryPathComputerBaseTest method connectDiamonds.

private void connectDiamonds(SwitchId switchA, SwitchId switchB, IslStatus status, int cost, int port) {
    // A - B - D
    // + C +
    Switch nodeA = switchRepository.findById(switchA).get();
    Switch nodeB = switchRepository.findById(switchB).get();
    createIsl(nodeA, nodeB, status, status, cost, 1000, port);
    createIsl(nodeB, nodeA, status, status, cost, 1000, port);
}
Also used : Switch(org.openkilda.model.Switch)

Example 27 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class MaxLatencyPathComputationStrategyBaseTest method createTwoLinksInsidePathTopo.

private void createTwoLinksInsidePathTopo() {
    // A - B - C - D - E - F
    // \ /
    String switchStart = "00:";
    int index = 1;
    Switch nodeA = createSwitch(switchStart + format("%02X", index++));
    Switch nodeB = createSwitch(switchStart + format("%02X", index++));
    Switch nodeC = createSwitch(switchStart + format("%02X", index++));
    Switch nodeD = createSwitch(switchStart + format("%02X", index++));
    Switch nodeE = createSwitch(switchStart + format("%02X", index++));
    Switch nodeF = createSwitch(switchStart + format("%02X", index));
    createBiIsl(nodeA, nodeB, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 1, 1L);
    createBiIsl(nodeB, nodeC, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 2, 1L);
    createBiIsl(nodeC, nodeD, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 3, 1L);
    createBiIsl(nodeD, nodeE, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 4, 1L);
    createBiIsl(nodeE, nodeF, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 5, 1L);
    createBiIsl(nodeC, nodeD, IslStatus.ACTIVE, IslStatus.ACTIVE, 10, 1000, 6, 10L);
}
Also used : Switch(org.openkilda.model.Switch)

Example 28 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class LatencyPathComputationStrategyBaseTest method shouldFindPathOverTriangleByLatency.

@Test
public void shouldFindPathOverTriangleByLatency() throws UnroutableFlowException, RecoverableException {
    /*
         * should choose longer (in hops) but low latency path
         */
    createTriangleTopo(IslStatus.ACTIVE, 10, 10, "00:", 1);
    Switch srcSwitch = getSwitchById("00:01");
    Switch destSwitch = getSwitchById("00:02");
    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));
    // it should now have C as first hop since A - B segment has high latency
    assertEquals(new SwitchId("00:03"), path.getForward().getSegments().get(0).getDestSwitchId());
}
Also used : 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 29 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class PersistenceDummyEntityFactory method makeSwitch.

/**
 * Create {@link Switch} object.
 */
public Switch makeSwitch(SwitchId switchId) {
    Switch sw = switchDefaults.fill(Switch.builder()).switchId(switchId).ofVersion("OF_13").features(new HashSet<SwitchFeature>() {

        {
            add(SwitchFeature.METERS);
            add(SwitchFeature.GROUPS);
        }
    }).ofDescriptionManufacturer("manufacturer").ofDescriptionSoftware("software").build();
    switchRepository.add(sw);
    switchPropertiesRepository.add(switchPropertiesDefaults.fill(SwitchProperties.builder()).switchObj(sw).build());
    return sw;
}
Also used : Switch(org.openkilda.model.Switch) HashSet(java.util.HashSet)

Example 30 with Switch

use of org.openkilda.model.Switch in project open-kilda by telstra.

the class FermaSwitchConnectRepository method doAdd.

@Override
protected SwitchConnectFrame doAdd(SwitchConnectData data) {
    Switch owner = data.getOwner();
    if (owner == null || owner.getSwitchId() == null) {
        throw new IllegalArgumentException("Owner or owner switchId field is null");
    }
    SwitchFrame ownerFrame = SwitchFrame.load(framedGraph(), SwitchIdConverter.INSTANCE.toGraphProperty(owner.getSwitchId())).orElseThrow(() -> new IllegalArgumentException(String.format("Unable to locate the switch %s", owner.getSwitchId())));
    Speaker speaker = data.getSpeaker();
    if (speaker == null || speaker.getName() == null) {
        throw new IllegalArgumentException("Speaker or speaker name is null");
    }
    SpeakerFrame speakerFrame = SpeakerFrame.load(framedGraph(), speaker.getName()).orElseThrow(() -> new IllegalArgumentException("Unable to locate speaker " + speaker.getName()));
    SwitchConnectFrame frame = KildaBaseEdgeFrame.addNewFramedEdge(framedGraph(), ownerFrame, speakerFrame, SwitchConnectFrame.FRAME_LABEL, SwitchConnectFrame.class);
    SwitchConnectCloner.INSTANCE.copyWithoutRelations(data, frame);
    return frame;
}
Also used : Switch(org.openkilda.model.Switch) SwitchConnectFrame(org.openkilda.persistence.ferma.frames.SwitchConnectFrame) SpeakerFrame(org.openkilda.persistence.ferma.frames.SpeakerFrame) SwitchFrame(org.openkilda.persistence.ferma.frames.SwitchFrame) Speaker(org.openkilda.model.Speaker)

Aggregations

Switch (org.openkilda.model.Switch)230 Test (org.junit.Test)126 Flow (org.openkilda.model.Flow)68 SwitchId (org.openkilda.model.SwitchId)67 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)46 FlowPath (org.openkilda.model.FlowPath)34 PathId (org.openkilda.model.PathId)32 Utils.buildSwitch (org.openkilda.rulemanager.Utils.buildSwitch)32 PathComputer (org.openkilda.pce.PathComputer)28 GetPathsResult (org.openkilda.pce.GetPathsResult)23 List (java.util.List)22 SwitchProperties (org.openkilda.model.SwitchProperties)21 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)20 SpeakerData (org.openkilda.rulemanager.SpeakerData)19 String.format (java.lang.String.format)17 Set (java.util.Set)17 Isl (org.openkilda.model.Isl)15 HashSet (java.util.HashSet)14 ArrayList (java.util.ArrayList)13 Collections (java.util.Collections)13