blob: 0c5be10d55c61ce4680f99efc1f0f26a372bb85d [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;
Toshio Koide025a9152014-07-21 11:00:34 -07008import net.onrc.onos.api.flowmanager.FlowId;
Toshio Koidea03915e2014-07-01 18:39:52 -07009import net.onrc.onos.api.flowmanager.IFlow;
10import 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 */
18public class FlowManagerModule implements IFlowManagerService {
Toshio Koided46b66d2014-07-21 10:27:27 -070019 private ConflictDetectionPolicy conflictDetectionPolicy;
20
21 /**
22 * Constructor.
23 */
24 public FlowManagerModule() {
25 this.conflictDetectionPolicy = ConflictDetectionPolicy.FREE;
26 }
27
Toshio Koidea03915e2014-07-01 18:39:52 -070028 @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 Koide025a9152014-07-21 11:00:34 -070036 public boolean removeFlow(FlowId id) {
Toshio Koidea03915e2014-07-01 18:39:52 -070037 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 Koide025a9152014-07-21 11:00:34 -070050 public IFlow getFlow(FlowId id) {
Toshio Koidea03915e2014-07-01 18:39:52 -070051 // 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 Koided46b66d2014-07-21 10:27:27 -070069 if (policy == ConflictDetectionPolicy.FREE) {
70 conflictDetectionPolicy = policy;
71 } else {
72 throw new UnsupportedOperationException(
73 policy.toString() + " is not supported.");
74 }
Toshio Koidea03915e2014-07-01 18:39:52 -070075 }
76
77 @Override
78 public ConflictDetectionPolicy getConflictDetectionPolicy() {
Toshio Koided46b66d2014-07-21 10:27:27 -070079 return conflictDetectionPolicy;
Toshio Koidea03915e2014-07-01 18:39:52 -070080 }
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}