alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 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.net.flowobjective; |
| 17 | |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 18 | import com.google.common.annotations.Beta; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 19 | import org.onosproject.core.ApplicationId; |
| 20 | |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 21 | import java.util.Optional; |
| 22 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 23 | /** |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 24 | * Base representation of a flow-objective description. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 25 | */ |
Thomas Vachuska | a9d491e | 2015-05-20 11:17:21 -0700 | [diff] [blame] | 26 | @Beta |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 27 | public interface Objective { |
| 28 | |
Sho SHIMIZU | e2952e4 | 2015-09-11 17:11:21 -0700 | [diff] [blame] | 29 | boolean DEFAULT_PERMANENT = true; |
| 30 | int DEFAULT_TIMEOUT = 0; |
| 31 | int DEFAULT_PRIORITY = 32768; |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Type of operation. |
| 35 | */ |
| 36 | enum Operation { |
| 37 | /** |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 38 | * Adds the objective. Can be used for any flow objective. For forwarding |
| 39 | * and filtering objectives, existing objectives with identical selector |
| 40 | * and priority fields (but different treatments or next) will be replaced. |
| 41 | * For next objectives, if modification is desired, ADD will not |
| 42 | * do anything - use ADD_TO_EXISTING. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 43 | */ |
| 44 | ADD, |
| 45 | |
| 46 | /** |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 47 | * Removes the objective. Can be used for any flow objective. |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 48 | */ |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 49 | REMOVE, |
| 50 | |
| 51 | /** |
| 52 | * Add to an existing Next Objective. Should not be used for any other |
| 53 | * objective. |
| 54 | */ |
| 55 | ADD_TO_EXISTING, |
| 56 | |
| 57 | /** |
| 58 | * Remove from an existing Next Objective. Should not be used for any |
| 59 | * other objective. |
| 60 | */ |
| 61 | REMOVE_FROM_EXISTING |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | /** |
| 65 | * An identifier for this objective. |
| 66 | * |
| 67 | * @return an integer |
| 68 | */ |
| 69 | int id(); |
| 70 | |
| 71 | /** |
| 72 | * The priority for this objective. |
| 73 | * |
| 74 | * @return an integer |
| 75 | */ |
| 76 | int priority(); |
| 77 | |
| 78 | /** |
| 79 | * The application which applied this objective. |
| 80 | * |
| 81 | * @return an application id |
| 82 | */ |
| 83 | ApplicationId appId(); |
| 84 | |
| 85 | /** |
| 86 | * The timeout for this objective. |
| 87 | * |
| 88 | * @return an integer |
| 89 | */ |
| 90 | int timeout(); |
| 91 | |
| 92 | /** |
| 93 | * Whether this objective is permanent. |
| 94 | * |
| 95 | * @return a boolean |
| 96 | */ |
| 97 | boolean permanent(); |
| 98 | |
| 99 | /** |
| 100 | * The type of operation for this objective. |
| 101 | * |
| 102 | * @return an operation |
| 103 | */ |
| 104 | Operation op(); |
| 105 | |
| 106 | /** |
alshabib | 2a441c6 | 2015-04-13 18:39:38 -0700 | [diff] [blame] | 107 | * Obtains an optional context. |
| 108 | * |
| 109 | * @return optional; which will be empty if there is no context. |
| 110 | * Otherwise it will return the context. |
| 111 | */ |
| 112 | Optional<ObjectiveContext> context(); |
| 113 | |
| 114 | /** |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 115 | * An objective builder. |
| 116 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 117 | interface Builder { |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 118 | /** |
| 119 | * Makes the filtering objective temporary. |
| 120 | * |
| 121 | * @param timeout a timeout |
| 122 | * @return an objective builder |
| 123 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 124 | Builder makeTemporary(int timeout); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Makes the filtering objective permanent. |
| 128 | * |
| 129 | * @return an objective builder |
| 130 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 131 | Builder makePermanent(); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * Specifies the application which applied the filter. |
| 135 | * |
| 136 | * @param appId an application id |
| 137 | * @return an objective builder |
| 138 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 139 | Builder fromApp(ApplicationId appId); |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 140 | |
| 141 | /** |
| 142 | * Sets the priority for this objective. |
| 143 | * |
| 144 | * @param priority an integer |
| 145 | * @return an objective builder |
| 146 | */ |
Sho SHIMIZU | 3310a34 | 2015-05-13 12:14:05 -0700 | [diff] [blame] | 147 | Builder withPriority(int priority); |
Saurav Das | 8a0732e | 2015-11-20 15:27:53 -0800 | [diff] [blame] | 148 | |
alshabib | faa1e36 | 2015-04-02 15:01:54 -0700 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | } |