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);
}
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);
}
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());
}
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;
}
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;
}
Aggregations