blob: 55c0ea2ed081745b31687276b57b2c4013360c71 [file] [log] [blame]
Thomas Vachuskaedc944c2014-11-04 15:42:25 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuskaedc944c2014-11-04 15:42:25 -08003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.intent;
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080017
Brian O'Connor9476fa12015-06-25 15:17:17 -040018import com.google.common.annotations.Beta;
Brian O'Connorabafb502014-12-02 22:26:20 -080019import org.onosproject.net.Link;
20import org.onosproject.net.Path;
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080021
22/**
23 * Representation of a connectivity constraint capable of evaluating a link
24 * and determining the cost of traversing that link in the context of this
25 * constraint.
26 */
Brian O'Connor9476fa12015-06-25 15:17:17 -040027@Beta
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080028public interface Constraint {
29
30 // TODO: Consider separating cost vs viability.
31
32 /**
33 * Evaluates the specified link and provides the cost for its traversal.
34 *
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080035 * @param link link to be evaluated
36 * @param context resource context for validating availability of resources
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080037 * @return cost of link traversal
38 */
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080039 double cost(Link link, ResourceContext context);
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080040
41 /**
42 * Validates that the specified path satisfies the constraint.
43 *
44 * @param path path to be validated
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080045 * @param context resource context for validating availability of resources
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080046 * @return cost of link traversal
47 */
Sho SHIMIZUb1681bd2016-02-22 12:47:50 -080048 boolean validate(Path path, ResourceContext context);
Thomas Vachuskaedc944c2014-11-04 15:42:25 -080049
50}