blob: 78e528ce872380a333dfbc0d5aeda1cc8ddae05a [file] [log] [blame]
Toshio Koidea03915e2014-07-01 18:39:52 -07001package net.onrc.onos.core.matchaction;
2
Ray Milkeyc127a5a2014-08-20 11:22:12 -07003import java.util.Collections;
Toshio Koidea03915e2014-07-01 18:39:52 -07004import java.util.EventListener;
Ray Milkeyc127a5a2014-08-20 11:22:12 -07005import java.util.HashSet;
6import java.util.List;
Brian O'Connordee2e6b2014-08-12 11:34:51 -07007import java.util.Set;
Toshio Koide77ec9982014-08-27 16:57:43 -07008
Toshio Koidea03915e2014-07-01 18:39:52 -07009import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy;
10
11/**
12 * Manages Match-Action entries.
13 * <p>
14 * TODO: Make all methods thread-safe
15 */
Toshio Koide77ec9982014-08-27 16:57:43 -070016public class MatchActionModule implements MatchActionFloodlightService {
Toshio Koidea03915e2014-07-01 18:39:52 -070017
Ray Milkeyc127a5a2014-08-20 11:22:12 -070018 private final HashSet<MatchAction> currentOperations = new HashSet<>();
19
20 private boolean processMatchActionEntries(
21 final List<MatchActionOperationEntry> entries) {
22 int successfulOperations = 0;
23 for (final MatchActionOperationEntry entry : entries) {
24 if (currentOperations.add(entry.getTarget())) {
25 successfulOperations++;
26 }
27 }
28 return entries.size() == successfulOperations;
29 }
30
Toshio Koidea03915e2014-07-01 18:39:52 -070031 @Override
32 public boolean addMatchAction(MatchAction matchAction) {
Brian O'Connordee2e6b2014-08-12 11:34:51 -070033 return false;
Toshio Koidea03915e2014-07-01 18:39:52 -070034 }
35
36 @Override
Brian O'Connordee2e6b2014-08-12 11:34:51 -070037 public Set<MatchAction> getMatchActions() {
Ray Milkeyc127a5a2014-08-20 11:22:12 -070038 return Collections.unmodifiableSet(currentOperations);
Toshio Koidea03915e2014-07-01 18:39:52 -070039 }
40
41 @Override
Brian O'Connordee2e6b2014-08-12 11:34:51 -070042 public boolean executeOperations(final MatchActionOperations operations) {
Ray Milkeyc127a5a2014-08-20 11:22:12 -070043 return processMatchActionEntries(operations.getOperations());
Toshio Koidea03915e2014-07-01 18:39:52 -070044 }
45
46 @Override
47 public void setConflictDetectionPolicy(ConflictDetectionPolicy policy) {
48 // TODO Auto-generated method stub
49
50 }
51
52 @Override
53 public ConflictDetectionPolicy getConflictDetectionPolicy() {
54 // TODO Auto-generated method stub
55 return null;
56 }
57
58 @Override
Toshio Koide77ec9982014-08-27 16:57:43 -070059 public MatchActionIdGenerator getMatchActionIdGenerator() {
60 // TODO Auto-generated method stub
61 // use MatchActionIdGeneratorWithIdBlockAllocator.
62 return null;
63 }
64
65 @Override
66 public MatchActionOperationsIdGenerator getMatchActionOperationsIdGenerator() {
67 // TODO Auto-generated method stub
68 // use MatchActionOperationsIdGeneratorWithIdBlockAllocator.
69 return null;
70 }
71
72 @Override
Toshio Koidea03915e2014-07-01 18:39:52 -070073 public void addEventListener(EventListener listener) {
74 // TODO Auto-generated method stub
75
76 }
77
78 @Override
79 public void removeEventListener(EventListener listener) {
80 // TODO Auto-generated method stub
81
82 }
83}