Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.flowmanager; |
| 2 | |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 3 | import net.onrc.onos.api.flowmanager.FlowBatchHandle; |
| 4 | import net.onrc.onos.api.flowmanager.FlowBatchId; |
| 5 | import net.onrc.onos.api.flowmanager.FlowBatchOperation; |
| 6 | import net.onrc.onos.api.flowmanager.FlowBatchState; |
Toshio Koide | 3c84631 | 2014-08-21 19:47:15 -0700 | [diff] [blame] | 7 | import net.onrc.onos.core.util.IdBlockAllocator; |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 8 | |
Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 9 | /** |
| 10 | * Manages the set of flow operations throughout the ONOS instances. |
Toshio Koide | 3c84631 | 2014-08-21 19:47:15 -0700 | [diff] [blame] | 11 | * <p> |
| 12 | * Application can access to this map using {@link FlowBatchHandle}. |
Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 13 | */ |
| 14 | public class FlowOperationMap { |
Toshio Koide | 3c84631 | 2014-08-21 19:47:15 -0700 | [diff] [blame] | 15 | private final FlowBatchIdGeneratorWithIdBlockAllocator flowBatchIdGenerator; |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 16 | |
Toshio Koide | 3c84631 | 2014-08-21 19:47:15 -0700 | [diff] [blame] | 17 | /** |
| 18 | * Creates a driver for the shared flow batch operation map. |
| 19 | * |
| 20 | * @param allocator {@link IdBlockAllocator} to be used for batch IDs |
| 21 | */ |
| 22 | FlowOperationMap(IdBlockAllocator allocator) { |
| 23 | flowBatchIdGenerator = new FlowBatchIdGeneratorWithIdBlockAllocator(allocator); |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 24 | } |
| 25 | |
Toshio Koide | 3c84631 | 2014-08-21 19:47:15 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Adds a flow batch operation to the map. |
| 28 | * |
| 29 | * @param ops the flow batch operation to be added |
| 30 | * @return {@link FlowBatchHandle} handle if succeeded, null otherwise |
| 31 | */ |
| 32 | FlowBatchHandle putBatchOperation(FlowBatchOperation ops) { |
| 33 | FlowBatchId id = flowBatchIdGenerator.getNewId(); |
| 34 | |
| 35 | // TODO: put batch operation to map |
| 36 | |
| 37 | boolean succeeded = false; |
| 38 | |
| 39 | return succeeded ? new FlowBatchHandleImpl(this, id) : null; |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Toshio Koide | 3c84631 | 2014-08-21 19:47:15 -0700 | [diff] [blame] | 42 | /** |
| 43 | * Gets the flow batch operation from the map specified with an ID. |
| 44 | * |
| 45 | * @param id the ID for the operation |
| 46 | * @return the flow batch operation if exists, null otherwise |
| 47 | */ |
| 48 | FlowBatchOperation getBatchOperation(FlowBatchId id) { |
| 49 | // TODO: implement it |
| 50 | return null; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Removes the flow batch operation from the map specified with an ID. |
| 55 | */ |
| 56 | void removeBatchOperation(FlowBatchId id) { |
| 57 | // TODO: implement it |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Gets the state for the flow batch operation specified with an ID. |
| 62 | * |
| 63 | * @param id the ID for the batch operation |
| 64 | * @return the state of the batch operation |
| 65 | */ |
| 66 | FlowBatchState getState(FlowBatchId id) { |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 67 | // TODO implement it |
| 68 | return null; |
| 69 | } |
| 70 | |
Toshio Koide | 3c84631 | 2014-08-21 19:47:15 -0700 | [diff] [blame] | 71 | /** |
| 72 | * Updates the state for the flow batch operation specified with an ID. |
| 73 | * |
| 74 | * @param id the ID for the batch operation |
| 75 | * @param state new state for the batch operation |
| 76 | * @return true if succeeded, false otherwise |
| 77 | */ |
| 78 | boolean setState(FlowBatchId id, FlowBatchState state) { |
| 79 | // TODO: implement it |
Toshio Koide | fc5acc7 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 80 | return false; |
| 81 | } |
Toshio Koide | b8cea26 | 2014-08-12 18:45:46 -0700 | [diff] [blame] | 82 | } |