Merge branch 'master' into optical-integration
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceAllocation.java b/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceAllocation.java
index b542533..5995d5f 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceAllocation.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceAllocation.java
@@ -3,6 +3,21 @@
/**
* Representation of allocated bandwidth resource.
*/
-public interface BandwidthResourceAllocation extends BandwidthResourceRequest {
+public class BandwidthResourceAllocation extends BandwidthResourceRequest
+ implements ResourceAllocation {
+ @Override
+ public ResourceType type() {
+ return ResourceType.BANDWIDTH;
+ }
+
+ /**
+ * Creates a new {@link BandwidthResourceAllocation} with {@link Bandwidth}
+ * object.
+ *
+ * @param bandwidth allocated bandwidth
+ */
+ public BandwidthResourceAllocation(Bandwidth bandwidth) {
+ super(bandwidth);
+ }
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java b/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java
index 2ea24b8..601a27c 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/BandwidthResourceRequest.java
@@ -3,11 +3,34 @@
/**
* Representation of a request for bandwidth resource.
*/
-public interface BandwidthResourceRequest {
+public class BandwidthResourceRequest implements ResourceRequest {
+ private final Bandwidth bandwidth;
+
+ /**
+ * Creates a new {@link BandwidthResourceRequest} with {@link Bandwidth}
+ * object.
+ *
+ * @param bandwidth {@link Bandwidth} object to be requested
+ */
+ public BandwidthResourceRequest(Bandwidth bandwidth) {
+ this.bandwidth = bandwidth;
+ }
+
+ /**
+ * Creates a new {@link BandwidthResourceRequest} with bandwidth value.
+ *
+ * @param bandwidth bandwidth value to be requested
+ */
+ public BandwidthResourceRequest(double bandwidth) {
+ this.bandwidth = Bandwidth.valueOf(bandwidth);
+ }
+
/**
* Returns the bandwidth resource.
*
* @return the bandwidth resource
*/
- Bandwidth bandwidth();
+ public Bandwidth bandwidth() {
+ return bandwidth;
+ }
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java b/core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java
new file mode 100644
index 0000000..38f90c1
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceRequest.java
@@ -0,0 +1,118 @@
+package org.onlab.onos.net.resource;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.onlab.onos.net.Link;
+import org.onlab.onos.net.intent.IntentId;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Implementation of {@link LinkResourceRequest}.
+ */
+public final class DefaultLinkResourceRequest implements LinkResourceRequest {
+
+ private final IntentId intentId;
+ private final Collection<Link> links;
+ private final Set<ResourceRequest> resources;
+
+ /**
+ * Creates a new link resource request with the given ID, links, and
+ * resource requests.
+ *
+ * @param intentId intent ID related to this request
+ * @param links a set of links for the request
+ * @param resources a set of resources to be requested
+ */
+ private DefaultLinkResourceRequest(IntentId intentId,
+ Collection<Link> links,
+ Set<ResourceRequest> resources) {
+ this.intentId = intentId;
+ this.links = ImmutableSet.copyOf(links);
+ this.resources = ImmutableSet.copyOf(resources);
+ }
+
+ @Override
+ public IntentId intendId() {
+ return intentId;
+ }
+
+ @Override
+ public Collection<Link> links() {
+ return links;
+ }
+
+ @Override
+ public Set<ResourceRequest> resources() {
+ return resources;
+ }
+
+ /**
+ * Returns builder of link resource request.
+ *
+ * @param intentId intent ID related to this request
+ * @param links a set of links for the request
+ * @return builder of link resource request
+ */
+ public static LinkResourceRequest.Builder builder(
+ IntentId intentId, Collection<Link> links) {
+ return new Builder(intentId, links);
+ }
+
+ /**
+ * Builder of link resource request.
+ */
+ public static final class Builder implements LinkResourceRequest.Builder {
+ private IntentId intentId;
+ private Collection<Link> links;
+ private Set<ResourceRequest> resources;
+
+ /**
+ * Creates a new link resource request.
+ *
+ * @param intentId intent ID related to this request
+ * @param links a set of links for the request
+ */
+ private Builder(IntentId intentId, Collection<Link> links) {
+ this.intentId = intentId;
+ this.links = links;
+ this.resources = new HashSet<>();
+ }
+
+ /**
+ * Adds lambda request.
+ *
+ * @return self
+ */
+ @Override
+ public Builder addLambdaRequest() {
+ resources.add(new LambdaResourceRequest());
+ return this;
+ }
+
+ /**
+ * Adds bandwidth request with bandwidth value.
+ *
+ * @param bandwidth bandwidth value to be requested
+ * @return self
+ */
+ @Override
+ public Builder addBandwidthRequest(double bandwidth) {
+ resources.add(new BandwidthResourceRequest(bandwidth));
+ return this;
+ }
+
+ /**
+ * Returns link resource request.
+ *
+ * @return link resource request
+ */
+ @Override
+ public LinkResourceRequest build() {
+ return new DefaultLinkResourceRequest(intentId, links, resources);
+ }
+ }
+
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceAllocation.java b/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceAllocation.java
index 1ed63b4..9095633 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceAllocation.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceAllocation.java
@@ -3,11 +3,31 @@
/**
* Representation of allocated lambda resource.
*/
-public interface LambdaResourceAllocation extends LambdaResourceRequest {
+public class LambdaResourceAllocation extends LambdaResourceRequest
+ implements ResourceAllocation {
+ private final Lambda lambda;
+
+ @Override
+ public ResourceType type() {
+ return ResourceType.LAMBDA;
+ }
+
+ /**
+ * Creates a new {@link LambdaResourceAllocation} with {@link Lambda}
+ * object.
+ *
+ * @param lambda allocated lambda
+ */
+ public LambdaResourceAllocation(Lambda lambda) {
+ this.lambda = lambda;
+ }
+
/**
* Returns the lambda resource.
*
* @return the lambda resource
*/
- Lambda lambda();
+ public Lambda lambda() {
+ return lambda;
+ }
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java b/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java
index dfb3b81..30caa2d 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LambdaResourceRequest.java
@@ -3,6 +3,6 @@
/**
* Representation of a request for lambda resource.
*/
-public interface LambdaResourceRequest {
+public class LambdaResourceRequest implements ResourceRequest {
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java
index a3d3e87..412cecd 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceAllocations.java
@@ -1,5 +1,7 @@
package org.onlab.onos.net.resource;
+import java.util.Set;
+
import org.onlab.onos.net.Link;
/**
@@ -12,5 +14,5 @@
* @param link the target link
* @return allocated resource for the link
*/
- ResourceAllocation getResourceAllocation(Link link);
+ Set<ResourceAllocation> getResourceAllocation(Link link);
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
index 3f9bf79..3f32b06 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceRequest.java
@@ -31,4 +31,31 @@
* @return the set of resource requests
*/
Set<ResourceRequest> resources();
+
+ /**
+ * Builder of link resource request.
+ */
+ interface Builder {
+ /**
+ * Adds lambda request.
+ *
+ * @return self
+ */
+ public Builder addLambdaRequest();
+
+ /**
+ * Adds bandwidth request with bandwidth value.
+ *
+ * @param bandwidth bandwidth value to be requested
+ * @return self
+ */
+ public Builder addBandwidthRequest(double bandwidth);
+
+ /**
+ * Returns link resource request.
+ *
+ * @return link resource request
+ */
+ public LinkResourceRequest build();
+ }
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java b/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java
index 5cc1414..3ddadbc 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java
@@ -5,4 +5,10 @@
*/
public interface ResourceAllocation extends ResourceRequest {
+ /**
+ * Returns the type of the allocated resource.
+ *
+ * @return the type of the allocated resource
+ */
+ ResourceType type();
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/ResourceType.java b/core/api/src/main/java/org/onlab/onos/net/resource/ResourceType.java
new file mode 100644
index 0000000..06a8174
--- /dev/null
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/ResourceType.java
@@ -0,0 +1,6 @@
+package org.onlab.onos.net.resource;
+
+public enum ResourceType {
+ LAMBDA,
+ BANDWIDTH,
+}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/package-info.java b/core/api/src/main/java/org/onlab/onos/net/resource/package-info.java
index 4e07a28..6b402a7 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/package-info.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/package-info.java
@@ -1,4 +1,4 @@
/**
* Services for reserving network resources, e.g. bandwidth, lambdas.
*/
-package org.onlab.onos.net.resource;
\ No newline at end of file
+package org.onlab.onos.net.resource;
diff --git a/core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java b/core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java
new file mode 100644
index 0000000..cb14abc
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java
@@ -0,0 +1,68 @@
+package org.onlab.onos.net.resource;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+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.Service;
+import org.onlab.onos.net.Link;
+import org.onlab.onos.net.intent.IntentId;
+import org.slf4j.Logger;
+
+/**
+ * Provides basic implementation of link resources allocation.
+ */
+@Component(immediate = true)
+@Service
+public class LinkResourceManager implements LinkResourceService {
+
+ private final Logger log = getLogger(getClass());
+
+ @Activate
+ public void activate() {
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+ @Override
+ public LinkResourceAllocations requestResources(LinkResourceRequest req) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void releaseResources(LinkResourceAllocations allocations) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Iterable<LinkResourceAllocations> getAllocations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Iterable<LinkResourceAllocations> getAllocations(Link link) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Iterable<IntentId> getIntents(Link link) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ResourceRequest getAvailableResources(Link link) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/core/net/src/main/java/org/onlab/onos/net/resource/package-info.java b/core/net/src/main/java/org/onlab/onos/net/resource/package-info.java
new file mode 100644
index 0000000..6b402a7
--- /dev/null
+++ b/core/net/src/main/java/org/onlab/onos/net/resource/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * Services for reserving network resources, e.g. bandwidth, lambdas.
+ */
+package org.onlab.onos.net.resource;
diff --git a/openflow/api/pom.xml b/openflow/api/pom.xml
index 59d05a2..45d863d 100644
--- a/openflow/api/pom.xml
+++ b/openflow/api/pom.xml
@@ -30,7 +30,7 @@
<groupId>org.projectfloodlight</groupId>
<artifactId>openflowj</artifactId>
<!-- FIXME once experimenter gets merged to upstream -->
- <version>0.3.8-optical_experimenter3</version>
+ <version>0.3.8-optical_experimenter4</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>