Modified intent compilers to only chose paths that are appropriate to the type of intent, i.e. packet or optical.
diff --git a/apps/tvue/src/main/webapp/WEB-INF/web.xml b/apps/tvue/src/main/webapp/WEB-INF/web.xml
index 83d5f73..b42951a 100644
--- a/apps/tvue/src/main/webapp/WEB-INF/web.xml
+++ b/apps/tvue/src/main/webapp/WEB-INF/web.xml
@@ -28,8 +28,14 @@
<servlet-name>JAX-RS Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
- <param-name>com.sun.jersey.config.property.packages</param-name>
- <param-value>org.onlab.onos.tvue</param-value>
+ <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
+ <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
+ </init-param>
+ <init-param>
+ <!--param-name>com.sun.jersey.config.property.packages</param-name>
+ <param-value>org.onlab.onos.tvue</param-value-->
+ <param-name>com.sun.jersey.config.property.classnames</param-name>
+ <param-value>org.onlab.onos.tvue.TopologyResource</param-value>
</init-param>
<load-on-startup>10</load-on-startup>
</servlet>
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/HostToHostIntentCompiler.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/HostToHostIntentCompiler.java
index b244812..e045cec 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/HostToHostIntentCompiler.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/HostToHostIntentCompiler.java
@@ -22,6 +22,7 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.onos.net.Host;
import org.onlab.onos.net.HostId;
+import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.host.HostService;
@@ -30,7 +31,9 @@
import org.onlab.onos.net.intent.IntentCompiler;
import org.onlab.onos.net.intent.IntentExtensionService;
import org.onlab.onos.net.intent.PathIntent;
+import org.onlab.onos.net.topology.LinkWeight;
import org.onlab.onos.net.topology.PathService;
+import org.onlab.onos.net.topology.TopologyEdge;
import java.util.Arrays;
import java.util.List;
@@ -86,7 +89,13 @@
}
private Path getPath(HostId one, HostId two) {
- Set<Path> paths = pathService.getPaths(one, two);
+ Set<Path> paths = pathService.getPaths(one, two, new LinkWeight() {
+ @Override
+ public double weight(TopologyEdge edge) {
+ return edge.link().type() == Link.Type.OPTICAL ? -1 : +1;
+ }
+ });
+
if (paths.isEmpty()) {
throw new PathNotFoundException("No path from host " + one + " to " + two);
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
index 1fae0f9..3683e8e 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
@@ -15,19 +15,12 @@
*/
package org.onlab.onos.net.intent.impl;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
+import com.google.common.collect.ImmutableList;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.onlab.onos.core.CoreService;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
@@ -36,41 +29,26 @@
import org.onlab.onos.net.intent.IntentExtensionService;
import org.onlab.onos.net.intent.OpticalConnectivityIntent;
import org.onlab.onos.net.intent.OpticalPathIntent;
-import org.onlab.onos.net.provider.ProviderId;
-import org.onlab.onos.net.resource.LinkResourceService;
import org.onlab.onos.net.topology.LinkWeight;
-import org.onlab.onos.net.topology.PathService;
import org.onlab.onos.net.topology.Topology;
import org.onlab.onos.net.topology.TopologyEdge;
import org.onlab.onos.net.topology.TopologyService;
-import org.slf4j.Logger;
+
+import java.util.List;
+import java.util.Set;
/**
- * Optical compiler for OpticalConnectivityIntent.
- * It firstly computes K-shortest paths in the optical-layer, then choose the optimal one to assign a wavelength.
- * Finally, it generates one or more opticalPathintent(s) with opticalMatchs and opticalActions.
+ * An intent compiler for {@link org.onlab.onos.net.intent.OpticalConnectivityIntent}.
*/
@Component(immediate = true)
public class OpticalConnectivityIntentCompiler implements IntentCompiler<OpticalConnectivityIntent> {
- private final Logger log = getLogger(getClass());
- private static final ProviderId PID = new ProviderId("core", "org.onlab.onos.core", true);
-
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected IntentExtensionService intentManager;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected PathService pathService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TopologyService topologyService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LinkResourceService resourceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
@Activate
public void activate() {
intentManager.registerCompiler(OpticalConnectivityIntent.class, this);
@@ -84,31 +62,12 @@
@Override
public List<Intent> compile(OpticalConnectivityIntent intent) {
// TODO: compute multiple paths using the K-shortest path algorithm
- List<Intent> retList = new ArrayList<>();
- log.info("The system is comipling the OpticalConnectivityIntent:" + intent.toString());
Path path = calculateOpticalPath(intent.getSrcConnectPoint(), intent.getDst());
- if (path == null) {
- return retList;
- } else {
- log.info("the computed lightpath is : {}.", path.toString());
- }
-
- List<Link> links = new ArrayList<>();
- // links.add(DefaultEdgeLink.createEdgeLink(intent.getSrcConnectPoint(), true));
- links.addAll(path.links());
- //links.add(DefaultEdgeLink.createEdgeLink(intent.getDst(), false));
-
- // create a new opticalPathIntent
Intent newIntent = new OpticalPathIntent(intent.appId(),
- intent.getSrcConnectPoint(),
- intent.getDst(),
- path);
-
- log.info("a new OpticalPathIntent was created: " + newIntent.toString());
-
- retList.add(newIntent);
-
- return retList;
+ intent.getSrcConnectPoint(),
+ intent.getDst(),
+ path);
+ return ImmutableList.of(newIntent);
}
private Path calculateOpticalPath(ConnectPoint start, ConnectPoint end) {
@@ -117,36 +76,18 @@
LinkWeight weight = new LinkWeight() {
@Override
public double weight(TopologyEdge edge) {
- Link.Type lt = edge.link().type();
- if (lt == Link.Type.OPTICAL) {
- return 1.0;
- } else {
- return 1000.0;
- }
+ return edge.link().type() == Link.Type.OPTICAL ? +1 : -1;
}
};
- Set<Path> paths = topologyService.getPaths(topology,
- start.deviceId(),
- end.deviceId(),
- weight);
-
- ArrayList<Path> localPaths = new ArrayList<>();
- Iterator<Path> itr = paths.iterator();
- while (itr.hasNext()) {
- Path path = itr.next();
- if (path.cost() >= 1000) {
- continue;
- }
- localPaths.add(path);
- }
-
- if (localPaths.isEmpty()) {
+ Set<Path> paths = topologyService.getPaths(topology, start.deviceId(),
+ end.deviceId(), weight);
+ if (paths.isEmpty()) {
throw new PathNotFoundException("No fiber path from " + start + " to " + end);
- } else {
- return localPaths.iterator().next();
}
+ // TODO: let's be more intelligent about this eventually
+ return paths.iterator().next();
}
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
index 6fe8c1f..f0747dd 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
@@ -15,11 +15,7 @@
*/
package org.onlab.onos.net.intent.impl;
-import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.List;
-
+import com.google.common.collect.Lists;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -53,14 +49,14 @@
import org.onlab.onos.net.topology.TopologyService;
import org.slf4j.Logger;
-import com.google.common.collect.Lists;
+import java.util.List;
+
+import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
+import static org.slf4j.LoggerFactory.getLogger;
/**
- * OpticaliIntentInstaller for optical path intents.
- * It essentially generates optical FlowRules and
- * call the flowRule service to execute them.
+ * Installer for {@link org.onlab.onos.net.intent.OpticalPathIntent optical path connectivity intents}.
*/
-
@Component(immediate = true)
public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIntent> {
private final Logger log = getLogger(getClass());
@@ -125,12 +121,12 @@
treatmentBuilder.setLambda((short) la.toInt());
FlowRule rule = new DefaultFlowRule(prev.deviceId(),
- selectorBuilder.build(),
- treatmentBuilder.build(),
- 100,
- appId,
- 100,
- true);
+ selectorBuilder.build(),
+ treatmentBuilder.build(),
+ 100,
+ appId,
+ 100,
+ true);
rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule));
@@ -143,12 +139,12 @@
TrafficTreatment treatmentLast = builder()
.setOutput(intent.dst().port()).build();
FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
- selectorBuilder.build(),
- treatmentLast,
- 100,
- appId,
- 100,
- true);
+ selectorBuilder.build(),
+ treatmentLast,
+ 100,
+ appId,
+ 100,
+ true);
rules.add(new FlowRuleBatchEntry(FlowRuleOperation.ADD, rule));
return Lists.newArrayList(new FlowRuleBatchOperation(rules));
@@ -156,7 +152,7 @@
private LinkResourceAllocations assignWavelength(OpticalPathIntent intent) {
LinkResourceRequest.Builder request = DefaultLinkResourceRequest.builder(intent.id(),
- intent.path().links())
+ intent.path().links())
.addLambdaRequest();
LinkResourceAllocations retLambda = resourceService.requestResources(request.build());
return retLambda;
@@ -230,12 +226,12 @@
treatmentBuilder.setLambda((short) la.toInt());
FlowRule rule = new DefaultFlowRule(prev.deviceId(),
- selectorBuilder.build(),
- treatmentBuilder.build(),
- 100,
- appId,
- 100,
- true);
+ selectorBuilder.build(),
+ treatmentBuilder.build(),
+ 100,
+ appId,
+ 100,
+ true);
rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule));
prev = link.dst();
@@ -247,12 +243,12 @@
TrafficTreatment treatmentLast = builder()
.setOutput(intent.dst().port()).build();
FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
- selectorBuilder.build(),
- treatmentLast,
- 100,
- appId,
- 100,
- true);
+ selectorBuilder.build(),
+ treatmentLast,
+ 100,
+ appId,
+ 100,
+ true);
rules.add(new FlowRuleBatchEntry(FlowRuleOperation.REMOVE, rule));
return Lists.newArrayList(new FlowRuleBatchOperation(rules));
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/PathIntentInstaller.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/PathIntentInstaller.java
index 6d14b7a..d0666cc 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/PathIntentInstaller.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/PathIntentInstaller.java
@@ -46,7 +46,7 @@
import com.google.common.collect.Lists;
/**
- * Installer for {@link PathIntent path connectivity intents}.
+ * Installer for {@link PathIntent packet path connectivity intents}.
*/
@Component(immediate = true)
public class PathIntentInstaller implements IntentInstaller<PathIntent> {
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/PointToPointIntentCompiler.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/PointToPointIntentCompiler.java
index 03bd91a..5c79d5c 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/PointToPointIntentCompiler.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/PointToPointIntentCompiler.java
@@ -25,7 +25,6 @@
import org.onlab.onos.net.DefaultPath;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
-import org.onlab.onos.net.host.HostService;
import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.IntentCompiler;
import org.onlab.onos.net.intent.IntentExtensionService;
@@ -33,23 +32,18 @@
import org.onlab.onos.net.intent.PointToPointIntent;
import org.onlab.onos.net.provider.ProviderId;
import org.onlab.onos.net.topology.LinkWeight;
-//import org.onlab.onos.net.topology.LinkWeight;
-import org.onlab.onos.net.topology.PathService;
import org.onlab.onos.net.topology.Topology;
import org.onlab.onos.net.topology.TopologyEdge;
-//import org.onlab.onos.net.topology.Topology;
-//import org.onlab.onos.net.topology.TopologyEdge;
import org.onlab.onos.net.topology.TopologyService;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-//import java.util.Iterator;
import java.util.List;
import java.util.Set;
+import static java.util.Arrays.asList;
+
/**
- * A intent compiler for {@link org.onlab.onos.net.intent.HostToHostIntent}.
+ * An intent compiler for {@link org.onlab.onos.net.intent.PointToPointIntent}.
*/
@Component(immediate = true)
public class PointToPointIntentCompiler
@@ -60,12 +54,6 @@
protected IntentExtensionService intentManager;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected PathService pathService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected TopologyService topologyService;
@Activate
@@ -87,9 +75,8 @@
links.addAll(path.links());
links.add(DefaultEdgeLink.createEdgeLink(intent.egressPoint(), false));
- return Arrays.asList(createPathIntent(new DefaultPath(PID, links, path.cost() + 2,
- path.annotations()),
- intent));
+ return asList(createPathIntent(new DefaultPath(PID, links, path.cost() + 2,
+ path.annotations()), intent));
}
/**
@@ -114,39 +101,21 @@
* @throws PathNotFoundException if a path cannot be found
*/
private Path getPath(ConnectPoint one, ConnectPoint two) {
- // Set<Path> paths = pathService.getPaths(one.deviceId(), two.deviceId());
- Topology topology = topologyService.currentTopology();
+ Topology topology = topologyService.currentTopology();
LinkWeight weight = new LinkWeight() {
@Override
public double weight(TopologyEdge edge) {
- Link.Type lt = edge.link().type();
- if (lt == Link.Type.OPTICAL) {
- return 1000.0;
- } else {
- return Double.MIN_VALUE;
- }
+ return edge.link().type() == Link.Type.OPTICAL ? -1 : +1;
}
};
- Set<Path> paths = topologyService.getPaths(topology,
- one.deviceId(),
- two.deviceId(),
- weight);
-
- ArrayList<Path> localPaths = new ArrayList<>();
- Iterator<Path> itr = paths.iterator();
- while (itr.hasNext()) {
- Path path = itr.next();
- if (path.cost() >= 1000) {
- continue;
- }
- localPaths.add(path);
- }
-
- if (localPaths.isEmpty()) {
+ Set<Path> paths = topologyService.getPaths(topology, one.deviceId(),
+ two.deviceId(), weight);
+ if (paths.isEmpty()) {
throw new PathNotFoundException("No packet path from " + one + " to " + two);
}
+
// TODO: let's be more intelligent about this eventually
- return localPaths.iterator().next();
+ return paths.iterator().next();
}
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/UnavailableIdException.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/UnavailableIdException.java
deleted file mode 100644
index 6ff5d2d..0000000
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/UnavailableIdException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2014 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onlab.onos.net.intent.impl;
-
-/**
- * Represents that there is no available IDs.
- */
-public class UnavailableIdException extends RuntimeException {
-
- private static final long serialVersionUID = -2287403908433720122L;
-
- /**
- * Constructs an exception with no message and no underlying cause.
- */
- public UnavailableIdException() {
- }
-
- /**
- * Constructs an exception with the specified message.
- *
- * @param message the message describing the specific nature of the error
- */
- public UnavailableIdException(String message) {
- super(message);
- }
-
- /**
- * Constructs an exception with the specified message and the underlying cause.
- *
- * @param message the message describing the specific nature of the error
- * @param cause the underlying cause of this error
- */
- public UnavailableIdException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java b/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java
index 21625ed..23c7362 100644
--- a/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/link/impl/LinkManager.java
@@ -212,7 +212,6 @@
checkNotNull(linkDescription, LINK_DESC_NULL);
checkValidity();
-
LinkEvent event = store.createOrUpdateLink(provider().id(),
linkDescription);
if (event != null) {
diff --git a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestPointToPointIntentCompiler.java b/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestPointToPointIntentCompiler.java
index 94542ec..d417908 100644
--- a/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestPointToPointIntentCompiler.java
+++ b/core/net/src/test/java/org/onlab/onos/net/intent/impl/TestPointToPointIntentCompiler.java
@@ -68,7 +68,7 @@
private PointToPointIntentCompiler makeCompiler(String[] hops) {
PointToPointIntentCompiler compiler =
new PointToPointIntentCompiler();
- compiler.pathService = new IntentTestsMocks.MockPathService(hops);
+// compiler.topologyService = new IntentTestsMocks.MockPathService(hops);
return compiler;
}
diff --git a/tools/test/cells/local b/tools/test/cells/local
index f506c08..64b63ec 100644
--- a/tools/test/cells/local
+++ b/tools/test/cells/local
@@ -8,4 +8,4 @@
export OCN="192.168.56.103"
export OCI="${OC1}"
-export ONOS_FEATURES="${ONOS_FEATURES:-webconsole,onos-api,onos-core,onos-cli,onos-openflow,onos-app-fwd,onos-app-proxyarp,onos-app-tvue}"
+export ONOS_FEATURES="${ONOS_FEATURES:-webconsole,onos-api,onos-core,onos-cli,onos-openflow,onos-rest,onos-app-fwd,onos-app-proxyarp,onos-app-tvue}"
diff --git a/tools/test/cells/single b/tools/test/cells/single
index 125477a..50296c1 100644
--- a/tools/test/cells/single
+++ b/tools/test/cells/single
@@ -7,4 +7,4 @@
export OCN="192.168.56.103"
export OCI="${OC1}"
-export ONOS_FEATURES="${ONOS_FEATURES:-webconsole,onos-api,onos-core-trivial,onos-cli,onos-rest,onos-openflow,onos-app-fwd,onos-app-proxyarp,onos-app-tvue}"
+export ONOS_FEATURES=webconsole,onos-api,onos-core-trivial,onos-cli,onos-rest,onos-openflow,onos-app-fwd,onos-app-proxyarp,onos-app-tvue