domain intent APIs
Change-Id: I4b2ac854da7808a880ef0a37b3b08ef51da812e5
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/DomainIntentConfigurable.java b/core/api/src/main/java/org/onosproject/net/behaviour/DomainIntentConfigurable.java
new file mode 100644
index 0000000..3ea4d6c
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/DomainIntentConfigurable.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016-present 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.net.behaviour;
+
+import org.onosproject.net.domain.DomainIntent;
+import org.onosproject.net.driver.Behaviour;
+
+import java.util.Collection;
+
+/**
+ * Behaviour to manages the intent in a network domain.
+ */
+public interface DomainIntentConfigurable extends Behaviour {
+
+ /**
+ * Submit a intent in a network domain.
+ *
+ * @param intent the domain intent to be added
+ * @return the intent installed successfully
+ */
+ DomainIntent sumbit(DomainIntent intent);
+
+ /**
+ * Remove a intent in a domain.
+ *
+ * @param intent the domain intent to be removed.
+ * @return the intent removed successfully
+ */
+ DomainIntent remove(DomainIntent intent);
+
+ /**
+ * Retrieves all installed intend network domain.
+ *
+ * @return a collection of intent installed
+ */
+ Collection<DomainIntent> getIntents();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainId.java b/core/api/src/main/java/org/onosproject/net/domain/DomainId.java
new file mode 100644
index 0000000..6c67009
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainId.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+import org.onlab.util.Identifier;
+
+/**
+ * Representation of a domain identity.
+ */
+public class DomainId extends Identifier<String> {
+
+ /**
+ * Represents the domain directly managed by ONOS.
+ */
+ public static final DomainId LOCAL = domainId("local");
+
+ /**
+ * Constructor of the peer id.
+ *
+ * @param identifier of the peer
+ */
+ public DomainId(String identifier) {
+ super(identifier);
+ }
+
+ /**
+ * Creates a peer id from the string identifier.
+ *
+ * @param identifier string identifier
+ * @return instance of the class DomainId
+ */
+ public static DomainId domainId(String identifier) {
+ return new DomainId(identifier);
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainIntent.java b/core/api/src/main/java/org/onosproject/net/domain/DomainIntent.java
new file mode 100644
index 0000000..7908626
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainIntent.java
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.FilteredConnectPoint;
+import org.onosproject.net.NetworkResource;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.Key;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Intents targeting a domain network.
+ */
+@Beta
+public abstract class DomainIntent extends Intent {
+
+ private final Set<FilteredConnectPoint> filteredIngressPoints;
+ private final Set<FilteredConnectPoint> filteredEgressPoints;
+ private final TrafficTreatment treatment;
+ private final List<Constraint> constraints;
+
+
+ /**
+ * @param appId application identifier
+ * @param key explicit key to use for intent
+ * @param resources required network resources (optional)
+ * @param priority intent priority
+ * @param filteredIngressPoints filtered ingress points
+ * @param filteredEgressPoints filtered egress points
+ * @param treatment action to be applied at the egress
+ * @param constraints constraints of the intent
+ * @throws NullPointerException if {@code filteredIngressPoints} or
+ * {@code filteredEgressPoints} or {@code appId}
+ * or {@code constraints} is null.
+ * @throws IllegalArgumentException if {@code filteredIngressPoints} or {@code filteredEgressPoints} is empty.
+ */
+ public DomainIntent(ApplicationId appId, Key key,
+ Collection<NetworkResource> resources,
+ int priority,
+ Set<FilteredConnectPoint> filteredIngressPoints,
+ Set<FilteredConnectPoint> filteredEgressPoints,
+ TrafficTreatment treatment,
+ List<Constraint> constraints) {
+ super(appId, key, resources, priority);
+
+ checkNotNull(filteredIngressPoints, "Ingress points cannot be null");
+ checkArgument(!filteredIngressPoints.isEmpty(), "Ingress point cannot be empty");
+ checkNotNull(filteredEgressPoints, "Egress points cannot be null");
+ checkArgument(!filteredEgressPoints.isEmpty(), "Egress point cannot be empty");
+ this.filteredIngressPoints = filteredIngressPoints;
+ this.filteredEgressPoints = filteredEgressPoints;
+ this.treatment = treatment;
+ this.constraints = checkNotNull(constraints, "Constraints cannot be null");
+ }
+
+ /**
+ * Constructor for serializer.
+ */
+ protected DomainIntent() {
+ super();
+ filteredIngressPoints = null;
+ filteredEgressPoints = null;
+ treatment = null;
+ constraints = null;
+ }
+
+ /**
+ * Abstract builder for connectivity intents.
+ */
+ public abstract static class Builder extends Intent.Builder {
+ protected List<Constraint> constraints = ImmutableList.of();
+ protected TrafficTreatment treatment;
+
+ /**
+ * Creates a new empty builder.
+ */
+ protected Builder() {
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ return (Builder) super.appId(appId);
+ }
+
+ @Override
+ public Builder key(Key key) {
+ return (Builder) super.key(key);
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ return (Builder) super.priority(priority);
+ }
+
+ /**
+ * Sets the traffic treatment for the intent that will be built.
+ *
+ * @param treatment treatment to use for built intent
+ * @return this builder
+ */
+ public Builder treatment(TrafficTreatment treatment) {
+ this.treatment = treatment;
+ return this;
+ }
+
+ /**
+ * Sets the constraints for the intent that will be built.
+ *
+ * @param constraints constraints to use for built intent
+ * @return this builder
+ */
+ public Builder constraints(List<Constraint> constraints) {
+ this.constraints = ImmutableList.copyOf(constraints);
+ return this;
+ }
+ }
+
+ @Override
+ public boolean isInstallable() {
+ return true;
+ }
+
+ /**
+ * Returns the filtered connected points on which the ingress traffic
+ * should be connected to the egress.
+ *
+ * @return filtered ingress connect points
+ */
+ public Set<FilteredConnectPoint> filteredIngressPoints() {
+ return filteredIngressPoints;
+ }
+
+ /**
+ * Returns the filtered connected points on which the traffic should egress.
+ *
+ * @return filtered egress connect points
+ */
+ public Set<FilteredConnectPoint> filteredEgressPoints() {
+ return filteredEgressPoints;
+ }
+
+ /**
+ * Returns the action applied to the traffic at the egress.
+ *
+ * @return applied action
+ */
+ public TrafficTreatment treatment() {
+ return treatment;
+ }
+
+ /**
+ * Returns the set of connectivity constraints.
+ *
+ * @return list of intent constraints
+ */
+ public List<Constraint> constraints() {
+ return constraints;
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperation.java b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperation.java
new file mode 100644
index 0000000..c26309c
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperation.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+import com.google.common.base.MoreObjects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Representation of an intent operation on a network domain.
+ */
+public class DomainIntentOperation {
+
+ /**
+ * Type of domain intent operations.
+ * <p>
+ * TODO MODIFY to be added here.
+ */
+ public enum Type {
+ ADD,
+ REMOVE
+ }
+
+ private final DomainIntent intent;
+ private final Type type;
+
+ /**
+ * Creates a domain intent operation using the supplied information.
+ *
+ * @param intent the domain intent
+ * @param type the operation type
+ */
+ public DomainIntentOperation(DomainIntent intent, Type type) {
+ this.intent = checkNotNull(intent, "Intent cannot be null");
+ this.type = checkNotNull(type, "Operation type cannot be null");
+ }
+
+ /**
+ * Returns the type of operation.
+ *
+ * @return type
+ */
+ public Type type() {
+ return type;
+ }
+
+ /**
+ * Returns the domain intent.
+ *
+ * @return domain intent
+ */
+ public DomainIntent intent() {
+ return intent;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("intent", intent)
+ .add("type", type)
+ .toString();
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperations.java b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperations.java
new file mode 100644
index 0000000..a7a13c9
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperations.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
+
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.net.domain.DomainIntentOperation.Type.ADD;
+import static org.onosproject.net.domain.DomainIntentOperation.Type.REMOVE;
+
+/**
+ * A batch of domain intent operations that are broken into stages.
+ */
+public class DomainIntentOperations {
+
+ private final List<DomainIntentOperation> stages;
+ private final DomainIntentOperationsContext callback;
+
+ private DomainIntentOperations(List<DomainIntentOperation> stages,
+ DomainIntentOperationsContext cb) {
+ this.stages = stages;
+ this.callback = cb;
+ }
+
+ // kryo-constructor
+ protected DomainIntentOperations() {
+ this.stages = null;
+ this.callback = null;
+ }
+
+ /**
+ * Returns a new builder.
+ *
+ * @return new builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Returns the domain intent operations as sets of stages that should be
+ * executed sequentially.
+ *
+ * @return domain intent stages
+ */
+ public List<DomainIntentOperation> stages() {
+ return stages;
+ }
+
+ /**
+ * Returns the callback for this batch of operations.
+ *
+ * @return callback
+ */
+ public DomainIntentOperationsContext callback() {
+ return callback;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("stages", stages)
+ .toString();
+ }
+
+ /**
+ * A builder for constructing domain intent operations.
+ */
+ public static final class Builder {
+
+ private final ImmutableList.Builder<DomainIntentOperation> listBuilder =
+ ImmutableList.builder();
+
+ // prevent use of the default constructor outside of this file; use the above method
+ private Builder() {
+ }
+
+ /**
+ * Appends a domain intent add to the current stage.
+ *
+ * @param intent domain intent
+ * @return this
+ */
+ public Builder add(DomainIntent intent) {
+ listBuilder.add(new DomainIntentOperation(intent, ADD));
+ return this;
+ }
+
+ /**
+ * Appends an existing domain intent to the current stage.
+ * @param domainIntentOperation domain intent operation
+ * @return this
+ */
+ public Builder operation(DomainIntentOperation domainIntentOperation) {
+ listBuilder.add(domainIntentOperation);
+ return this;
+ }
+
+ /**
+ * Appends a domain intent removal to the current stage.
+ *
+ * @param intent domain intent
+ * @return this
+ */
+ // FIXME this is confusing, consider renaming
+ public Builder remove(DomainIntent intent) {
+ listBuilder.add(new DomainIntentOperation(intent, REMOVE));
+ return this;
+ }
+
+ /**
+ * Builds the immutable domain intent operations.
+ *
+ * @return domain intent operations
+ */
+ public DomainIntentOperations build() {
+ return build(NullDomainIntentOperationsContext.getInstance());
+ }
+
+ /**
+ * Builds the immutable domain intent operations.
+ *
+ * @param cb the callback to call when this operation completes
+ * @return domain intent operations
+ */
+ public DomainIntentOperations build(DomainIntentOperationsContext cb) {
+ checkNotNull(cb);
+ return new DomainIntentOperations(listBuilder.build(), cb);
+ }
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperationsContext.java b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperationsContext.java
new file mode 100644
index 0000000..9a9b924
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentOperationsContext.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+/**
+ * Represents domain intent that does nothing on success or on error.
+ */
+public interface DomainIntentOperationsContext {
+
+ /**
+ * Invoked on successful execution of the domain intent.
+ *
+ * @param idops domain intent to execute
+ */
+ default void onSuccess(DomainIntentOperations idops) {
+ }
+
+ /**
+ * Invoked when error is encountered while executing the domain intent.
+ *
+ * @param idos domain intent to execute
+ */
+ default void onError(DomainIntentOperations idos) {
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainIntentService.java b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentService.java
new file mode 100644
index 0000000..3de7420
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainIntentService.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+/**
+ * Service used to submit and remove intent domains.
+ */
+public interface DomainIntentService {
+
+ /**
+ * Submit a batch operation of domain intent to be send to the target domain
+ * through the proper driver.
+ *
+ * @param domainOperations to be submitted
+ */
+ void sumbit(DomainIntentOperations domainOperations);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainPointToPointIntent.java b/core/api/src/main/java/org/onosproject/net/domain/DomainPointToPointIntent.java
new file mode 100644
index 0000000..7fcc4e6
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainPointToPointIntent.java
@@ -0,0 +1,222 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.FilteredConnectPoint;
+import org.onosproject.net.Link;
+import org.onosproject.net.NetworkResource;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.intent.Constraint;
+import org.onosproject.net.intent.Key;
+
+import java.util.Collection;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Representation of a point to point intent targeting a domain. It consists
+ * into an ingress and an egress filtered connection points and
+ * a set of links to represent the path.
+ */
+@Beta
+public class DomainPointToPointIntent extends DomainIntent {
+
+ private final List<Link> links;
+
+
+ /**
+ * Creates a new point-to-point domain intent with the supplied ingress/egress
+ * ports and domainId.
+ *
+ * @param appId application identifier
+ * @param key explicit key to use for intent
+ * @param priority intent priority
+ * @param filteredIngressPoint filtered ingress point
+ * @param filteredEgressPoint filtered egress point
+ * @throws NullPointerException if {@code filteredIngressPoint} or
+ * {@code filteredEgressPoint} or {@code appId}
+ * or {@code links} or {@code constraints}
+ * is null.
+ */
+ private DomainPointToPointIntent(ApplicationId appId, Key key,
+ int priority,
+ FilteredConnectPoint filteredIngressPoint,
+ FilteredConnectPoint filteredEgressPoint,
+ TrafficTreatment treatment,
+ List<Constraint> constraints,
+ List<Link> links) {
+
+ super(appId, key, resources(links),
+ priority, ImmutableSet.of(filteredIngressPoint),
+ ImmutableSet.of(filteredEgressPoint), treatment, constraints);
+ this.links = links;
+
+ }
+
+ /**
+ * Constructor for serializer.
+ */
+ protected DomainPointToPointIntent() {
+ super();
+ this.links = null;
+ }
+
+ /**
+ * Returns a new point to point domain intent builder. The application id,
+ * ingress point, egress point and domainId are required fields.
+ * If they are not set by calls to the appropriate methods,
+ * an exception will be thrown.
+ *
+ * @return point to point builder
+ */
+ public static DomainPointToPointIntent.Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder of a point to point domain intent.
+ */
+ public static final class Builder extends DomainIntent.Builder {
+ private FilteredConnectPoint filteredIngressPoint;
+ private FilteredConnectPoint filteredEgressPoint;
+ private List<Link> links;
+
+ private Builder() {
+ // Hide constructor
+ }
+
+ @Override
+ public Builder appId(ApplicationId appId) {
+ super.appId = appId;
+ return this;
+ }
+
+ @Override
+ public Builder key(Key key) {
+ super.key = key;
+ return this;
+ }
+
+ @Override
+ public Builder priority(int priority) {
+ super.priority = priority;
+ return this;
+ }
+
+ @Override
+ public Builder treatment(TrafficTreatment treatment) {
+ super.treatment = treatment;
+ return this;
+ }
+
+ @Override
+ public Builder constraints(List<Constraint> constraints) {
+ super.constraints = ImmutableList.copyOf(constraints);
+ return this;
+ }
+
+ /**
+ * Sets the filtered ingress point of the domain point to point intent
+ * that will be built.
+ *
+ * @param ingressPoint single ingress connect point
+ * @return this builder
+ */
+ public Builder filteredIngressPoint(FilteredConnectPoint ingressPoint) {
+ this.filteredIngressPoint = ingressPoint;
+ return this;
+ }
+
+ /**
+ * Sets the filtered egress point of the domain point to point intent
+ * that will be built.
+ *
+ * @param egressPoint single egress connect point
+ * @return this builder
+ */
+ public Builder filteredEgressPoint(FilteredConnectPoint egressPoint) {
+ this.filteredEgressPoint = egressPoint;
+ return this;
+ }
+
+ /**
+ * Sets the links of the point to domain point intent that will be built.
+ *
+ * @param links links for the intent
+ * @return this builder
+ */
+ public Builder links(List<Link> links) {
+ this.links = ImmutableList.copyOf(links);
+ return this;
+ }
+
+ /**
+ * Builds a point to point domain intent from the accumulated parameters.
+ *
+ * @return point to point domain intent
+ */
+ public DomainPointToPointIntent build() {
+
+ return new DomainPointToPointIntent(
+ appId,
+ key,
+ priority,
+ filteredIngressPoint,
+ filteredEgressPoint,
+ treatment,
+ constraints,
+ links
+ );
+ }
+ }
+
+ public List<Link> links() {
+ return links;
+ }
+
+ /**
+ * Produces a collection of network resources from the given links.
+ *
+ * @param links collection of links
+ * @return collection of link resources
+ */
+ protected static Collection<NetworkResource> resources(Collection<Link> links) {
+ checkNotNull(links, "links cannot be null");
+ return ImmutableSet.copyOf(links);
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("id", id())
+ .add("key", key())
+ .add("appId", appId())
+ .add("priority", priority())
+ .add("resources", resources())
+ .add("filtered ingress", filteredIngressPoints())
+ .add("filtered egress", filteredEgressPoints())
+ .toString();
+ }
+
+}
+
diff --git a/core/api/src/main/java/org/onosproject/net/domain/DomainService.java b/core/api/src/main/java/org/onosproject/net/domain/DomainService.java
new file mode 100644
index 0000000..03c465e
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/DomainService.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+import org.onosproject.net.DeviceId;
+
+import java.util.Set;
+
+/**
+ * Service to access domain topology elements.
+ */
+public interface DomainService {
+
+ /**
+ * Returns the set of domains that have an associated topology.
+ *
+ * @return set of domain identifiers
+ */
+ Set<DomainId> getDomainIds();
+
+ /**
+ * Returns the set of the device ids of the specified domain.
+ *
+ * @param domainId domain identifier
+ * @return set of device objects
+ */
+ Set<DeviceId> getDeviceIds(DomainId domainId);
+
+ /**
+ * Returns a domain given a device id.
+ *
+ * @param deviceId the device id
+ * @return null or the domain id of a device
+ */
+ DomainId getDomain(DeviceId deviceId);
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/net/domain/NullDomainIntentOperationsContext.java b/core/api/src/main/java/org/onosproject/net/domain/NullDomainIntentOperationsContext.java
new file mode 100644
index 0000000..616ccfe
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/NullDomainIntentOperationsContext.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+/**
+ * Represents domain intent context that does nothing on success or on error.
+ */
+final class NullDomainIntentOperationsContext implements DomainIntentOperationsContext {
+ private static final DomainIntentOperationsContext INSTANCE = new NullDomainIntentOperationsContext();
+
+ private NullDomainIntentOperationsContext() {
+ }
+
+ /**
+ * Returns an instance of this class.
+ *
+ * @return instance
+ */
+ public static DomainIntentOperationsContext getInstance() {
+ return INSTANCE;
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/domain/package-info.java b/core/api/src/main/java/org/onosproject/net/domain/package-info.java
new file mode 100644
index 0000000..2df8b1a
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/domain/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016-present 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.
+ */
+
+/**
+ * Domain intent package.
+ */
+package org.onosproject.net.domain;
\ No newline at end of file
diff --git a/core/api/src/test/java/org/onosproject/net/domain/DomainPointToPointIntentTest.java b/core/api/src/test/java/org/onosproject/net/domain/DomainPointToPointIntentTest.java
new file mode 100644
index 0000000..99b9ff4
--- /dev/null
+++ b/core/api/src/test/java/org/onosproject/net/domain/DomainPointToPointIntentTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2016-present 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.net.domain;
+
+import com.google.common.collect.ImmutableList;
+import org.junit.Test;
+import org.onosproject.net.DefaultLink;
+import org.onosproject.net.Link;
+import org.onosproject.net.intent.ConnectivityIntentTest;
+import org.onosproject.net.provider.ProviderId;
+
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+
+import static org.junit.Assert.assertEquals;
+import static org.onosproject.net.Link.State.ACTIVE;
+import static org.onosproject.net.Link.Type.DIRECT;
+import static org.onosproject.net.domain.DomainPointToPointIntent.resources;
+
+/**
+ * Suite of tests of the point-to-point domain intent descriptor.
+ */
+public class DomainPointToPointIntentTest extends ConnectivityIntentTest {
+
+ private static final ProviderId PID = new ProviderId("of", "foo");
+ private static final Link L1 = DefaultLink.builder().providerId(PID).src(FP1.connectPoint())
+ .dst(FP2.connectPoint()).type(DIRECT).state(ACTIVE).build();
+ private static final List<Link> LINKS_SET = new LinkedList(Arrays.asList(L1));
+
+ @Test
+ public void basics() {
+ DomainPointToPointIntent intent = createOne();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect ingress",
+ intent.filteredIngressPoints().size(), 1);
+ assertEquals("incorrect ingress",
+ intent.filteredIngressPoints().iterator().next(), FP1);
+ assertEquals("incorrect ingress",
+ intent.filteredEgressPoints().size(), 1);
+ assertEquals("incorrect ingress",
+ intent.filteredEgressPoints().iterator().next(), FP2);
+ assertEquals(intent.links().size(), 0);
+ }
+
+ @Test
+ public void links() {
+ DomainPointToPointIntent intent = createAnother();
+ assertEquals("incorrect id", APPID, intent.appId());
+ assertEquals("incorrect ingress",
+ intent.filteredIngressPoints().size(), 1);
+ assertEquals("incorrect ingress",
+ intent.filteredIngressPoints().iterator().next(), FP2);
+ assertEquals("incorrect ingress",
+ intent.filteredEgressPoints().size(), 1);
+ assertEquals("incorrect ingress",
+ intent.filteredEgressPoints().iterator().next(), FP1);
+ assertEquals("links are not correctly assigned",
+ intent.links(), LINKS_SET);
+ assertEquals("resources are not correctly assigned",
+ intent.resources(), resources(LINKS_SET));
+ }
+
+ @Override
+ protected DomainPointToPointIntent createOne() {
+ return DomainPointToPointIntent.builder()
+ .appId(APPID)
+ .filteredIngressPoint(FP1)
+ .filteredEgressPoint(FP2)
+ .links(ImmutableList.of()).build();
+
+ }
+
+ @Override
+ protected DomainPointToPointIntent createAnother() {
+ return DomainPointToPointIntent.builder()
+ .appId(APPID)
+ .filteredIngressPoint(FP2)
+ .filteredEgressPoint(FP1)
+ .links(LINKS_SET).build();
+ }
+
+}
\ No newline at end of file
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index d638f5f..8e599c5 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -98,6 +98,7 @@
import org.onosproject.net.device.OmsPortDescription;
import org.onosproject.net.device.OtuPortDescription;
import org.onosproject.net.device.PortStatistics;
+import org.onosproject.net.domain.DomainIntent;
import org.onosproject.net.flow.CompletedBatchOperation;
import org.onosproject.net.flow.DefaultFlowEntry;
import org.onosproject.net.flow.DefaultFlowRule;
@@ -571,6 +572,7 @@
.register(ProtectedTransportIntent.class)
.register(MarkerResource.class)
.register(new BitSetSerializer(), BitSet.class)
+ .register(DomainIntent.class)
.build("API");
/**