Initial sketch of intent domains.
Change-Id: I08cb6f9a8c8f83763a2026c1ab9d3e69e0f5d83c
Showing
14 changed files
with
776 additions
and
1 deletions
... | @@ -28,7 +28,7 @@ public final class IntentId implements ResourceConsumer { | ... | @@ -28,7 +28,7 @@ public final class IntentId implements ResourceConsumer { |
28 | private final long value; | 28 | private final long value; |
29 | 29 | ||
30 | /** | 30 | /** |
31 | - * Creates an intent identifier from the specified string representation. | 31 | + * Creates an intent identifier from the specified long representation. |
32 | * | 32 | * |
33 | * @param value long value | 33 | * @param value long value |
34 | * @return intent identifier | 34 | * @return intent identifier | ... | ... |
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 com.google.common.base.MoreObjects; | ||
20 | +import org.onlab.graph.AbstractEdge; | ||
21 | +import org.onosproject.net.ConnectPoint; | ||
22 | + | ||
23 | +import java.util.Objects; | ||
24 | + | ||
25 | +/** | ||
26 | + * Representation of a connection between an intent domain and a device. This | ||
27 | + * must happen using a connect point that is part of both the domain and the | ||
28 | + * device. | ||
29 | + */ | ||
30 | +@Beta | ||
31 | +public class DomainEdge extends AbstractEdge<DomainVertex> { | ||
32 | + ConnectPoint connectPoint; | ||
33 | + | ||
34 | + public DomainEdge(DomainVertex src, DomainVertex dst, ConnectPoint connectPoint) { | ||
35 | + super(src, dst); | ||
36 | + this.connectPoint = connectPoint; | ||
37 | + } | ||
38 | + | ||
39 | + @Override | ||
40 | + public int hashCode() { | ||
41 | + return 43 * super.hashCode() + Objects.hash(connectPoint); | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public boolean equals(Object obj) { | ||
46 | + if (this == obj) { | ||
47 | + return true; | ||
48 | + } | ||
49 | + if (obj instanceof DomainEdge) { | ||
50 | + final DomainEdge other = (DomainEdge) obj; | ||
51 | + return super.equals(other) && | ||
52 | + Objects.equals(this.connectPoint, other.connectPoint); | ||
53 | + } | ||
54 | + return false; | ||
55 | + } | ||
56 | + | ||
57 | + @Override | ||
58 | + public String toString() { | ||
59 | + return MoreObjects.toStringHelper(this) | ||
60 | + .add("src", src()) | ||
61 | + .add("dst", dst()) | ||
62 | + .add("connectPoint", connectPoint) | ||
63 | + .toString(); | ||
64 | + } | ||
65 | +} |
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.onlab.graph.Vertex; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | + | ||
22 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
23 | + | ||
24 | +/** | ||
25 | + * Representation of the intent domain or a device that is part of the intent | ||
26 | + * domain graph. | ||
27 | + */ | ||
28 | +@Beta | ||
29 | +public class DomainVertex implements Vertex { | ||
30 | + // FIXME we will want to add a type enum or subclasses for the two different types | ||
31 | + | ||
32 | + // A domain vertex is either an intent domain or a device: | ||
33 | + private final IntentDomainId id; | ||
34 | + // ----- or ----- | ||
35 | + private final DeviceId deviceId; | ||
36 | + | ||
37 | + // Serialization constructor | ||
38 | + private DomainVertex() { | ||
39 | + this.id = null; | ||
40 | + this.deviceId = null; | ||
41 | + } | ||
42 | + | ||
43 | + DomainVertex(IntentDomainId id) { | ||
44 | + this.id = checkNotNull(id, "Intent domain ID cannot be null."); | ||
45 | + this.deviceId = null; | ||
46 | + } | ||
47 | + | ||
48 | + DomainVertex(DeviceId id) { | ||
49 | + this.id = null; | ||
50 | + this.deviceId = checkNotNull(id, "Device ID cannot be null."); | ||
51 | + } | ||
52 | +} |
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.ConnectPoint; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | + | ||
22 | +import java.util.Objects; | ||
23 | +import java.util.Set; | ||
24 | + | ||
25 | +/** | ||
26 | + * Representation of an intent domain which includes the set of internal devices, | ||
27 | + * the set of edge ports, and the implementation of the domain provider. | ||
28 | + */ | ||
29 | +@Beta | ||
30 | +public class IntentDomain { | ||
31 | + | ||
32 | + private final IntentDomainId id; | ||
33 | + private String name; | ||
34 | + | ||
35 | + private Set<DeviceId> internalDevices; | ||
36 | + private Set<ConnectPoint> edgePorts; | ||
37 | + | ||
38 | + private IntentDomainProvider provider; | ||
39 | + | ||
40 | + IntentDomain(IntentDomainId id, String name, | ||
41 | + Set<DeviceId> internalDevices, | ||
42 | + Set<ConnectPoint> edgePorts) { | ||
43 | + this.id = id; | ||
44 | + this.name = name; | ||
45 | + this.internalDevices = internalDevices; | ||
46 | + this.edgePorts = edgePorts; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Returns the id for the intent domain. | ||
51 | + * | ||
52 | + * @return intent domain id | ||
53 | + */ | ||
54 | + public IntentDomainId id() { | ||
55 | + return id; | ||
56 | + } | ||
57 | + | ||
58 | + /** | ||
59 | + * Returns the friendly name for the intent domain. | ||
60 | + * | ||
61 | + * @return intent domain name | ||
62 | + */ | ||
63 | + public String name() { | ||
64 | + return name; | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Returns the set of internal devices for the intent domain (devices under | ||
69 | + * exclusive control of the intent domain). | ||
70 | + * | ||
71 | + * @return set of internal devices | ||
72 | + */ | ||
73 | + public Set<DeviceId> internalDevices() { | ||
74 | + return internalDevices; | ||
75 | + } | ||
76 | + | ||
77 | + /** | ||
78 | + * Returns the set of edge ports for the intent domain. | ||
79 | + * | ||
80 | + * @return set of edge ports | ||
81 | + */ | ||
82 | + public Set<ConnectPoint> edgePorts() { | ||
83 | + return edgePorts; | ||
84 | + } | ||
85 | + | ||
86 | + /** | ||
87 | + * Returns the provider for the intent domain. | ||
88 | + * | ||
89 | + * @return intent domain provider | ||
90 | + */ | ||
91 | + IntentDomainProvider provider() { | ||
92 | + return provider; | ||
93 | + } | ||
94 | + | ||
95 | + /** | ||
96 | + * Returns the status of the intent domain. An intent domain is active if it | ||
97 | + * has an intent domain provider bound, and it is inactive if one is not bound. | ||
98 | + * | ||
99 | + * @return true if active; false otherwise | ||
100 | + */ | ||
101 | + public boolean isActive() { | ||
102 | + return provider != null; | ||
103 | + } | ||
104 | + | ||
105 | + /** | ||
106 | + * Sets the provider for the intent domain if one is not already set. | ||
107 | + * | ||
108 | + * @param provider new intent domain provider | ||
109 | + */ | ||
110 | + public void setProvider(IntentDomainProvider provider) { | ||
111 | + // TODO consider checkState depending on caller | ||
112 | + if (this.provider == null) { | ||
113 | + this.provider = provider; | ||
114 | + } | ||
115 | + } | ||
116 | + | ||
117 | + /** | ||
118 | + * Unsets the provider for the intent domain if the given provider matches | ||
119 | + * the existing provider. | ||
120 | + * | ||
121 | + * @param provider provider to unset | ||
122 | + */ | ||
123 | + public void unsetProvider(IntentDomainProvider provider) { | ||
124 | + // TODO consider checkState depending on caller | ||
125 | + if (Objects.equals(this.provider, provider)) { | ||
126 | + this.provider = null; | ||
127 | + } | ||
128 | + } | ||
129 | + | ||
130 | + //TODO add remaining setters (we will probably want to link this to the network config) | ||
131 | +} |
incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainAdminService.java
0 → 100644
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.core.ApplicationId; | ||
20 | + | ||
21 | +/** | ||
22 | + * Administrative interface for the intent domain service. | ||
23 | + */ | ||
24 | +@Beta | ||
25 | +public interface IntentDomainAdminService { | ||
26 | + | ||
27 | + /** | ||
28 | + * Register an application that provides intent domain service. | ||
29 | + * | ||
30 | + * @param applicationId application id | ||
31 | + * @param provider intent domain provider | ||
32 | + */ | ||
33 | + void registerApplication(ApplicationId applicationId, IntentDomainProvider provider); | ||
34 | + | ||
35 | + /** | ||
36 | + * Unregisters an application that provides intent domain service. | ||
37 | + * | ||
38 | + * @param applicationId application id | ||
39 | + */ | ||
40 | + void unregisterApplication(ApplicationId applicationId); | ||
41 | + | ||
42 | + /* TODO we may be able to accomplish the following through network config: | ||
43 | + void createDomain(String domainId); | ||
44 | + void removeDomain(String domainId); | ||
45 | + | ||
46 | + void addInternalDeviceToDomain(IntentDomain domain, DeviceId deviceId); | ||
47 | + void addPortToDomain(IntentDomain domain, ConnectPoint port); | ||
48 | + | ||
49 | + void bindApplicationToDomain(String domain, IntentDomain implementation); | ||
50 | + void unbindApplicationToDomain(String domain, IntentDomain implementation); | ||
51 | + */ | ||
52 | +} | ||
53 | + |
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.incubator.net.config.Config; | ||
20 | +import org.onosproject.net.ConnectPoint; | ||
21 | +import org.onosproject.net.DeviceId; | ||
22 | + | ||
23 | +import java.util.Set; | ||
24 | + | ||
25 | +/** | ||
26 | + * Configuration for an intent domain including a name, set of internal devices, | ||
27 | + * set of edge ports, and the application bound to control the domain. | ||
28 | + */ | ||
29 | +@Beta | ||
30 | +public abstract class IntentDomainConfig extends Config<IntentDomainId> { | ||
31 | + | ||
32 | + private static final String DOMAIN_NAME = "domainName"; | ||
33 | + private static final String APPLICATION_NAME = "applicationName"; | ||
34 | + | ||
35 | + /** | ||
36 | + * Returns the friendly name for the domain. | ||
37 | + * | ||
38 | + * @return domain name | ||
39 | + */ | ||
40 | + public String domainName() { | ||
41 | + return get(DOMAIN_NAME, subject.toString()); | ||
42 | + } | ||
43 | + | ||
44 | + /** | ||
45 | + * Sets the friendly name for the domain. | ||
46 | + * | ||
47 | + * @param domainName new name for the domain; null to clear | ||
48 | + * @return self | ||
49 | + */ | ||
50 | + public IntentDomainConfig domainName(String domainName) { | ||
51 | + return (IntentDomainConfig) setOrClear(DOMAIN_NAME, domainName); | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Returns the friendly name for the domain. | ||
56 | + * | ||
57 | + * @return domain name | ||
58 | + */ | ||
59 | + public String applicationName() { | ||
60 | + return get(APPLICATION_NAME, null); //TODO maybe not null? | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Sets the friendly name for the domain. | ||
65 | + * | ||
66 | + * @param applicationName new name for the domain; null to clear | ||
67 | + * @return self | ||
68 | + */ | ||
69 | + public IntentDomainConfig applicationName(String applicationName) { | ||
70 | + return (IntentDomainConfig) setOrClear(APPLICATION_NAME, applicationName); | ||
71 | + } | ||
72 | + | ||
73 | + //TODO sets | ||
74 | + abstract Set<DeviceId> internalDevices(); | ||
75 | + abstract Set<ConnectPoint> edgePorts(); | ||
76 | + | ||
77 | +} |
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 | + | ||
20 | +import java.util.Objects; | ||
21 | + | ||
22 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
23 | + | ||
24 | +/** | ||
25 | + * Intent domain identifier. | ||
26 | + */ | ||
27 | +@Beta | ||
28 | +public class IntentDomainId { | ||
29 | + | ||
30 | + private final String id; | ||
31 | + | ||
32 | + /** | ||
33 | + * Creates an intent domain identifier from the specified string representation. | ||
34 | + * | ||
35 | + * @param value string value | ||
36 | + * @return intent identifier | ||
37 | + */ | ||
38 | + public static IntentDomainId valueOf(String value) { | ||
39 | + return new IntentDomainId(value); | ||
40 | + } | ||
41 | + | ||
42 | + /** | ||
43 | + * Constructor for serializer. | ||
44 | + */ | ||
45 | + IntentDomainId() { | ||
46 | + this.id = null; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Constructs the ID corresponding to a given string value. | ||
51 | + * | ||
52 | + * @param value the underlying value of this ID | ||
53 | + */ | ||
54 | + IntentDomainId(String value) { | ||
55 | + this.id = checkNotNull(value, "Intent domain ID cannot be null."); | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return id.hashCode(); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (obj == this) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + if (!(obj instanceof IntentDomainId)) { | ||
69 | + return false; | ||
70 | + } | ||
71 | + IntentDomainId that = (IntentDomainId) obj; | ||
72 | + return Objects.equals(this.id, that.id); | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public String toString() { | ||
77 | + return id; | ||
78 | + } | ||
79 | +} |
incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainListener.java
0 → 100644
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 | + | ||
20 | +/** | ||
21 | + * Listener for intent domain events. | ||
22 | + */ | ||
23 | +@Beta | ||
24 | +public interface IntentDomainListener { | ||
25 | + //TODO create event types | ||
26 | + //extends EventListener<IntentDomainEvent> | ||
27 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainProvider.java
0 → 100644
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 | + | ||
20 | +import java.util.List; | ||
21 | +import java.util.Set; | ||
22 | + | ||
23 | +/** | ||
24 | + * FIXME. | ||
25 | + */ | ||
26 | +@Beta | ||
27 | +public interface IntentDomainProvider { | ||
28 | + | ||
29 | + /** | ||
30 | + * Requests that the provider attempt to satisfy the intent primitive. | ||
31 | + * The application must apply the context before the intent resource | ||
32 | + * can be used. Request contexts can be explictly cancelled, or they will | ||
33 | + * eventually time out so that resources can be reused. | ||
34 | + * | ||
35 | + * @param primitive intent primitive | ||
36 | + * @return request contexts that contain resources to satisfy the intent | ||
37 | + */ | ||
38 | + //TODO Consider an iterable and/or holds (only hold one or two reservation(s) at a time) | ||
39 | + List<RequestContext> request(IntentPrimitive primitive); | ||
40 | + | ||
41 | + /** | ||
42 | + * Request that the provider attempt to modify an existing resource to satisfy | ||
43 | + * a new intent primitive. The application must apply the context before | ||
44 | + * the intent resource can be used. | ||
45 | + * | ||
46 | + * @param resource existing resource | ||
47 | + * @param newPrimitive intent primitive | ||
48 | + * @return request contexts that contain resources to satisfy the intent | ||
49 | + */ | ||
50 | + List<RequestContext> modify(IntentResource resource, IntentPrimitive newPrimitive); | ||
51 | + | ||
52 | + /** | ||
53 | + * Requests that the provider release an intent resource. | ||
54 | + * | ||
55 | + * @param resource intent resource | ||
56 | + */ | ||
57 | + void release(IntentResource resource); | ||
58 | + | ||
59 | + /** | ||
60 | + * Requests that the provider apply the intent resource in the request context. | ||
61 | + * | ||
62 | + * @param context request context | ||
63 | + * @return intent resource that satisfies the intent | ||
64 | + */ | ||
65 | + IntentResource apply(RequestContext context); | ||
66 | + | ||
67 | + /** | ||
68 | + * Requests that the provider cancel the request. Requests that are not applied | ||
69 | + * will be eventually timed out by the provider. | ||
70 | + * | ||
71 | + * @param context request context | ||
72 | + */ | ||
73 | + void cancel(RequestContext context); | ||
74 | + | ||
75 | + /** | ||
76 | + * Returns all intent resources held by the provider. | ||
77 | + * | ||
78 | + * @return set of intent resources | ||
79 | + */ | ||
80 | + Set<IntentResource> getResources(); | ||
81 | +} | ||
82 | + | ||
83 | + |
incubator/api/src/main/java/org/onosproject/incubator/net/domain/IntentDomainService.java
0 → 100644
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.onlab.graph.Graph; | ||
20 | +import org.onosproject.net.DeviceId; | ||
21 | + | ||
22 | +import java.util.Set; | ||
23 | + | ||
24 | +/** | ||
25 | + * Service for that maintains a graph of intent domains and a registry of intent | ||
26 | + * domain providers. | ||
27 | + */ | ||
28 | +@Beta | ||
29 | +public interface IntentDomainService { | ||
30 | + | ||
31 | + /** | ||
32 | + * Returns the intent domain for the given id. | ||
33 | + * | ||
34 | + * @param id id to look up | ||
35 | + * @return the intent domain; null if none found | ||
36 | + */ | ||
37 | + IntentDomain getDomain(IntentDomainId id); | ||
38 | + | ||
39 | + /** | ||
40 | + * Returns a set of all intent domains. | ||
41 | + * | ||
42 | + * @return set of intent domains | ||
43 | + */ | ||
44 | + Set<IntentDomain> getDomains(); | ||
45 | + | ||
46 | + /** | ||
47 | + * Returns any network domains associated with the given device id. | ||
48 | + * | ||
49 | + * @param deviceId device id to look up | ||
50 | + * @return set of intent domain | ||
51 | + */ | ||
52 | + Set<IntentDomain> getDomains(DeviceId deviceId); | ||
53 | + | ||
54 | + /** | ||
55 | + * Returns the graph of intent domains and connection devices. | ||
56 | + * | ||
57 | + * @return graph of network domains | ||
58 | + */ | ||
59 | + Graph<DomainVertex, DomainEdge> getDomainGraph(); | ||
60 | + | ||
61 | + /** | ||
62 | + * Adds the specified listener for intent domain events. | ||
63 | + * | ||
64 | + * @param listener listener to be added | ||
65 | + */ | ||
66 | + void addListener(IntentDomainListener listener); | ||
67 | + | ||
68 | + /** | ||
69 | + * Removes the specified listener for intent domain events. | ||
70 | + * | ||
71 | + * @param listener listener to be removed | ||
72 | + */ | ||
73 | + void removeListener(IntentDomainListener listener); | ||
74 | +} | ||
75 | + | ||
76 | + | ||
77 | + | ||
78 | + | ||
79 | + |
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.core.ApplicationId; | ||
20 | + | ||
21 | +/** | ||
22 | + * Abstract base class for intent primitives. | ||
23 | + */ | ||
24 | +@Beta | ||
25 | +public abstract class IntentPrimitive { | ||
26 | + | ||
27 | + private final ApplicationId appId; | ||
28 | + | ||
29 | + IntentPrimitive(ApplicationId appId) { | ||
30 | + this.appId = appId; | ||
31 | + } | ||
32 | +} |
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 | + | ||
20 | +/** | ||
21 | + * The abstract base class for the resource that satisfies an intent primitive. | ||
22 | + */ | ||
23 | +@Beta | ||
24 | +public abstract class IntentResource { | ||
25 | + | ||
26 | + private final IntentPrimitive primitive; | ||
27 | + | ||
28 | + // TODO add other common fields | ||
29 | + //String ingressTag; | ||
30 | + //String egressTag; | ||
31 | + //etc. | ||
32 | + | ||
33 | + IntentResource(IntentPrimitive primitive) { | ||
34 | + this.primitive = primitive; | ||
35 | + } | ||
36 | + | ||
37 | + public IntentPrimitive primitive() { | ||
38 | + return primitive; | ||
39 | + } | ||
40 | + | ||
41 | +} |
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 | + | ||
20 | +/** | ||
21 | + * Context for intent primitive requests to an intent domain provider. A context | ||
22 | + * must be explicitly applied before it can be used. The purpose of the request | ||
23 | + * context is so that an application can coordinate multiple requests across multiple | ||
24 | + * domains before committing. Contexts can be explicitly cancelled if they are not | ||
25 | + * needed (due to a better context or incomplete path across domains); they can | ||
26 | + * also be automatically cancelled by a provider after a short timeout. | ||
27 | + */ | ||
28 | +@Beta | ||
29 | +class RequestContext { | ||
30 | + IntentDomain domain; | ||
31 | + IntentResource resource; | ||
32 | + //TODO other common parameters: | ||
33 | + //String cost; | ||
34 | + | ||
35 | + //TODO getters/setters | ||
36 | +} |
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 | +/** | ||
18 | + * Subsystem for network intent domains. | ||
19 | + */ | ||
20 | +package org.onosproject.incubator.net.domain; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment