blob: 65352691819d845e99e7945bc897b90ab32896d9 [file] [log] [blame]
Toshio Koideb8cea262014-08-12 18:45:46 -07001package net.onrc.onos.core.flowmanager;
2
Toshio Koidefc5acc72014-08-12 18:45:46 -07003import net.onrc.onos.api.flowmanager.FlowBatchHandle;
4import net.onrc.onos.api.flowmanager.FlowBatchId;
5import net.onrc.onos.api.flowmanager.FlowBatchOperation;
6import net.onrc.onos.api.flowmanager.FlowBatchState;
Toshio Koide3c846312014-08-21 19:47:15 -07007import net.onrc.onos.core.util.IdBlockAllocator;
Toshio Koidefc5acc72014-08-12 18:45:46 -07008
Toshio Koideb8cea262014-08-12 18:45:46 -07009/**
10 * Manages the set of flow operations throughout the ONOS instances.
Toshio Koide3c846312014-08-21 19:47:15 -070011 * <p>
12 * Application can access to this map using {@link FlowBatchHandle}.
Toshio Koideb8cea262014-08-12 18:45:46 -070013 */
14public class FlowOperationMap {
Toshio Koide3c846312014-08-21 19:47:15 -070015 private final FlowBatchIdGeneratorWithIdBlockAllocator flowBatchIdGenerator;
Toshio Koidefc5acc72014-08-12 18:45:46 -070016
Toshio Koide3c846312014-08-21 19:47:15 -070017 /**
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 Koidefc5acc72014-08-12 18:45:46 -070024 }
25
Toshio Koide3c846312014-08-21 19:47:15 -070026 /**
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 Koidefc5acc72014-08-12 18:45:46 -070040 }
41
Toshio Koide3c846312014-08-21 19:47:15 -070042 /**
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 Koidefc5acc72014-08-12 18:45:46 -070067 // TODO implement it
68 return null;
69 }
70
Toshio Koide3c846312014-08-21 19:47:15 -070071 /**
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 Koidefc5acc72014-08-12 18:45:46 -070080 return false;
81 }
Toshio Koideb8cea262014-08-12 18:45:46 -070082}