Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.matchaction; |
| 2 | |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 3 | import java.util.Collections; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 4 | import java.util.EventListener; |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 5 | import java.util.HashSet; |
| 6 | import java.util.List; |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 7 | import java.util.Set; |
Toshio Koide | 77ec998 | 2014-08-27 16:57:43 -0700 | [diff] [blame] | 8 | |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 9 | import net.onrc.onos.api.flowmanager.ConflictDetectionPolicy; |
| 10 | |
| 11 | /** |
| 12 | * Manages Match-Action entries. |
| 13 | * <p> |
| 14 | * TODO: Make all methods thread-safe |
| 15 | */ |
Toshio Koide | 77ec998 | 2014-08-27 16:57:43 -0700 | [diff] [blame] | 16 | public class MatchActionModule implements MatchActionFloodlightService { |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 17 | |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 18 | 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 Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 31 | @Override |
| 32 | public boolean addMatchAction(MatchAction matchAction) { |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 33 | return false; |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | @Override |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 37 | public Set<MatchAction> getMatchActions() { |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 38 | return Collections.unmodifiableSet(currentOperations); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | @Override |
Brian O'Connor | dee2e6b | 2014-08-12 11:34:51 -0700 | [diff] [blame] | 42 | public boolean executeOperations(final MatchActionOperations operations) { |
Ray Milkey | c127a5a | 2014-08-20 11:22:12 -0700 | [diff] [blame] | 43 | return processMatchActionEntries(operations.getOperations()); |
Toshio Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 44 | } |
| 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 Koide | 77ec998 | 2014-08-27 16:57:43 -0700 | [diff] [blame] | 59 | 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 Koide | a03915e | 2014-07-01 18:39:52 -0700 | [diff] [blame] | 73 | 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 | } |