use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class AvailableNetwork method addEdge.
/**
* Add an edge. It must reference nodes which are already added to the network.
*
* @param edge the edge to add.
* @param errorOnDuplicates how to handle duplicate edges, if true will throw exception on duplicate.
* @throws IllegalArgumentException in case of duplicate or improperly created edge.
*/
public void addEdge(Edge edge, boolean errorOnDuplicates) {
Node srcSwitch = switches.get(edge.getSrcSwitch().getSwitchId());
Node dstSwitch = switches.get(edge.getDestSwitch().getSwitchId());
if (srcSwitch == null || srcSwitch != edge.getSrcSwitch() || dstSwitch == null || dstSwitch != edge.getDestSwitch()) {
throw new IllegalArgumentException("The edge must reference nodes already added to the network.");
}
edges.add(edge);
boolean srcAdded = srcSwitch.getOutgoingLinks().add(edge);
boolean dstAdded = dstSwitch.getIncomingLinks().add(edge);
if (errorOnDuplicates && !(srcAdded && dstAdded)) {
throw new IllegalArgumentException("Duplicate edge has been passed to AvailableNetwork: " + edge);
}
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class AvailableNetworkFactory method addIslAsEdge.
private void addIslAsEdge(IslImmutableView isl, AvailableNetwork network) {
Node srcSwitch = network.getOrAddNode(isl.getSrcSwitchId(), isl.getSrcPop());
Node dstSwitch = network.getOrAddNode(isl.getDestSwitchId(), isl.getDestPop());
Edge edge = Edge.builder().srcSwitch(srcSwitch).srcPort(isl.getSrcPort()).destSwitch(dstSwitch).destPort(isl.getDestPort()).cost(isl.getCost()).latency(isl.getLatency()).underMaintenance(isl.isUnderMaintenance()).unstable(isl.isUnstable()).availableBandwidth(isl.getAvailableBandwidth()).build();
network.addEdge(edge);
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class BestWeightAndShortestPathFinder method findPathWithMinWeight.
@Override
public FindPathResult findPathWithMinWeight(AvailableNetwork network, SwitchId startSwitchId, SwitchId endSwitchId, WeightFunction weightFunction) throws UnroutableFlowException {
Node start = network.getSwitch(startSwitchId);
Node end = network.getSwitch(endSwitchId);
return findPath(network, startSwitchId, endSwitchId, () -> findOneDirectionPath(start, end, weightFunction));
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class BestWeightAndShortestPathFinder method findPathWithMinWeightAndLatencyLimits.
@Override
public FindPathResult findPathWithMinWeightAndLatencyLimits(AvailableNetwork network, SwitchId startSwitchId, SwitchId endSwitchId, WeightFunction weightFunction, long maxLatency, long latencyLimit) throws UnroutableFlowException {
Node start = network.getSwitch(startSwitchId);
Node end = network.getSwitch(endSwitchId);
return findPath(network, startSwitchId, endSwitchId, () -> findOneDirectionPathWithLatencyLimits(start, end, weightFunction, maxLatency, latencyLimit));
}
use of org.openkilda.pce.model.Node in project open-kilda by telstra.
the class BestWeightAndShortestPathFinder method findPathWithWeightCloseToMaxWeight.
@Override
public FindPathResult findPathWithWeightCloseToMaxWeight(AvailableNetwork network, SwitchId startSwitchId, SwitchId endSwitchId, WeightFunction weightFunction, long maxWeight, long backUpMaxWeight) throws UnroutableFlowException {
Node start = network.getSwitch(startSwitchId);
Node end = network.getSwitch(endSwitchId);
return findPath(network, startSwitchId, endSwitchId, () -> findOneDirectionPath(start, end, weightFunction, maxWeight, backUpMaxWeight));
}
Aggregations