Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.flowmanager; |
| 2 | |
| 3 | import java.util.Collection; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 4 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 5 | import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy; |
Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 6 | import net.onrc.onos.api.flowmanager.Flow; |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame^] | 7 | import net.onrc.onos.api.flowmanager.FlowBatchHandle; |
Toshio Koide | 4ea8419 | 2014-07-31 12:10:12 -0700 | [diff] [blame] | 8 | import net.onrc.onos.api.flowmanager.FlowBatchOperation; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame] | 9 | import net.onrc.onos.api.flowmanager.FlowId; |
Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 10 | import net.onrc.onos.api.flowmanager.FlowManagerListener; |
Toshio Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 11 | import net.onrc.onos.api.flowmanager.FlowManagerService; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 12 | |
| 13 | /** |
Toshio Koide | 7894ca0 | 2014-08-15 14:30:13 -0700 | [diff] [blame] | 14 | * Manages a set of Flow objects, computes and maintains a set of Match-Action |
| 15 | * entries based on the Flow objects, and executes Match-Action plans. |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 16 | * <p> |
| 17 | * TODO: Make all methods thread-safe |
| 18 | */ |
Toshio Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 19 | public class FlowManagerModule implements FlowManagerService { |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 20 | private ConflictDetectionPolicy conflictDetectionPolicy; |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame^] | 21 | private FlowOperationMap flowOperationMap; |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 22 | |
| 23 | /** |
| 24 | * Constructor. |
| 25 | */ |
| 26 | public FlowManagerModule() { |
| 27 | this.conflictDetectionPolicy = ConflictDetectionPolicy.FREE; |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame^] | 28 | this.flowOperationMap = new FlowOperationMap(); |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 31 | @Override |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame^] | 32 | public FlowBatchHandle addFlow(Flow flow) { |
Toshio Koide | 4ea8419 | 2014-07-31 12:10:12 -0700 | [diff] [blame] | 33 | FlowBatchOperation ops = new FlowBatchOperation(); |
| 34 | ops.addAddFlowOperation(flow); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 35 | return executeBatch(ops); |
| 36 | } |
| 37 | |
| 38 | @Override |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame^] | 39 | public FlowBatchHandle removeFlow(FlowId id) { |
Toshio Koide | 4ea8419 | 2014-07-31 12:10:12 -0700 | [diff] [blame] | 40 | FlowBatchOperation ops = new FlowBatchOperation(); |
| 41 | ops.addRemoveFlowOperation(id); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 42 | return executeBatch(ops); |
| 43 | } |
| 44 | |
| 45 | @Override |
Toshio Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 46 | public Flow getFlow(FlowId id) { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 47 | // TODO Auto-generated method stub |
| 48 | return null; |
| 49 | } |
| 50 | |
| 51 | @Override |
Toshio Koide | fad1cd5 | 2014-08-07 17:10:07 -0700 | [diff] [blame] | 52 | public Collection<Flow> getFlows() { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 53 | // TODO Auto-generated method stub |
| 54 | return null; |
| 55 | } |
| 56 | |
| 57 | @Override |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame^] | 58 | public FlowBatchHandle executeBatch(FlowBatchOperation ops) { |
| 59 | // This method just put the batch-operation object to the global |
| 60 | // flow operation map with unique ID. The leader process will get |
| 61 | // the appended operation with events notified from the map. |
| 62 | FlowBatchHandle handler = flowOperationMap.putOperation(ops); |
| 63 | |
| 64 | // Then it will return a handler to obtain the result of this operation, |
| 65 | // control the executing process, etc. |
| 66 | return handler; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public void setConflictDetectionPolicy(ConflictDetectionPolicy policy) { |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 71 | if (policy == ConflictDetectionPolicy.FREE) { |
| 72 | conflictDetectionPolicy = policy; |
| 73 | } else { |
| 74 | throw new UnsupportedOperationException( |
| 75 | policy.toString() + " is not supported."); |
| 76 | } |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public ConflictDetectionPolicy getConflictDetectionPolicy() { |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 81 | return conflictDetectionPolicy; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | @Override |
Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 85 | public void addListener(FlowManagerListener listener) { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 86 | // TODO Auto-generated method stub |
| 87 | |
| 88 | } |
| 89 | |
| 90 | @Override |
Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 91 | public void removeListener(FlowManagerListener listener) { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 92 | // TODO Auto-generated method stub |
| 93 | |
| 94 | } |
| 95 | } |