Search in sources :

Example 6 with Node

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

Example 7 with Node

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

Example 8 with Node

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

Example 9 with Node

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

Example 10 with Node

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

Aggregations

Node (org.openkilda.pce.model.Node)20 Edge (org.openkilda.pce.model.Edge)15 Test (org.junit.Test)8 SwitchId (org.openkilda.model.SwitchId)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 UnroutableFlowException (org.openkilda.pce.exception.UnroutableFlowException)3 ArrayList (java.util.ArrayList)2 Collections.emptyList (java.util.Collections.emptyList)2 LinkedHashSet (java.util.LinkedHashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 Slf4j (lombok.extern.slf4j.Slf4j)2 Flow (org.openkilda.model.Flow)2 PathSegment (org.openkilda.model.PathSegment)2 FindOneDirectionPathResult (org.openkilda.pce.model.FindOneDirectionPathResult)2 PathWeight (org.openkilda.pce.model.PathWeight)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1