use of org.openkilda.model.SwitchId 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.SwitchId in project open-kilda by telstra.
the class FermaMirrorGroupRepository method exists.
@Override
public boolean exists(SwitchId switchId, GroupId groupId) {
String switchIdAsStr = SwitchIdConverter.INSTANCE.toGraphProperty(switchId);
Long groupIdAsLong = GroupIdConverter.INSTANCE.toGraphProperty(groupId);
try (GraphTraversal<?, ?> traversal = framedGraph().traverse(g -> g.V().hasLabel(FlowMeterFrame.FRAME_LABEL).has(MirrorGroupFrame.GROUP_ID_PROPERTY, groupIdAsLong).has(MirrorGroupFrame.SWITCH_ID_PROPERTY, switchIdAsStr)).getRawTraversal()) {
return traversal.hasNext();
} catch (Exception e) {
throw new PersistenceException("Failed to traverse", e);
}
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class FlowFrame method getSrcSwitch.
@Override
public Switch getSrcSwitch() {
if (srcSwitch == null) {
List<? extends SwitchFrame> switchFrames = traverse(v -> v.out(SOURCE_EDGE).hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
if (!switchFrames.isEmpty()) {
srcSwitch = new Switch((switchFrames.get(0)));
if (!Objects.equals(getSrcSwitchId(), srcSwitch.getSwitchId())) {
throw new IllegalStateException(format("The flow %s has inconsistent source switch %s / %s", getId(), getSrcSwitchId(), srcSwitch.getSwitchId()));
}
} else {
String switchId = getProperty(SRC_SWITCH_ID_PROPERTY);
log.warn("Fallback to find the source switch by a reference instead of an edge. " + "The switch {}, the vertex {}", switchId, this);
srcSwitch = SwitchFrame.load(getGraph(), switchId).map(Switch::new).orElse(null);
}
}
return srcSwitch;
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class IslFrame method getDestSwitch.
@Override
public Switch getDestSwitch() {
if (destSwitch == null) {
List<? extends SwitchFrame> switchFrames = traverse(e -> e.inV().hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
destSwitch = !switchFrames.isEmpty() ? new Switch((switchFrames.get(0))) : null;
SwitchId switchId = destSwitch != null ? destSwitch.getSwitchId() : null;
if (!Objects.equals(getDestSwitchId(), switchId)) {
throw new IllegalStateException(format("The isl %s has inconsistent dest switch %s / %s", getId(), getDestSwitchId(), switchId));
}
}
return destSwitch;
}
use of org.openkilda.model.SwitchId in project open-kilda by telstra.
the class IslFrame method getSrcSwitch.
@Override
public Switch getSrcSwitch() {
if (srcSwitch == null) {
List<? extends SwitchFrame> switchFrames = traverse(e -> e.outV().hasLabel(SwitchFrame.FRAME_LABEL)).toListExplicit(SwitchFrame.class);
srcSwitch = !switchFrames.isEmpty() ? new Switch((switchFrames.get(0))) : null;
SwitchId switchId = srcSwitch != null ? srcSwitch.getSwitchId() : null;
if (!Objects.equals(getSrcSwitchId(), switchId)) {
throw new IllegalStateException(format("The isl %s has inconsistent source switch %s / %s", getId(), getSrcSwitchId(), switchId));
}
}
return srcSwitch;
}
Aggregations