enum SETTING_UP_METER_ERROR;
enum UNDEFINED_ERROR;
enum REMOVING_ROUTE_ERROR;
- enum REMOVING_METTER_ERROR;
+ enum REMOVING_METER_ERROR;
enum MISSING_ROUTE_ERROR;
enum UPDATING_RATE_LIMITING_ERROR;
enum INVALID_INPUT;
rpc setup-route {
description "Given the endpoints, this service computes a route
- satisfying the constraints; among those satisfying the constraints,
+ satisfying the constraints; among those satisfying the constraints,
it computes the one with the best object metrics. If a route is
found, the service will setup the route by installing flow rules
in FRM. This service does not handle the complexity of re-route.";
--- /dev/null
+/*
+ * Copyright (c) 2015 SNLAB and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.alto.spce.impl.algorithm;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.spce.rev160718.AltoSpceMetric;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.spce.rev160718.setup.route.input.ConstraintMetric;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class MaxBandwidthPathRouteChecker extends RouteChecker {
+ private List<RouteViewerPath> result;
+ private long bandwidth = 0;
+ private List<ConstraintMetric> constraintMetrics = null;
+ private RouteViewerPath finalPath = null;
+
+ MaxBandwidthPathRouteChecker(RouteViewerPath finalPath, List<ConstraintMetric> constraintMetrics){
+ this.finalPath = finalPath;
+ this.constraintMetrics = constraintMetrics;
+ this.bandwidth = 0;
+ }
+
+ @Override
+ public boolean isStop(List<RouteViewerPath> pathList) {
+ LinkedList<RouteViewerPath> tmp = new LinkedList<>(pathList);
+ tmp.add(finalPath);
+ long hopcount = tmp.size();
+ long bandwidth = getBandwidth(pathList);
+ List<ConstraintMetric> constraintMetrics = this.constraintMetrics;
+ if (constraintMetrics != null) {
+ for (ConstraintMetric eachConstraint : constraintMetrics) {
+ if (eachConstraint.getMetric() == null) continue;
+ long max = (eachConstraint.getMax() != null) ?
+ eachConstraint.getMax().longValue() : Long.MAX_VALUE;
+ long min = (eachConstraint.getMin() != null) ?
+ eachConstraint.getMin().longValue() : 0;
+ long value = 0;
+ if (eachConstraint.getMetric().equals(AltoSpceMetric.Bandwidth)) {
+ value = bandwidth;
+ } else {
+ value = hopcount;
+ }
+ if (value < min || value > max) {
+ return false;
+ }
+ }
+ }
+
+ if (bandwidth > this.bandwidth) {
+ this.bandwidth = bandwidth;
+ result = tmp;
+ }
+ return false;
+ }
+
+ @Override
+ public List<RouteViewerPath> getResult() {
+ return result;
+ }
+}
public List<TpId> shortestPath(TpId srcTpId, TpId dstTpId, Topology topology,
final List<ConstraintMetric> constraintMetrics) {
- final RouteViewer.Path finalPath = new RouteViewer.Path();
+ final RouteViewerPath finalPath = new RouteViewerPath();
finalPath.src = dstTpId;
finalPath.bandwidth = getBandwidthByTp(dstTpId.getValue()).longValue();
- RouteViewer.RouteChecker checker = new RouteViewer.RouteChecker() {
- private List<RouteViewer.Path> result;
- private long hopcount = Long.MAX_VALUE;
- @Override
- public boolean isStop(List<RouteViewer.Path> pathList) {
- LinkedList<RouteViewer.Path> tmp = new LinkedList<>(pathList);
- tmp.add(finalPath);
- long hopcount = tmp.size();
- long bandwidth = getBandwidth(tmp);
- if (constraintMetrics != null) {
- for (ConstraintMetric eachConstraint : constraintMetrics) {
- if (eachConstraint.getMetric() == null) {
- continue;
- }
- long max = (eachConstraint.getMax() != null) ?
- eachConstraint.getMax().longValue() : Long.MAX_VALUE;
- long min = (eachConstraint.getMin() != null) ?
- eachConstraint.getMin().longValue() : 0;
- long value = 0;
- if (eachConstraint.getMetric().equals(AltoSpceMetric.Bandwidth)) {
- value = bandwidth;
- } else {
- value = hopcount;
- }
- if (value < min || value > max) {
- return false;
- }
- }
- }
- if (hopcount < this.hopcount) {
- this.hopcount = hopcount;
- result = tmp;
- }
- return false;
- }
-
- @Override
- public List<RouteViewer.Path> getResult() {
- return result;
- }
- };
-
+ RouteChecker checker = new ShortestPathRouteChecker(finalPath, constraintMetrics);
RouteViewer rv = new RouteViewer(getGraphFromTopology(topology, (long) 0), checker);
- List<RouteViewer.Path> result = rv.viewRoutes(
+ List<RouteViewerPath> result = rv.viewRoutes(
RouteViewer.extractNodeId(srcTpId),
RouteViewer.extractNodeId(dstTpId))
.getResult();
logger.info(result.toString());
List<TpId> output = new LinkedList<>();
- for (RouteViewer.Path eachPath : result) {
+ for (RouteViewerPath eachPath : result) {
output.add(eachPath.src);
}
return output;
public List<TpId> maxBandwidthPath(TpId srcTpId, TpId dstTpId, Topology topology,
final List<ConstraintMetric> constraintMetrics) {
- final RouteViewer.Path finalPath = new RouteViewer.Path();
+ final RouteViewerPath finalPath = new RouteViewerPath();
finalPath.src = dstTpId;
finalPath.bandwidth = getBandwidthByTp(dstTpId.getValue()).longValue();
- RouteViewer.RouteChecker checker = new RouteViewer.RouteChecker() {
- private List<RouteViewer.Path> result;
- private long bandwidth = 0;
- @Override
- public boolean isStop(List<RouteViewer.Path> pathList) {
- LinkedList<RouteViewer.Path> tmp = new LinkedList<>(pathList);
- tmp.add(finalPath);
- long hopcount = tmp.size();
- long bandwidth = getBandwidth(tmp);
- if (constraintMetrics != null) {
- for (ConstraintMetric eachConstraint : constraintMetrics) {
- if (eachConstraint.getMetric() == null) {
- continue;
- }
- long max = (eachConstraint.getMax() != null) ?
- eachConstraint.getMax().longValue() : Long.MAX_VALUE;
- long min = (eachConstraint.getMin() != null) ?
- eachConstraint.getMin().longValue() : 0;
- long value = 0;
- if (eachConstraint.getMetric().equals(AltoSpceMetric.Bandwidth)) {
- value = bandwidth;
- } else {
- value = hopcount;
- }
- if (value < min || value > max) {
- return false;
- }
- }
- }
- if (bandwidth > this.bandwidth) {
- this.bandwidth = bandwidth;
- result = tmp;
- }
- return false;
- }
-
- @Override
- public List<RouteViewer.Path> getResult() {
- return result;
- }
- };
-
+ RouteChecker checker = new MaxBandwidthPathRouteChecker(finalPath, constraintMetrics);
RouteViewer rv = new RouteViewer(getGraphFromTopology(topology, (long) 0), checker);
- List<RouteViewer.Path> result = rv.viewRoutes(
+ List<RouteViewerPath> result = rv.viewRoutes(
RouteViewer.extractNodeId(srcTpId),
RouteViewer.extractNodeId(dstTpId))
.getResult();
List<TpId> output = new LinkedList<>();
- for (RouteViewer.Path eachPath : result) {
+ for (RouteViewerPath eachPath : result) {
output.add(eachPath.src);
}
return output;
}
- long getBandwidth(List<RouteViewer.Path> pathList) {
- Long result = Long.MAX_VALUE;
- for (RouteViewer.Path eachPath : pathList) {
- result = (result < eachPath.bandwidth) ? result : eachPath.bandwidth;
- }
- return result;
- }
-
public List<TpId> shortestPathOpti(TpId srcTpId, TpId dstTpId, Topology topology, List<ConstraintMetric> constraintMetrics) {
String src = srcTpId.getValue();
String dst = dstTpId.getValue();
minBw : eachConstraint.getMin().longValue();
}
}
- Graph<String, RouteViewer.Path> networkGraph = getGraphFromTopology(topology, minBw);
- DijkstraShortestPath<String, RouteViewer.Path> shortestPath = new DijkstraShortestPath<>(networkGraph);
- List<RouteViewer.Path> path = shortestPath.getPath(extractNodeId(src), extractNodeId(dst));
+ Graph<String, RouteViewerPath> networkGraph = getGraphFromTopology(topology, minBw);
+ DijkstraShortestPath<String, RouteViewerPath> shortestPath = new DijkstraShortestPath<>(networkGraph);
+ List<RouteViewerPath> path = shortestPath.getPath(extractNodeId(src), extractNodeId(dst));
List<TpId> output = new LinkedList<>();
- for (RouteViewer.Path eachPath : path) {
+ for (RouteViewerPath eachPath : path) {
output.add(eachPath.src);
}
return output;
public List<TpId> maxBandwidthPathOpti(TpId srcTpId, TpId dstTpId, Topology topology, List<ConstraintMetric> constraintMetrics) {
String src = srcTpId.getValue();
String dst = dstTpId.getValue();
- Graph<String, RouteViewer.Path> networkGraph = getGraphFromTopology(topology, null);
+ Graph<String, RouteViewerPath> networkGraph = getGraphFromTopology(topology, null);
Long maxHop = Long.MAX_VALUE;
for (ConstraintMetric eachConstraint : constraintMetrics) {
if (AltoSpceMetric.Hopcount == eachConstraint.getMetric() && eachConstraint.getMax() != null) {
maxHop : eachConstraint.getMax().longValue();
}
}
- List<RouteViewer.Path> path = maxBandwidth(networkGraph, extractNodeId(src), extractNodeId(dst), maxHop);
+ List<RouteViewerPath> path = maxBandwidth(networkGraph, extractNodeId(src), extractNodeId(dst), maxHop);
List<TpId> output = new LinkedList<>();
- for (RouteViewer.Path eachPath : path) {
+ for (RouteViewerPath eachPath : path) {
output.add(eachPath.src);
}
return output;
** return this route;
** (3) else: continue the adding.
**/
- public List<RouteViewer.Path> maxBandwidth(Graph<String, RouteViewer.Path> networkGraph, String src, String dst, Long maxHop) {
+ public List<RouteViewerPath> maxBandwidth(Graph<String, RouteViewerPath> networkGraph, String src, String dst, Long maxHop) {
Map<String, Long> hopCount = new HashMap<>();
- Map<String, RouteViewer.Path> pre = new HashMap<>();
+ Map<String, RouteViewerPath> pre = new HashMap<>();
hopCount.put(src, (long) 0);
- List<RouteViewer.Path> paths = new ArrayList<>(networkGraph.getEdges());
- Collections.sort(paths, new Comparator<RouteViewer.Path>() {
+ List<RouteViewerPath> paths = new ArrayList<>(networkGraph.getEdges());
+ Collections.sort(paths, new Comparator<RouteViewerPath>() {
@Override
- public int compare(RouteViewer.Path x, RouteViewer.Path y) {
+ public int compare(RouteViewerPath x, RouteViewerPath y) {
return (Objects.equals(x.bandwidth, y.bandwidth) ? 0 : (x.bandwidth > y.bandwidth ? -1 : 1));
}
});
- Graph<String, RouteViewer.Path> graph = new SparseMultigraph<>();
+ Graph<String, RouteViewerPath> graph = new SparseMultigraph<>();
// add every node into the graph
for (String eachNode : networkGraph.getVertices())
graph.addVertex(eachNode);
- for (RouteViewer.Path eachPath : paths) {
+ for (RouteViewerPath eachPath : paths) {
String srcNode = extractNodeId(eachPath.src.getValue());
String dstNode = extractNodeId(eachPath.dst.getValue());
graph.addEdge(eachPath, srcNode, dstNode, EdgeType.DIRECTED);
while (!queue.isEmpty()) {
srcNode = queue.pop();
if (graph.getOutEdges(srcNode) != null) {
- for (RouteViewer.Path outPath : graph.getOutEdges(srcNode)) {
+ for (RouteViewerPath outPath : graph.getOutEdges(srcNode)) {
dstNode = extractNodeId(outPath.dst.getValue());
if (!hopCount.containsKey(dstNode) ||
(hopCount.get(dstNode) > hopCount.get(srcNode) + 1)) {
}
if (hopCount.containsKey(dst) && hopCount.get(dst) <= maxHop) {
// finally, build the route
- List<RouteViewer.Path> output = new LinkedList<>();
+ List<RouteViewerPath> output = new LinkedList<>();
output.add(0, pre.get(dst));
while (!extractNodeId(output.get(0).src.getValue()).equals(src)) {
dst = extractNodeId(output.get(0).src.getValue());
return null;
}
- private Graph<String, RouteViewer.Path> getGraphFromTopology(Topology topology, Long minBw) {
- Graph<String, RouteViewer.Path> networkGraph = new SparseMultigraph();
+ private Graph<String, RouteViewerPath> getGraphFromTopology(Topology topology, Long minBw) {
+ Graph<String, RouteViewerPath> networkGraph = new SparseMultigraph();
if (minBw == null) {
minBw = (long) 0;
}
}
TpId linkSrcTp = eachLink.getSource().getSourceTp();
TpId linkDstTp = eachLink.getDestination().getDestTp();
- RouteViewer.Path srcPath = new RouteViewer.Path();
+ RouteViewerPath srcPath = new RouteViewerPath();
srcPath.src = linkSrcTp;
srcPath.dst = linkDstTp;
srcPath.bandwidth = getBandwidthByTp(srcPath.src.getValue()).longValue();
--- /dev/null
+/*
+ * Copyright (c) 2015 SNLAB and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.alto.spce.impl.algorithm;
+
+import java.util.List;
+
+public abstract class RouteChecker {
+ abstract boolean isStop(List<RouteViewerPath> pathList);
+ abstract List<RouteViewerPath> getResult();
+
+ protected long getBandwidth(List<RouteViewerPath> pathList) {
+ Long result = Long.MAX_VALUE;
+ for (RouteViewerPath eachPath : pathList) {
+ result = (result < eachPath.bandwidth) ? result : eachPath.bandwidth;
+ }
+ return result;
+ }
+}
import java.util.HashMap;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.Objects;
public class RouteViewer {
- static public interface RouteChecker {
- boolean isStop(List<Path> pathList);
- List<Path> getResult();
- }
-
- static public class Path {
- TpId src;
- TpId dst;
- Long bandwidth;
-
- @Override
- public String toString() {
- return "" + src + "->" + dst + "@" + bandwidth;
- }
- }
-
private RouteChecker routeChecker;
private Map<String, Boolean> hasVisited;
- private Graph<String, Path> networkGraph;
- private LinkedList<Path> route;
+ private Graph<String, RouteViewerPath> networkGraph;
+ private LinkedList<RouteViewerPath> route;
- RouteViewer(Graph<String, Path> networkGraph, RouteChecker routeChecker) {
+ RouteViewer(Graph<String, RouteViewerPath> networkGraph, RouteChecker routeChecker) {
this.networkGraph = networkGraph;
this.routeChecker = routeChecker;
}
}
else {
hasVisited.put(srcNode, true);
- for (Path eachPath : this.networkGraph.getOutEdges(srcNode)) {
+ for (RouteViewerPath eachPath : this.networkGraph.getOutEdges(srcNode)) {
route.addLast(eachPath);
if (visitor(extractNodeId(eachPath.dst), dstNode))
return true;
--- /dev/null
+/*
+ * Copyright (c) 2015 SNLAB and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.alto.spce.impl.algorithm;
+
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TpId;
+
+public class RouteViewerPath {
+ TpId src;
+ TpId dst;
+ Long bandwidth;
+
+ @Override
+ public String toString() {
+ return "" + src + "->" + dst + "@" + bandwidth;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 SNLAB and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.alto.spce.impl.algorithm;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.spce.rev160718.AltoSpceMetric;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.alto.spce.rev160718.setup.route.input.ConstraintMetric;
+
+import java.util.LinkedList;
+import java.util.List;
+
+public class ShortestPathRouteChecker extends RouteChecker {
+ private List<RouteViewerPath> result;
+ private long hopcount = Long.MAX_VALUE;
+ private List<ConstraintMetric> constraintMetrics = null;
+ private RouteViewerPath finalPath = null;
+
+ ShortestPathRouteChecker(RouteViewerPath finalPath, List<ConstraintMetric> constraintMetrics){
+ this.finalPath = finalPath;
+ this.constraintMetrics = constraintMetrics;
+ }
+
+ @Override
+ public boolean isStop(List<RouteViewerPath> pathList) {
+ LinkedList<RouteViewerPath> tmp = new LinkedList<>(pathList);
+ tmp.add(finalPath);
+ long hopcount = tmp.size();
+ long bandwidth = getBandwidth(pathList);
+ List<ConstraintMetric> constraintMetrics = this.constraintMetrics;
+ if (constraintMetrics != null) {
+ for (ConstraintMetric eachConstraint : constraintMetrics) {
+ if (eachConstraint.getMetric() == null) continue;
+ long max = (eachConstraint.getMax() != null) ?
+ eachConstraint.getMax().longValue() : Long.MAX_VALUE;
+ long min = (eachConstraint.getMin() != null) ?
+ eachConstraint.getMin().longValue() : 0;
+ long value = 0;
+ if (eachConstraint.getMetric().equals(AltoSpceMetric.Bandwidth)) {
+ value = bandwidth;
+ } else {
+ value = hopcount;
+ }
+ if (value < min || value > max) {
+ return false;
+ }
+ }
+ }
+ if (hopcount < this.hopcount) {
+ this.hopcount = hopcount;
+ result = tmp;
+ }
+ return false;
+ }
+
+ @Override
+ public List<RouteViewerPath> getResult() {
+ return result;
+ }
+}
LOG.info("Remove a flow from the switch" + InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
this.flowManager.removeFlow(srcMac, dstMac, new NodeConnectorRef(ncid));
}
- if (routeInfoValue.getLimitedRate() > 0 && routeInfoValue.getBurstSize() > 0) {
- try {
- this.meterManager.removeMeterFromSwitch(endpoints, ncr, routeInfoValue.getLimitedRate(), routeInfoValue.getBurstSize());
- } catch (Exception e) {
- LOG.info("Exception occurs when remove the meter from " +
- InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
- return ErrorCodeType.REMOVINGMETTERERROR;
- }
- }
+ if (! removeMeter(endpoints, routeInfoValue, ncr)) return ErrorCodeType.REMOVINGMETERERROR;
}
} catch (Exception e) {
LOG.info("Exception occurs when setup a route: " + e.getMessage());
return ErrorCodeType.OK;
}
+ private boolean removeMeter(Endpoints endpoints, RouteInfoValue routeInfoValue, NodeConnectorRef ncr) {
+ if (routeInfoValue.getLimitedRate() > 0 && routeInfoValue.getBurstSize() > 0) {
+ try {
+ this.meterManager.removeMeterFromSwitch(endpoints, ncr, routeInfoValue.getLimitedRate(), routeInfoValue.getBurstSize());
+ } catch (Exception e) {
+ LOG.info("Exception occurs when remove the meter from " +
+ InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
+ return false;
+ }
+ }
+ return true;
+ }
+
public ErrorCodeType removeRateLimiting(Endpoints endpoints) {
RouteInfoKey routeInfoKey = new RouteInfoKey(endpoints.getSrc().getValue(), endpoints.getDst().getValue());
RouteInfoValue routeInfoValue = this.routeInfo.get(routeInfoKey);
} catch (Exception e) {
LOG.info("Exception occurs when remove the meter from " +
InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
- return ErrorCodeType.REMOVINGMETTERERROR;
+ return ErrorCodeType.REMOVINGMETERERROR;
}
- try {
- if (flowLayer == FlowType.L3) {
- this.flowManager.writeFlow(srcIp, dstIp, new NodeConnectorRef(ncid), NO_METER_SPECIFIED);
- } else if (flowLayer == FlowType.L2) {
- this.flowManager.writeFlow(srcMac, dstMac, new NodeConnectorRef(ncid), NO_METER_SPECIFIED);
- }
- } catch (Exception e) {
- LOG.info("Exception occurs when update the flow in " +
- InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
+ if (! writeFlow(srcIp, dstIp, srcMac, dstMac, flowLayer, ncid, ncr, NO_METER_SPECIFIED))
return ErrorCodeType.SETTINGUPROUTEERROR;
- }
}
} catch (Exception e) {
LOG.info("Exception occurs when remove a rate limiting: " + e.getMessage());
new NodeConnectorKey(new NodeConnectorId(nc_value)))
.build();
NodeConnectorRef ncr = new NodeConnectorRef(ncid);
- if (routeInfoValue.getLimitedRate() > 0 && routeInfoValue.getBurstSize() > 0) {
- try {
- this.meterManager.removeMeterFromSwitch(endpoints, ncr, routeInfoValue.getLimitedRate(), routeInfoValue.getBurstSize());
- } catch (Exception e) {
- LOG.info("Exception occurs when remove the meter from " +
- InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
- return ErrorCodeType.REMOVINGMETTERERROR;
- }
- }
+ if (! removeMeter(endpoints, routeInfoValue, ncr)) return ErrorCodeType.REMOVINGMETERERROR;
long meterId = NO_METER_SPECIFIED;
if (limitedRate > 0 && burstSize > 0) {
}
}
- try {
- if (flowLayer == FlowType.L3) {
- this.flowManager.writeFlow(srcIp, dstIp, new NodeConnectorRef(ncid), meterId);
- } else if (flowLayer == FlowType.L2) {
- this.flowManager.writeFlow(srcMac, dstMac, new NodeConnectorRef(ncid), meterId);
- }
- } catch (Exception e) {
- LOG.info("Exception occurs when update the flow in " +
- InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
+ if (! writeFlow(srcIp, dstIp, srcMac, dstMac, flowLayer, ncid, ncr, meterId))
return ErrorCodeType.SETTINGUPROUTEERROR;
- }
}
} catch (Exception e) {
LOG.info("Exception occurs when update a rate limiting: " + e.getMessage());
}
}
+ private boolean writeFlow(Ipv4Address srcIp, Ipv4Address dstIp, MacAddress srcMac, MacAddress dstMac, FlowType flowLayer, InstanceIdentifier<NodeConnector> ncid, NodeConnectorRef ncr, long meterId) {
+ try {
+ if (flowLayer == FlowType.L3) {
+ this.flowManager.writeFlow(srcIp, dstIp, new NodeConnectorRef(ncid), meterId);
+ } else if (flowLayer == FlowType.L2) {
+ this.flowManager.writeFlow(srcMac, dstMac, new NodeConnectorRef(ncid), meterId);
+ }
+ } catch (Exception e) {
+ LOG.info("Exception occurs when update the flow in " +
+ InstanceIdentifierUtils.generateNodeInstanceIdentifier(ncr).firstKeyOf(Node.class).getId().getValue());
+ return false;
+ }
+ return true;
+ }
+
public ErrorCodeType setupRoute(Endpoints endpoints, List<TpId> route, FlowType flowLayer, long limitedRate, long burstSize) {
Ipv4Address srcIp = endpoints.getSrc();
@Test
public void onTestMaxBandwidth() {
- Graph<String, RouteViewer.Path> networkGraph = new SparseMultigraph<>();
+ Graph<String, RouteViewerPath> networkGraph = new SparseMultigraph<>();
for (int i = 0; i < 5; ++i) {
networkGraph.addVertex("openflow:"+i);
}
addEdge(networkGraph, getTp(4, 1), getTp(5, 0), (long) 10);
addEdge(networkGraph, getTp(1, 2), getTp(6, 0), (long) 5);
addEdge(networkGraph, getTp(6, 1), getTp(4, 2), (long) 5);
- List<RouteViewer.Path> output
+ List<RouteViewerPath> output
= pathComputer.maxBandwidth(networkGraph, getNode(0), getNode(5), (long) 4);
LinkedList<String> result = new LinkedList<>();
result.add(getTp(0, 0));
return "openflow:" + i;
}
- private RouteViewer.Path addEdge (Graph<String, RouteViewer.Path> networkGraph,
- String src, String dst, Long bw) {
- RouteViewer.Path p = new RouteViewer.Path();
+ private RouteViewerPath addEdge (Graph<String, RouteViewerPath> networkGraph,
+ String src, String dst, Long bw) {
+ RouteViewerPath p = new RouteViewerPath();
p.src = TpId.getDefaultInstance(src);
p.dst = TpId.getDefaultInstance(dst);
p.bandwidth = bw;
networkGraph.addEdge(p, PathComputation.extractNodeId(src), PathComputation.extractNodeId(dst),
EdgeType.DIRECTED);
- p = new RouteViewer.Path();
+ p = new RouteViewerPath();
p.src = TpId.getDefaultInstance(dst);
p.dst = TpId.getDefaultInstance(src);
p.bandwidth = bw;