Thomas Vachuska | 83e090e | 2014-10-22 14:25:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 19 | package org.onlab.onos.net.flow; |
| 20 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 21 | import java.util.concurrent.Future; |
| 22 | |
Thomas Vachuska | e0f804a | 2014-10-27 23:40:48 -0700 | [diff] [blame^] | 23 | import org.onlab.onos.core.ApplicationId; |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 24 | import org.onlab.onos.net.DeviceId; |
| 25 | |
| 26 | /** |
| 27 | * Service for injecting flow rules into the environment and for obtaining |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 28 | * information about flow rules already in the environment. This implements |
| 29 | * semantics of a distributed authoritative flow table where the master copy |
| 30 | * of the flow rules lies with the controller and the devices hold only the |
| 31 | * 'cached' copy. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 32 | */ |
| 33 | public interface FlowRuleService { |
| 34 | |
| 35 | /** |
tom | 9b4030d | 2014-10-06 10:39:03 -0700 | [diff] [blame] | 36 | * Returns the number of flow rules in the system. |
| 37 | * |
| 38 | * @return flow rule count |
| 39 | */ |
| 40 | int getFlowRuleCount(); |
| 41 | |
| 42 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 43 | * Returns the collection of flow entries applied on the specified device. |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 44 | * This will include flow rules which may not yet have been applied to |
| 45 | * the device. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 46 | * |
| 47 | * @param deviceId device identifier |
| 48 | * @return collection of flow rules |
| 49 | */ |
alshabib | 1c319ff | 2014-10-04 20:29:09 -0700 | [diff] [blame] | 50 | Iterable<FlowEntry> getFlowEntries(DeviceId deviceId); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 51 | |
tom | 73d6d1e | 2014-09-17 20:08:01 -0700 | [diff] [blame] | 52 | // TODO: add createFlowRule factory method and execute operations method |
| 53 | |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 54 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 55 | * Applies the specified flow rules onto their respective devices. These |
| 56 | * flow rules will be retained by the system and re-applied anytime the |
| 57 | * device reconnects to the controller. |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 58 | * |
| 59 | * @param flowRules one or more flow rules |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 60 | */ |
alshabib | 219ebaa | 2014-09-22 15:41:24 -0700 | [diff] [blame] | 61 | void applyFlowRules(FlowRule... flowRules); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 64 | * Removes the specified flow rules from their respective devices. If the |
| 65 | * device is not presently connected to the controller, these flow will |
| 66 | * be removed once the device reconnects. |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 67 | * |
| 68 | * @param flowRules one or more flow rules |
| 69 | * throws SomeKindOfException that indicates which ones were removed and |
| 70 | * which ones failed |
| 71 | */ |
| 72 | void removeFlowRules(FlowRule... flowRules); |
| 73 | |
alshabib | a68eb96 | 2014-09-24 20:34:13 -0700 | [diff] [blame] | 74 | /** |
| 75 | * Removes all rules by id. |
| 76 | * |
| 77 | * @param appId id to remove |
| 78 | */ |
| 79 | void removeFlowRulesById(ApplicationId appId); |
| 80 | |
| 81 | /** |
| 82 | * Returns a list of rules with this application id. |
| 83 | * |
| 84 | * @param id the id to look up |
| 85 | * @return collection of flow rules |
| 86 | */ |
| 87 | Iterable<FlowRule> getFlowRulesById(ApplicationId id); |
tom | 4d0c663 | 2014-09-15 23:27:01 -0700 | [diff] [blame] | 88 | |
alshabib | 902d41b | 2014-10-07 16:52:05 -0700 | [diff] [blame] | 89 | /** |
| 90 | * Applies a batch operation of FlowRules. |
| 91 | * |
| 92 | * @return future indicating the state of the batch operation |
| 93 | */ |
| 94 | Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch); |
alshabib | 58747a6 | 2014-10-07 11:05:30 -0700 | [diff] [blame] | 95 | |
alshabib | 369d294 | 2014-09-12 17:59:35 -0700 | [diff] [blame] | 96 | /** |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 97 | * Adds the specified flow rule listener. |
| 98 | * |
| 99 | * @param listener flow rule listener |
| 100 | */ |
| 101 | void addListener(FlowRuleListener listener); |
| 102 | |
| 103 | /** |
| 104 | * Removes the specified flow rule listener. |
| 105 | * |
| 106 | * @param listener flow rule listener |
| 107 | */ |
| 108 | void removeListener(FlowRuleListener listener); |
tom | 8bb1606 | 2014-09-12 14:47:46 -0700 | [diff] [blame] | 109 | } |