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