blob: 6d04810fde6dcac76300b2de9eeeea72d9a7b608 [file] [log] [blame]
tom8bb16062014-09-12 14:47:46 -07001package org.onlab.onos.net.flow;
2
alshabib902d41b2014-10-07 16:52:05 -07003import java.util.concurrent.Future;
4
alshabiba68eb962014-09-24 20:34:13 -07005import org.onlab.onos.ApplicationId;
tom8bb16062014-09-12 14:47:46 -07006import org.onlab.onos.net.DeviceId;
7
8/**
9 * Service for injecting flow rules into the environment and for obtaining
tom4d0c6632014-09-15 23:27:01 -070010 * information about flow rules already in the environment. This implements
11 * semantics of a distributed authoritative flow table where the master copy
12 * of the flow rules lies with the controller and the devices hold only the
13 * 'cached' copy.
tom8bb16062014-09-12 14:47:46 -070014 */
15public interface FlowRuleService {
16
17 /**
tom9b4030d2014-10-06 10:39:03 -070018 * Returns the number of flow rules in the system.
19 *
20 * @return flow rule count
21 */
22 int getFlowRuleCount();
23
24 /**
tom8bb16062014-09-12 14:47:46 -070025 * Returns the collection of flow entries applied on the specified device.
tom4d0c6632014-09-15 23:27:01 -070026 * This will include flow rules which may not yet have been applied to
27 * the device.
tom8bb16062014-09-12 14:47:46 -070028 *
29 * @param deviceId device identifier
30 * @return collection of flow rules
31 */
alshabib1c319ff2014-10-04 20:29:09 -070032 Iterable<FlowEntry> getFlowEntries(DeviceId deviceId);
tom8bb16062014-09-12 14:47:46 -070033
tom73d6d1e2014-09-17 20:08:01 -070034 // TODO: add createFlowRule factory method and execute operations method
35
tom8bb16062014-09-12 14:47:46 -070036 /**
tom4d0c6632014-09-15 23:27:01 -070037 * Applies the specified flow rules onto their respective devices. These
38 * flow rules will be retained by the system and re-applied anytime the
39 * device reconnects to the controller.
tom8bb16062014-09-12 14:47:46 -070040 *
41 * @param flowRules one or more flow rules
tom8bb16062014-09-12 14:47:46 -070042 */
alshabib219ebaa2014-09-22 15:41:24 -070043 void applyFlowRules(FlowRule... flowRules);
tom8bb16062014-09-12 14:47:46 -070044
45 /**
tom4d0c6632014-09-15 23:27:01 -070046 * Removes the specified flow rules from their respective devices. If the
47 * device is not presently connected to the controller, these flow will
48 * be removed once the device reconnects.
alshabib369d2942014-09-12 17:59:35 -070049 *
50 * @param flowRules one or more flow rules
51 * throws SomeKindOfException that indicates which ones were removed and
52 * which ones failed
53 */
54 void removeFlowRules(FlowRule... flowRules);
55
alshabiba68eb962014-09-24 20:34:13 -070056 /**
57 * Removes all rules by id.
58 *
59 * @param appId id to remove
60 */
61 void removeFlowRulesById(ApplicationId appId);
62
63 /**
64 * Returns a list of rules with this application id.
65 *
66 * @param id the id to look up
67 * @return collection of flow rules
68 */
69 Iterable<FlowRule> getFlowRulesById(ApplicationId id);
tom4d0c6632014-09-15 23:27:01 -070070
alshabib902d41b2014-10-07 16:52:05 -070071 /**
72 * Applies a batch operation of FlowRules.
73 *
74 * @return future indicating the state of the batch operation
75 */
76 Future<CompletedBatchOperation> applyBatch(FlowRuleBatchOperation batch);
alshabib58747a62014-10-07 11:05:30 -070077
alshabib369d2942014-09-12 17:59:35 -070078 /**
tom8bb16062014-09-12 14:47:46 -070079 * Adds the specified flow rule listener.
80 *
81 * @param listener flow rule listener
82 */
83 void addListener(FlowRuleListener listener);
84
85 /**
86 * Removes the specified flow rule listener.
87 *
88 * @param listener flow rule listener
89 */
90 void removeListener(FlowRuleListener listener);
tom8bb16062014-09-12 14:47:46 -070091}