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; |
| 4 | import java.util.EventListener; |
| 5 | |
| 6 | import net.onrc.onos.api.batchoperation.BatchOperation; |
| 7 | import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy; |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame^] | 8 | import net.onrc.onos.api.flowmanager.FlowId; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 9 | import net.onrc.onos.api.flowmanager.IFlow; |
| 10 | import net.onrc.onos.api.flowmanager.IFlowManagerService; |
| 11 | |
| 12 | /** |
| 13 | * Manages a set of IFlow objects, computes and maintains a set of Match-Action |
| 14 | * entries based on the IFlow objects, and executes Match-Action plans. |
| 15 | * <p> |
| 16 | * TODO: Make all methods thread-safe |
| 17 | */ |
| 18 | public class FlowManagerModule implements IFlowManagerService { |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 19 | private ConflictDetectionPolicy conflictDetectionPolicy; |
| 20 | |
| 21 | /** |
| 22 | * Constructor. |
| 23 | */ |
| 24 | public FlowManagerModule() { |
| 25 | this.conflictDetectionPolicy = ConflictDetectionPolicy.FREE; |
| 26 | } |
| 27 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 28 | @Override |
| 29 | public boolean addFlow(IFlow flow) { |
| 30 | BatchOperation<IFlow> ops = new BatchOperation<IFlow>(); |
| 31 | ops.addAddOperation(flow); |
| 32 | return executeBatch(ops); |
| 33 | } |
| 34 | |
| 35 | @Override |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame^] | 36 | public boolean removeFlow(FlowId id) { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 37 | BatchOperation<IFlow> ops = new BatchOperation<IFlow>(); |
| 38 | ops.addRemoveOperation(id); |
| 39 | return executeBatch(ops); |
| 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public boolean updateFlow(IFlow flow) { |
| 44 | BatchOperation<IFlow> ops = new BatchOperation<IFlow>(); |
| 45 | ops.addUpdateOperation(flow.getId(), flow); |
| 46 | return executeBatch(ops); |
| 47 | } |
| 48 | |
| 49 | @Override |
Toshio Koide | 025a915 | 2014-07-21 11:00:34 -0700 | [diff] [blame^] | 50 | public IFlow getFlow(FlowId id) { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 51 | // TODO Auto-generated method stub |
| 52 | return null; |
| 53 | } |
| 54 | |
| 55 | @Override |
| 56 | public Collection<IFlow> getFlows() { |
| 57 | // TODO Auto-generated method stub |
| 58 | return null; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean executeBatch(BatchOperation<IFlow> ops) { |
| 63 | // TODO Auto-generated method stub |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void setConflictDetectionPolicy(ConflictDetectionPolicy policy) { |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 69 | if (policy == ConflictDetectionPolicy.FREE) { |
| 70 | conflictDetectionPolicy = policy; |
| 71 | } else { |
| 72 | throw new UnsupportedOperationException( |
| 73 | policy.toString() + " is not supported."); |
| 74 | } |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public ConflictDetectionPolicy getConflictDetectionPolicy() { |
Toshio Koide | d46b66d | 2014-07-21 10:27:27 -0700 | [diff] [blame] | 79 | return conflictDetectionPolicy; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public void addEventListener(EventListener listener) { |
| 84 | // TODO Auto-generated method stub |
| 85 | |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public void removeEventListener(EventListener listener) { |
| 90 | // TODO Auto-generated method stub |
| 91 | |
| 92 | } |
| 93 | } |