summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint')
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java113
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java64
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java109
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java64
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java83
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java91
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java93
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java108
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java92
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/PartialFailureConstraint.java49
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java117
-rw-r--r--framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/package-info.java20
12 files changed, 0 insertions, 1003 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java
deleted file mode 100644
index f5439efd..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AnnotationConstraint.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-import java.util.Objects;
-
-import static org.onosproject.net.AnnotationKeys.getAnnotatedValue;
-
-/**
- * Constraint that evaluates an arbitrary link annotated value is under the specified threshold.
- */
-@Beta
-public class AnnotationConstraint extends BooleanConstraint {
-
- private final String key;
- private final double threshold;
-
- /**
- * Creates a new constraint to keep the value for the specified key
- * of link annotation under the threshold.
- *
- * @param key key of link annotation
- * @param threshold threshold value of the specified link annotation
- */
- public AnnotationConstraint(String key, double threshold) {
- this.key = key;
- this.threshold = threshold;
- }
-
- // Constructor for serialization
- private AnnotationConstraint() {
- this.key = "";
- this.threshold = 0;
- }
-
- /**
- * Returns the key of link annotation this constraint designates.
- * @return key of link annotation
- */
- public String key() {
- return key;
- }
-
- /**
- * Returns the threshold this constraint ensures as link annotated value.
- *
- * @return threshold as link annotated value
- */
- public double threshold() {
- return threshold;
- }
-
- @Override
- public boolean isValid(Link link, LinkResourceService resourceService) {
- double value = getAnnotatedValue(link, key);
-
- return value <= threshold;
- }
-
- @Override
- public double cost(Link link, LinkResourceService resourceService) {
- if (isValid(link, resourceService)) {
- return getAnnotatedValue(link, key);
- } else {
- return -1;
- }
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(key, threshold);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (!(obj instanceof AnnotationConstraint)) {
- return false;
- }
-
- final AnnotationConstraint other = (AnnotationConstraint) obj;
- return Objects.equals(this.key, other.key) && Objects.equals(this.threshold, other.threshold);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("key", key)
- .add("threshold", threshold)
- .toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java
deleted file mode 100644
index e0f8614c..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/AsymmetricPathConstraint.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Constraint that serves as a request for asymmetric bi-directional path.
- */
-@Beta
-public class AsymmetricPathConstraint implements Constraint {
-
- @Override
- public double cost(Link link, LinkResourceService resourceService) {
- return 1;
- }
-
- @Override
- public boolean validate(Path path, LinkResourceService resourceService) {
- return true;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(true);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- return true;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
deleted file mode 100644
index 1b4a2600..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BandwidthConstraint.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-
-import org.onlab.util.Bandwidth;
-import org.onlab.util.DataRateUnit;
-import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.BandwidthResourceRequest;
-import org.onosproject.net.resource.link.LinkResourceService;
-import org.onosproject.net.resource.ResourceRequest;
-import org.onosproject.net.resource.ResourceType;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Constraint that evaluates links based on available bandwidths.
- */
-@Beta
-public final class BandwidthConstraint extends BooleanConstraint {
-
- private final Bandwidth bandwidth;
-
- /**
- * Creates a new bandwidth constraint.
- *
- * @param bandwidth required bandwidth
- */
- public BandwidthConstraint(Bandwidth bandwidth) {
- this.bandwidth = checkNotNull(bandwidth, "Bandwidth cannot be null");
- }
-
- /**
- * Creates a new bandwidth constraint.
- *
- * @param v required amount of bandwidth
- * @param unit {@link DataRateUnit} of {@code v}
- * @return {@link BandwidthConstraint} instance with given bandwidth requirement
- */
- public static BandwidthConstraint of(double v, DataRateUnit unit) {
- return new BandwidthConstraint(Bandwidth.of(v, unit));
- }
-
- // Constructor for serialization
- private BandwidthConstraint() {
- this.bandwidth = null;
- }
-
- @Override
- public boolean isValid(Link link, LinkResourceService resourceService) {
- for (ResourceRequest request : resourceService.getAvailableResources(link)) {
- if (request.type() == ResourceType.BANDWIDTH) {
- BandwidthResourceRequest brr = (BandwidthResourceRequest) request;
- if (brr.bandwidth().toDouble() >= bandwidth.bps()) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Returns the bandwidth required by this constraint.
- *
- * @return required bandwidth
- */
- public Bandwidth bandwidth() {
- return bandwidth;
- }
-
- @Override
- public int hashCode() {
- return bandwidth.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final BandwidthConstraint other = (BandwidthConstraint) obj;
- return Objects.equals(this.bandwidth, other.bandwidth);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("bandwidth", bandwidth).toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java
deleted file mode 100644
index f1d4ad9f..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/BooleanConstraint.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-/**
- * Abstract base class for various constraints that evaluate link viability
- * in a yes/no fashion.
- */
-@Beta
-public abstract class BooleanConstraint implements Constraint {
-
- /**
- * Returns true if the specified link satisfies the constraint.
- *
- * @param link link to be validated
- * @param resourceService resource service for checking available link resources
- * @return true if link is viable
- */
- public abstract boolean isValid(Link link, LinkResourceService resourceService);
-
- /**
- * {@inheritDoc}
- *
- * Negative return value means the specified link does not satisfy this constraint.
- *
- * @param link {@inheritDoc}
- * @param resourceService {@inheritDoc}
- * @return {@inheritDoc}
- */
- @Override
- public double cost(Link link, LinkResourceService resourceService) {
- return isValid(link, resourceService) ? +1 : -1;
- }
-
- @Override
- public boolean validate(Path path, LinkResourceService resourceService) {
- for (Link link : path.links()) {
- if (!isValid(link, resourceService)) {
- return false;
- }
- }
- return true;
- }
-
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
deleted file mode 100644
index e8539398..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/EncapsulationConstraint.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2014-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.net.intent.constraint;
-
-
-import org.onosproject.net.EncapsulationType;
-import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Encapsulation to manage core transportation.
- */
-public class EncapsulationConstraint extends BooleanConstraint {
-
- private EncapsulationType encapType;
-
- /**
- * Creates a new encapsulation constraint.
- *
- * @param encapType the encapsulation type {@link EncapsulationType}
- */
- public EncapsulationConstraint(EncapsulationType encapType) {
- checkNotNull(encapType, "EncapsulationType cannot be null");
- this.encapType = encapType;
- }
-
-
- @Override
- public boolean isValid(Link link, LinkResourceService resourceService) {
- //TODO: validate the availability of the resources for each link in the path.
- //e.g., availability of MPLSlabels, VLANID
-
- return true;
- }
-
- /**
- * Returns the encapsulation type required by this constraint.
- *
- * @return encapType
- */
- public EncapsulationType encapType() {
- return encapType;
- }
-
- @Override
- public int hashCode() {
- return encapType.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final EncapsulationConstraint other = (EncapsulationConstraint) obj;
- return this.encapType() == other.encapType();
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("encapType", encapType).toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
deleted file mode 100644
index eba28984..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LambdaConstraint.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import org.onosproject.net.IndexedLambda;
-import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.LinkResourceService;
-import org.onosproject.net.resource.ResourceRequest;
-import org.onosproject.net.resource.ResourceType;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-/**
- * Constraint that evaluates links based on available lambda.
- */
-@Beta
-public class LambdaConstraint extends BooleanConstraint {
-
- private final IndexedLambda lambda;
-
- /**
- * Creates a new optical lambda constraint.
- *
- * @param lambda optional lambda to indicate a specific lambda
- */
- public LambdaConstraint(IndexedLambda lambda) {
- this.lambda = lambda;
- }
-
- // Constructor for serialization
- private LambdaConstraint() {
- this.lambda = null;
- }
-
- @Override
- public boolean isValid(Link link, LinkResourceService resourceService) {
- for (ResourceRequest request : resourceService.getAvailableResources(link)) {
- if (request.type() == ResourceType.LAMBDA) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Returns the lambda required by this constraint.
- *
- * @return required lambda
- */
- public IndexedLambda lambda() {
- return lambda;
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(lambda);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final LambdaConstraint other = (LambdaConstraint) obj;
- return Objects.equals(this.lambda, other.lambda);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("lambda", lambda).toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
deleted file mode 100644
index aecef879..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LatencyConstraint.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-import java.time.Duration;
-import java.time.temporal.ChronoUnit;
-import java.util.Objects;
-
-import static org.onosproject.net.AnnotationKeys.LATENCY;
-import static org.onosproject.net.AnnotationKeys.getAnnotatedValue;
-
-/**
- * Constraint that evaluates the latency through a path.
- */
-@Beta
-public class LatencyConstraint implements Constraint {
-
- private final Duration latency;
-
- /**
- * Creates a new constraint to keep under specified latency through a path.
- * @param latency latency to be kept
- */
- public LatencyConstraint(Duration latency) {
- this.latency = latency;
- }
-
- // Constructor for serialization
- private LatencyConstraint() {
- this.latency = Duration.ZERO;
- }
-
- public Duration latency() {
- return latency;
- }
-
- @Override
- public double cost(Link link, LinkResourceService resourceService) {
- return getAnnotatedValue(link, LATENCY);
- }
-
- @Override
- public boolean validate(Path path, LinkResourceService resourceService) {
- double pathLatency = path.links().stream().mapToDouble(link -> cost(link, resourceService)).sum();
- return Duration.of((long) pathLatency, ChronoUnit.MICROS).compareTo(latency) <= 0;
- }
-
- @Override
- public int hashCode() {
- return latency.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (!(obj instanceof LatencyConstraint)) {
- return false;
- }
-
- final LatencyConstraint that = (LatencyConstraint) obj;
- return Objects.equals(this.latency, that.latency);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("latency", latency)
- .toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java
deleted file mode 100644
index ffa4405b..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/LinkTypeConstraint.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import com.google.common.collect.ImmutableSet;
-import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-import java.util.Objects;
-import java.util.Set;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Constraint that evaluates links based on their type.
- */
-@Beta
-public class LinkTypeConstraint extends BooleanConstraint {
-
- private final Set<Link.Type> types;
- private final boolean isInclusive;
-
- /**
- * Creates a new constraint for requesting connectivity using or avoiding
- * the specified link types.
- *
- * @param inclusive indicates whether the given link types are to be
- * permitted or avoided
- * @param types link types
- */
- public LinkTypeConstraint(boolean inclusive, Link.Type... types) {
- checkNotNull(types, "Link types cannot be null");
- checkArgument(types.length > 0, "There must be more than one type");
- this.types = ImmutableSet.copyOf(types);
- this.isInclusive = inclusive;
- }
-
- // Constructor for serialization
- private LinkTypeConstraint() {
- this.types = null;
- this.isInclusive = false;
- }
-
- @Override
- public boolean isValid(Link link, LinkResourceService resourceService) {
- boolean contains = types.contains(link.type());
- return isInclusive ? contains : !contains;
- }
-
- /**
- * Returns the set of link types.
- *
- * @return set of link types
- */
- public Set<Link.Type> types() {
- return types;
- }
-
- /**
- * Indicates if the constraint is inclusive or exclusive.
- *
- * @return true if inclusive
- */
- public boolean isInclusive() {
- return isInclusive;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(types, isInclusive);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null || getClass() != obj.getClass()) {
- return false;
- }
- final LinkTypeConstraint other = (LinkTypeConstraint) obj;
- return Objects.equals(this.types, other.types) && Objects.equals(this.isInclusive, other.isInclusive);
- }
-
- @Override
- public String toString() {
- return toStringHelper(this)
- .add("inclusive", isInclusive)
- .add("types", types)
- .toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
deleted file mode 100644
index ca4f3fd3..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/ObstacleConstraint.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2014-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.net.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableSet;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-import java.util.Collections;
-import java.util.Objects;
-import java.util.Set;
-
-/**
- * Constraint that evaluates elements not passed through.
- */
-@Beta
-public class ObstacleConstraint extends BooleanConstraint {
-
- private final Set<DeviceId> obstacles;
-
- /**
- * Creates a new constraint that the specified device are not passed through.
- * @param obstacles devices not to be passed
- */
- public ObstacleConstraint(DeviceId... obstacles) {
- this.obstacles = ImmutableSet.copyOf(obstacles);
- }
-
- // Constructor for serialization
- private ObstacleConstraint() {
- this.obstacles = Collections.emptySet();
- }
-
- /**
- * Returns the obstacle device ids.
- *
- * @return Set of obstacle device ids
- */
- public Set<DeviceId> obstacles() {
- return obstacles;
- }
-
- @Override
- public boolean isValid(Link link, LinkResourceService resourceService) {
- DeviceId src = link.src().deviceId();
- DeviceId dst = link.dst().deviceId();
-
- return !(obstacles.contains(src) || obstacles.contains(dst));
- }
-
- @Override
- public int hashCode() {
- return obstacles.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (!(obj instanceof ObstacleConstraint)) {
- return false;
- }
-
- final ObstacleConstraint that = (ObstacleConstraint) obj;
- return Objects.equals(this.obstacles, that.obstacles);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("obstacles", obstacles)
- .toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/PartialFailureConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/PartialFailureConstraint.java
deleted file mode 100644
index 827859b1..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/PartialFailureConstraint.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.net.intent.constraint;
-
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.intent.ConnectivityIntent;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.intent.Intent;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-/**
- * A constraint that allows intents that can only be partially compiled
- * (i.e. MultiPointToSinglePointIntent or SinglePointToMultiPointIntent)
- * to be installed when some endpoints or paths are not found.
- */
-public class PartialFailureConstraint implements Constraint {
- @Override
- public double cost(Link link, LinkResourceService resourceService) {
- return 1;
- }
-
- @Override
- public boolean validate(Path path, LinkResourceService resourceService) {
- return true;
- }
-
- public static boolean intentAllowsPartialFailure(Intent intent) {
- if (intent instanceof ConnectivityIntent) {
- ConnectivityIntent connectivityIntent = (ConnectivityIntent) intent;
- return connectivityIntent.constraints().stream()
- .anyMatch(c -> c instanceof PartialFailureConstraint);
- }
- return false;
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
deleted file mode 100644
index 4839feec..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/WaypointConstraint.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2014 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.intent.constraint;
-
-import com.google.common.annotations.Beta;
-import com.google.common.base.MoreObjects;
-import com.google.common.collect.ImmutableList;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.Path;
-import org.onosproject.net.intent.Constraint;
-import org.onosproject.net.resource.link.LinkResourceService;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Constraint that evaluates elements passed through in order.
- */
-@Beta
-public class WaypointConstraint implements Constraint {
-
- private final List<DeviceId> waypoints;
-
- /**
- * Creates a new waypoint constraint.
- *
- * @param waypoints waypoints
- */
- public WaypointConstraint(DeviceId... waypoints) {
- checkNotNull(waypoints, "waypoints cannot be null");
- checkArgument(waypoints.length > 0, "length of waypoints should be more than 0");
- this.waypoints = ImmutableList.copyOf(waypoints);
- }
-
- // Constructor for serialization
- private WaypointConstraint() {
- this.waypoints = Collections.emptyList();
- }
-
- public List<DeviceId> waypoints() {
- return waypoints;
- }
-
- @Override
- public double cost(Link link, LinkResourceService resourceService) {
- // Always consider the number of hops
- return 1;
- }
-
- @Override
- public boolean validate(Path path, LinkResourceService resourceService) {
- LinkedList<DeviceId> waypoints = new LinkedList<>(this.waypoints);
- DeviceId current = waypoints.poll();
- // This is safe because Path class ensures the number of links are more than 0
- Link firstLink = path.links().get(0);
- if (firstLink.src().elementId().equals(current)) {
- current = waypoints.poll();
- }
-
- for (Link link : path.links()) {
- if (link.dst().elementId().equals(current)) {
- current = waypoints.poll();
- // Empty waypoints means passing through all waypoints in the specified order
- if (current == null) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- return waypoints.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (!(obj instanceof WaypointConstraint)) {
- return false;
- }
-
- final WaypointConstraint that = (WaypointConstraint) obj;
- return Objects.equals(this.waypoints, that.waypoints);
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .add("waypoints", waypoints)
- .toString();
- }
-}
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/package-info.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/package-info.java
deleted file mode 100644
index 60d8df16..00000000
--- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/intent/constraint/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2014 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.
- */
-
-/**
- * Definitions of constraints used to refine intent specifications.
- */
-package org.onosproject.net.intent.constraint;