Aaron Kruglikov
Committed by Brian O'Connor

Intent domain for multiple domains (incubation)

Added new fields to IntentResource.

Note: The multi-domain work will be reverted after this commit
for simiplicity in Emu.

Change-Id: Ia642ba14e138b15dd6c8a1c74eb34fa8293931aa
/*
* Copyright 2015 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.onosproject.incubator.net.domain;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.tunnel.DomainTunnelId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Path;
/**
* A variant of intent resource specialized for use on the intra-domain level. It contains a lower level path.
*/
public class DomainIntentResource extends IntentResource {
private final Path domainPath;
private final DomainTunnelId domainTunnelId;
private final IntentDomainId intentDomainId;
/**
* Constructor for a domain intent resource.
*
* @param primitive the primitive associated with this resource
* @param domainTunnelId the id of this tunnel (used as a sorting mechanism)
* @param domainId the ID of the intent domain containing this tunnel
* @param appId the id of the application which created this tunnel
* @param ingress the fist connect point associated with this tunnel (order is irrelevant as long as it is
* consistent with the path)
* @param egress the second connect point associated with this tunnel (order is irrelevant as long as it is
* consistent with the path)
* @param path the path followed through the domain
*/
public DomainIntentResource(IntentPrimitive primitive, DomainTunnelId domainTunnelId, IntentDomainId domainId,
ApplicationId appId, ConnectPoint ingress, ConnectPoint egress, Path path) {
super(primitive, appId, ingress, egress);
this.domainPath = path;
this.domainTunnelId = domainTunnelId;
this.intentDomainId = domainId;
}
/**
* Returns the domain path associated with this resource at creation.
*
* @return this resource's domain level path or if this resource backs a network tunnel then null.
*/
public Path path() {
return domainPath;
}
/**
* Returns the tunnel ID associated with this domain at creation.
*
* @return this resource's tunnel ID.
*/
public DomainTunnelId tunnelId() {
return domainTunnelId;
}
/**
* Returns the domain ID associated with this resource at creation.
*
* @return this resource's domain ID.
*/
public IntentDomainId domainId() {
return intentDomainId;
}
}
......@@ -34,51 +34,51 @@ public interface IntentDomainProvider {
*
* @param domain intent domain for the request
* @param primitive intent primitive
* @return request contexts that contain resources to satisfy the intent
* @return intent resources that specify paths that satisfy the request.
*/
//TODO Consider an iterable and/or holds (only hold one or two reservation(s) at a time)
List<RequestContext> request(IntentDomain domain, IntentPrimitive primitive);
List<DomainIntentResource> request(IntentDomain domain, IntentPrimitive primitive);
/**
* Request that the provider attempt to modify an existing resource to satisfy
* a new intent primitive. The application must apply the context before
* the intent resource can be used.
*
* @param resource existing resource
* @param newPrimitive intent primitive
* @param oldResource the resource to be replaced
* @param newResource the resource to be applied
* @return request contexts that contain resources to satisfy the intent
*/
List<RequestContext> modify(IntentResource resource, IntentPrimitive newPrimitive);
DomainIntentResource modify(DomainIntentResource oldResource, DomainIntentResource newResource);
/**
* Requests that the provider release an intent resource.
*
* @param resource intent resource
*/
void release(IntentResource resource);
void release(DomainIntentResource resource);
/**
* Requests that the provider apply the intent resource in the request context.
* Requests that the provider apply the path from the intent resource.
*
* @param context request context
* @param domainIntentResource request context
* @return intent resource that satisfies the intent
*/
IntentResource apply(RequestContext context);
DomainIntentResource apply(DomainIntentResource domainIntentResource);
/**
* Requests that the provider cancel the request. Requests that are not applied
* Requests that the provider cancel the path. Requests that are not applied
* will be eventually timed out by the provider.
*
* @param context request context
* @param domainIntentResource the intent resource whose path should be cancelled.
*/
void cancel(RequestContext context);
void cancel(DomainIntentResource domainIntentResource);
/**
* Returns all intent resources held by the provider.
*
* @return set of intent resources
*/
Set<IntentResource> getResources();
Set<DomainIntentResource> getResources();
}
......
......@@ -16,53 +16,73 @@
package org.onosproject.incubator.net.domain;
import com.google.common.annotations.Beta;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.ConnectPoint;
/**
* The abstract base class for the resource that satisfies an intent primitive.
*/
@Beta
public class IntentResource {
public abstract class IntentResource {
private final IntentPrimitive primitive;
private final long tunnelId;
private final IntentDomainId domainId;
private final ApplicationId appId;
private final ConnectPoint ingress;
private final ConnectPoint egress;
//* QUESTIONABLE ADDITIONS *//
// TODO add other common fields
//String ingressTag;
//String egressTag;
//etc.
public IntentResource(IntentPrimitive primitive, long tunnelId, IntentDomainId domainId) {
public IntentResource(IntentPrimitive primitive, ApplicationId appId,
ConnectPoint ingress, ConnectPoint egress) {
this.appId = appId;
this.ingress = ingress;
this.egress = egress;
this.primitive = primitive;
this.tunnelId = tunnelId;
this.domainId = domainId;
}
//TODO when is same package tunnelID should be of type tunnelID and netTunnelId not long.
/**
* Returns the intent primitive associated with this resource as creation.
* Returns the intent primitive associated with this resource at creation.
*
* @return this resource's intent primitive
* @return this resource's intent primitive.
*/
public IntentPrimitive primitive() {
return primitive;
}
/**
* Returns the tunnel ID associated with this resource as creation.
* Returns the application ID associated with this resource at creation.
*
* @return this resource's tunnel ID
* @return this resource's application ID.
*/
public long tunnelId() {
return tunnelId;
public ApplicationId appId() {
return appId;
}
/**
* Returns the domain ID associated with this resource as creation.
* Returns the ingress connect point associated with this resource at creation.
*
* @return this resource's domain ID
* @return this resource's ingress connect point.
*/
public IntentDomainId domainId() {
return domainId;
public ConnectPoint ingress() {
return ingress;
}
/**
* Returns the egress connect point associated with this resource at creation.
*
* @return this resource's connect point.
*/
public ConnectPoint egress() {
return egress;
}
}
......
/*
* Copyright 2015 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.onosproject.incubator.net.domain;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.tunnel.NetworkTunnelId;
import org.onosproject.net.ConnectPoint;
/**
* A variant of intent resource specialized for use on the inter-domain level. It contains a higher level path.
*/
public class NetworkIntentResource extends IntentResource {
private final org.onlab.graph.Path<DomainVertex, DomainEdge> netPath;
private NetworkTunnelId networkTunnelId;
/**
* Constructor for a network intent resource.
*
* @param primitive the primitive associated with this resource
* @param networkTunnelId the id of this tunnel (used as a sorting mechanism)
* @param appId the id of the application which created this tunnel
* @param ingress the fist connect point associated with this tunnel (order is irrelevant as long as it is
* consistent with the path)
* @param egress the second connect point associated with this tunnel (order is irrelevant as long as it is
* consistent with the path)
* @param path the path followed through the graph of domain vertices and domain edges
*/
public NetworkIntentResource(IntentPrimitive primitive, NetworkTunnelId networkTunnelId, ApplicationId appId,
ConnectPoint ingress, ConnectPoint egress,
org.onlab.graph.Path<DomainVertex, DomainEdge> path) {
super(primitive, appId, ingress, egress);
this.networkTunnelId = networkTunnelId;
this.netPath = path;
}
/**
* Returns the network path associated with this resource at creation.
*
* @return this resource's network lever path or if this resource backs a domain level tunnel then null.
*/
public org.onlab.graph.Path<DomainVertex, DomainEdge> path() {
return netPath;
}
/**
* Returns ths network ID associated with this network tunnel at creation.
*
* @return thsi resource's tunnel ID.
*/
public NetworkTunnelId tunnelId() {
return this.networkTunnelId;
}
}
/*
* Copyright 2015 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.onosproject.incubator.net.domain;
import com.google.common.annotations.Beta;
import org.onosproject.net.Path;
/**
* Context for intent primitive requests to an intent domain provider. A context
* must be explicitly applied before it can be used. The purpose of the request
* context is so that an application can coordinate multiple requests across multiple
* domains before committing. Contexts can be explicitly cancelled if they are not
* needed (due to a better context or incomplete path across domains); they can
* also be automatically cancelled by a provider after a short timeout.
*/
@Beta
public class RequestContext {
private final IntentDomain domain;
private final IntentResource resource;
private final Path path;
//TODO other common parameters:
//String cost;
public RequestContext(IntentDomain domain, IntentResource resource, Path path) {
this.domain = domain;
this.resource = resource;
this.path = path;
}
public IntentDomain domain() {
return domain;
}
public IntentResource resource() {
return resource;
}
public Path path() {
return path;
}
}
/*
* Copyright 2015 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.onosproject.incubator.net.tunnel;
/**
* A wrapper class for a long used to identify domain level tunnels.
*/
public final class DomainTunnelId {
private final long value;
/**
* Creates a tunnel identifier from the specified tunnel.
*
* @param value long value
* @return domain tunnel identifier
*/
public static DomainTunnelId valueOf(long value) {
return new DomainTunnelId(value);
}
/**
* Creates a tunnel identifier from the specified tunnel.
*
* @param value long value as a string
* @return domain tunnel identifier
*/
public static DomainTunnelId valueOf(String value) {
return new DomainTunnelId(Long.parseLong(value));
}
/**
* Constructor for serializer.
*/
protected DomainTunnelId() {
this.value = 0;
}
/**
* Constructs the Domain ID corresponding to a given long value.
*
* @param value the underlying value of this domain ID
*/
public DomainTunnelId(long value) {
this.value = value;
}
/**
* Returns the backing value of this domain ID.
*
* @return the long value
*/
public long id() {
return value;
}
@Override
public int hashCode() {
return Long.hashCode(value);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof DomainTunnelId)) {
return false;
}
DomainTunnelId that = (DomainTunnelId) obj;
return this.value == that.value;
}
@Override
public String toString() {
return "0x" + Long.toHexString(value);
}
}
/*
* Copyright 2015 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.onosproject.incubator.net.tunnel;
import com.google.common.annotations.Beta;
/**
* Representation of a Network Tunnel Id.
*/
@Beta
public final class NetworkTunnelId {
private final long value;
/**
* Creates an tunnel identifier from the specified tunnel.
*
* @param value long value
* @return tunnel identifier
*/
public static NetworkTunnelId valueOf(long value) {
return new NetworkTunnelId(value);
}
public static NetworkTunnelId valueOf(String value) {
return new NetworkTunnelId(Long.parseLong(value));
}
/**
* Constructor for serializer.
*/
NetworkTunnelId() {
this.value = 0;
}
/**
* Constructs the ID corresponding to a given long value.
*
* @param value the underlying value of this ID
*/
public NetworkTunnelId(long value) {
this.value = value;
}
/**
* Returns the backing value.
*
* @return the value
*/
public long id() {
return value;
}
@Override
public int hashCode() {
return Long.hashCode(value);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof NetworkTunnelId)) {
return false;
}
NetworkTunnelId that = (NetworkTunnelId) obj;
return this.value == that.value;
}
@Override
public String toString() {
return "0x" + Long.toHexString(value);
}
}