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
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.incubator.net.domain;
18 +
19 +import org.onosproject.core.ApplicationId;
20 +import org.onosproject.incubator.net.tunnel.DomainTunnelId;
21 +import org.onosproject.net.ConnectPoint;
22 +import org.onosproject.net.Path;
23 +
24 +/**
25 + * A variant of intent resource specialized for use on the intra-domain level. It contains a lower level path.
26 + */
27 +public class DomainIntentResource extends IntentResource {
28 +
29 + private final Path domainPath;
30 +
31 + private final DomainTunnelId domainTunnelId;
32 +
33 + private final IntentDomainId intentDomainId;
34 +
35 + /**
36 + * Constructor for a domain intent resource.
37 + *
38 + * @param primitive the primitive associated with this resource
39 + * @param domainTunnelId the id of this tunnel (used as a sorting mechanism)
40 + * @param domainId the ID of the intent domain containing this tunnel
41 + * @param appId the id of the application which created this tunnel
42 + * @param ingress the fist connect point associated with this tunnel (order is irrelevant as long as it is
43 + * consistent with the path)
44 + * @param egress the second connect point associated with this tunnel (order is irrelevant as long as it is
45 + * consistent with the path)
46 + * @param path the path followed through the domain
47 + */
48 + public DomainIntentResource(IntentPrimitive primitive, DomainTunnelId domainTunnelId, IntentDomainId domainId,
49 + ApplicationId appId, ConnectPoint ingress, ConnectPoint egress, Path path) {
50 + super(primitive, appId, ingress, egress);
51 +
52 + this.domainPath = path;
53 + this.domainTunnelId = domainTunnelId;
54 + this.intentDomainId = domainId;
55 + }
56 +
57 + /**
58 + * Returns the domain path associated with this resource at creation.
59 + *
60 + * @return this resource's domain level path or if this resource backs a network tunnel then null.
61 + */
62 + public Path path() {
63 + return domainPath;
64 + }
65 +
66 + /**
67 + * Returns the tunnel ID associated with this domain at creation.
68 + *
69 + * @return this resource's tunnel ID.
70 + */
71 + public DomainTunnelId tunnelId() {
72 + return domainTunnelId;
73 + }
74 +
75 + /**
76 + * Returns the domain ID associated with this resource at creation.
77 + *
78 + * @return this resource's domain ID.
79 + */
80 + public IntentDomainId domainId() {
81 + return intentDomainId;
82 + }
83 +
84 +}
...@@ -34,51 +34,51 @@ public interface IntentDomainProvider { ...@@ -34,51 +34,51 @@ public interface IntentDomainProvider {
34 * 34 *
35 * @param domain intent domain for the request 35 * @param domain intent domain for the request
36 * @param primitive intent primitive 36 * @param primitive intent primitive
37 - * @return request contexts that contain resources to satisfy the intent 37 + * @return intent resources that specify paths that satisfy the request.
38 */ 38 */
39 //TODO Consider an iterable and/or holds (only hold one or two reservation(s) at a time) 39 //TODO Consider an iterable and/or holds (only hold one or two reservation(s) at a time)
40 - List<RequestContext> request(IntentDomain domain, IntentPrimitive primitive); 40 + List<DomainIntentResource> request(IntentDomain domain, IntentPrimitive primitive);
41 41
42 /** 42 /**
43 * Request that the provider attempt to modify an existing resource to satisfy 43 * Request that the provider attempt to modify an existing resource to satisfy
44 * a new intent primitive. The application must apply the context before 44 * a new intent primitive. The application must apply the context before
45 * the intent resource can be used. 45 * the intent resource can be used.
46 * 46 *
47 - * @param resource existing resource 47 + * @param oldResource the resource to be replaced
48 - * @param newPrimitive intent primitive 48 + * @param newResource the resource to be applied
49 * @return request contexts that contain resources to satisfy the intent 49 * @return request contexts that contain resources to satisfy the intent
50 */ 50 */
51 - List<RequestContext> modify(IntentResource resource, IntentPrimitive newPrimitive); 51 + DomainIntentResource modify(DomainIntentResource oldResource, DomainIntentResource newResource);
52 52
53 /** 53 /**
54 * Requests that the provider release an intent resource. 54 * Requests that the provider release an intent resource.
55 * 55 *
56 * @param resource intent resource 56 * @param resource intent resource
57 */ 57 */
58 - void release(IntentResource resource); 58 + void release(DomainIntentResource resource);
59 59
60 /** 60 /**
61 - * Requests that the provider apply the intent resource in the request context. 61 + * Requests that the provider apply the path from the intent resource.
62 * 62 *
63 - * @param context request context 63 + * @param domainIntentResource request context
64 * @return intent resource that satisfies the intent 64 * @return intent resource that satisfies the intent
65 */ 65 */
66 - IntentResource apply(RequestContext context); 66 + DomainIntentResource apply(DomainIntentResource domainIntentResource);
67 67
68 /** 68 /**
69 - * Requests that the provider cancel the request. Requests that are not applied 69 + * Requests that the provider cancel the path. Requests that are not applied
70 * will be eventually timed out by the provider. 70 * will be eventually timed out by the provider.
71 * 71 *
72 - * @param context request context 72 + * @param domainIntentResource the intent resource whose path should be cancelled.
73 */ 73 */
74 - void cancel(RequestContext context); 74 + void cancel(DomainIntentResource domainIntentResource);
75 75
76 /** 76 /**
77 * Returns all intent resources held by the provider. 77 * Returns all intent resources held by the provider.
78 * 78 *
79 * @return set of intent resources 79 * @return set of intent resources
80 */ 80 */
81 - Set<IntentResource> getResources(); 81 + Set<DomainIntentResource> getResources();
82 } 82 }
83 83
84 84
......
...@@ -16,53 +16,73 @@ ...@@ -16,53 +16,73 @@
16 package org.onosproject.incubator.net.domain; 16 package org.onosproject.incubator.net.domain;
17 17
18 import com.google.common.annotations.Beta; 18 import com.google.common.annotations.Beta;
19 +import org.onosproject.core.ApplicationId;
20 +import org.onosproject.net.ConnectPoint;
21 +
19 22
20 /** 23 /**
21 * The abstract base class for the resource that satisfies an intent primitive. 24 * The abstract base class for the resource that satisfies an intent primitive.
22 */ 25 */
23 @Beta 26 @Beta
24 -public class IntentResource { 27 +public abstract class IntentResource {
25 28
26 private final IntentPrimitive primitive; 29 private final IntentPrimitive primitive;
27 - private final long tunnelId; 30 +
28 - private final IntentDomainId domainId; 31 + private final ApplicationId appId;
32 + private final ConnectPoint ingress;
33 + private final ConnectPoint egress;
34 +
35 + //* QUESTIONABLE ADDITIONS *//
29 36
30 // TODO add other common fields 37 // TODO add other common fields
31 //String ingressTag; 38 //String ingressTag;
32 //String egressTag; 39 //String egressTag;
33 //etc. 40 //etc.
34 41
35 - public IntentResource(IntentPrimitive primitive, long tunnelId, IntentDomainId domainId) { 42 + public IntentResource(IntentPrimitive primitive, ApplicationId appId,
43 + ConnectPoint ingress, ConnectPoint egress) {
44 + this.appId = appId;
45 + this.ingress = ingress;
46 + this.egress = egress;
36 this.primitive = primitive; 47 this.primitive = primitive;
37 - this.tunnelId = tunnelId;
38 - this.domainId = domainId;
39 } 48 }
40 49
50 + //TODO when is same package tunnelID should be of type tunnelID and netTunnelId not long.
51 +
52 +
41 /** 53 /**
42 - * Returns the intent primitive associated with this resource as creation. 54 + * Returns the intent primitive associated with this resource at creation.
43 * 55 *
44 - * @return this resource's intent primitive 56 + * @return this resource's intent primitive.
45 */ 57 */
46 public IntentPrimitive primitive() { 58 public IntentPrimitive primitive() {
47 return primitive; 59 return primitive;
48 } 60 }
49 61
50 /** 62 /**
51 - * Returns the tunnel ID associated with this resource as creation. 63 + * Returns the application ID associated with this resource at creation.
52 * 64 *
53 - * @return this resource's tunnel ID 65 + * @return this resource's application ID.
54 */ 66 */
55 - public long tunnelId() { 67 + public ApplicationId appId() {
56 - return tunnelId; 68 + return appId;
57 } 69 }
58 70
59 /** 71 /**
60 - * Returns the domain ID associated with this resource as creation. 72 + * Returns the ingress connect point associated with this resource at creation.
61 * 73 *
62 - * @return this resource's domain ID 74 + * @return this resource's ingress connect point.
63 */ 75 */
64 - public IntentDomainId domainId() { 76 + public ConnectPoint ingress() {
65 - return domainId; 77 + return ingress;
66 } 78 }
67 79
80 + /**
81 + * Returns the egress connect point associated with this resource at creation.
82 + *
83 + * @return this resource's connect point.
84 + */
85 + public ConnectPoint egress() {
86 + return egress;
87 + }
68 } 88 }
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.incubator.net.domain;
18 +
19 +import org.onosproject.core.ApplicationId;
20 +import org.onosproject.incubator.net.tunnel.NetworkTunnelId;
21 +import org.onosproject.net.ConnectPoint;
22 +
23 +/**
24 + * A variant of intent resource specialized for use on the inter-domain level. It contains a higher level path.
25 + */
26 +public class NetworkIntentResource extends IntentResource {
27 +
28 + private final org.onlab.graph.Path<DomainVertex, DomainEdge> netPath;
29 +
30 + private NetworkTunnelId networkTunnelId;
31 +
32 + /**
33 + * Constructor for a network intent resource.
34 + *
35 + * @param primitive the primitive associated with this resource
36 + * @param networkTunnelId the id of this tunnel (used as a sorting mechanism)
37 + * @param appId the id of the application which created this tunnel
38 + * @param ingress the fist connect point associated with this tunnel (order is irrelevant as long as it is
39 + * consistent with the path)
40 + * @param egress the second connect point associated with this tunnel (order is irrelevant as long as it is
41 + * consistent with the path)
42 + * @param path the path followed through the graph of domain vertices and domain edges
43 + */
44 + public NetworkIntentResource(IntentPrimitive primitive, NetworkTunnelId networkTunnelId, ApplicationId appId,
45 + ConnectPoint ingress, ConnectPoint egress,
46 + org.onlab.graph.Path<DomainVertex, DomainEdge> path) {
47 + super(primitive, appId, ingress, egress);
48 +
49 + this.networkTunnelId = networkTunnelId;
50 + this.netPath = path;
51 + }
52 +
53 + /**
54 + * Returns the network path associated with this resource at creation.
55 + *
56 + * @return this resource's network lever path or if this resource backs a domain level tunnel then null.
57 + */
58 + public org.onlab.graph.Path<DomainVertex, DomainEdge> path() {
59 + return netPath;
60 + }
61 +
62 + /**
63 + * Returns ths network ID associated with this network tunnel at creation.
64 + *
65 + * @return thsi resource's tunnel ID.
66 + */
67 + public NetworkTunnelId tunnelId() {
68 + return this.networkTunnelId;
69 + }
70 +}
1 -/*
2 - * Copyright 2015 Open Networking Laboratory
3 - *
4 - * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with the License.
6 - * You may obtain a copy of the License at
7 - *
8 - * http://www.apache.org/licenses/LICENSE-2.0
9 - *
10 - * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and
14 - * limitations under the License.
15 - */
16 -package org.onosproject.incubator.net.domain;
17 -
18 -import com.google.common.annotations.Beta;
19 -import org.onosproject.net.Path;
20 -
21 -/**
22 - * Context for intent primitive requests to an intent domain provider. A context
23 - * must be explicitly applied before it can be used. The purpose of the request
24 - * context is so that an application can coordinate multiple requests across multiple
25 - * domains before committing. Contexts can be explicitly cancelled if they are not
26 - * needed (due to a better context or incomplete path across domains); they can
27 - * also be automatically cancelled by a provider after a short timeout.
28 - */
29 -@Beta
30 -public class RequestContext {
31 - private final IntentDomain domain;
32 - private final IntentResource resource;
33 - private final Path path;
34 - //TODO other common parameters:
35 - //String cost;
36 -
37 - public RequestContext(IntentDomain domain, IntentResource resource, Path path) {
38 - this.domain = domain;
39 - this.resource = resource;
40 - this.path = path;
41 - }
42 -
43 - public IntentDomain domain() {
44 - return domain;
45 - }
46 -
47 - public IntentResource resource() {
48 - return resource;
49 - }
50 -
51 - public Path path() {
52 - return path;
53 - }
54 -}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.incubator.net.tunnel;
18 +
19 +/**
20 + * A wrapper class for a long used to identify domain level tunnels.
21 + */
22 +public final class DomainTunnelId {
23 +
24 + private final long value;
25 +
26 + /**
27 + * Creates a tunnel identifier from the specified tunnel.
28 + *
29 + * @param value long value
30 + * @return domain tunnel identifier
31 + */
32 + public static DomainTunnelId valueOf(long value) {
33 + return new DomainTunnelId(value);
34 + }
35 +
36 + /**
37 + * Creates a tunnel identifier from the specified tunnel.
38 + *
39 + * @param value long value as a string
40 + * @return domain tunnel identifier
41 + */
42 + public static DomainTunnelId valueOf(String value) {
43 + return new DomainTunnelId(Long.parseLong(value));
44 + }
45 +
46 + /**
47 + * Constructor for serializer.
48 + */
49 + protected DomainTunnelId() {
50 + this.value = 0;
51 + }
52 +
53 + /**
54 + * Constructs the Domain ID corresponding to a given long value.
55 + *
56 + * @param value the underlying value of this domain ID
57 + */
58 + public DomainTunnelId(long value) {
59 + this.value = value;
60 + }
61 +
62 + /**
63 + * Returns the backing value of this domain ID.
64 + *
65 + * @return the long value
66 + */
67 + public long id() {
68 + return value;
69 + }
70 +
71 + @Override
72 + public int hashCode() {
73 + return Long.hashCode(value);
74 + }
75 +
76 + @Override
77 + public boolean equals(Object obj) {
78 + if (obj == this) {
79 + return true;
80 + }
81 + if (!(obj instanceof DomainTunnelId)) {
82 + return false;
83 + }
84 + DomainTunnelId that = (DomainTunnelId) obj;
85 + return this.value == that.value;
86 + }
87 +
88 + @Override
89 + public String toString() {
90 + return "0x" + Long.toHexString(value);
91 + }
92 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.incubator.net.tunnel;
18 +
19 +import com.google.common.annotations.Beta;
20 +
21 +/**
22 + * Representation of a Network Tunnel Id.
23 + */
24 +@Beta
25 +public final class NetworkTunnelId {
26 + private final long value;
27 +
28 + /**
29 + * Creates an tunnel identifier from the specified tunnel.
30 + *
31 + * @param value long value
32 + * @return tunnel identifier
33 + */
34 + public static NetworkTunnelId valueOf(long value) {
35 + return new NetworkTunnelId(value);
36 + }
37 +
38 + public static NetworkTunnelId valueOf(String value) {
39 + return new NetworkTunnelId(Long.parseLong(value));
40 + }
41 +
42 + /**
43 + * Constructor for serializer.
44 + */
45 + NetworkTunnelId() {
46 + this.value = 0;
47 + }
48 +
49 + /**
50 + * Constructs the ID corresponding to a given long value.
51 + *
52 + * @param value the underlying value of this ID
53 + */
54 + public NetworkTunnelId(long value) {
55 + this.value = value;
56 + }
57 +
58 + /**
59 + * Returns the backing value.
60 + *
61 + * @return the value
62 + */
63 + public long id() {
64 + return value;
65 + }
66 +
67 + @Override
68 + public int hashCode() {
69 + return Long.hashCode(value);
70 + }
71 +
72 + @Override
73 + public boolean equals(Object obj) {
74 + if (obj == this) {
75 + return true;
76 + }
77 + if (!(obj instanceof NetworkTunnelId)) {
78 + return false;
79 + }
80 + NetworkTunnelId that = (NetworkTunnelId) obj;
81 + return this.value == that.value;
82 + }
83 +
84 + @Override
85 + public String toString() {
86 + return "0x" + Long.toHexString(value);
87 + }
88 +
89 +}