Committed by
Gerrit Code Review
Refactor: Remove unused methods
Change-Id: Ib31bea1a27b16cdb9556748ecb9f9ab7eb689f3c
Showing
2 changed files
with
0 additions
and
144 deletions
... | @@ -15,45 +15,11 @@ | ... | @@ -15,45 +15,11 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.resource.device; | 16 | package org.onosproject.net.resource.device; |
17 | 17 | ||
18 | -import org.onosproject.net.DeviceId; | ||
19 | -import org.onosproject.net.Port; | ||
20 | import org.onosproject.net.intent.IntentId; | 18 | import org.onosproject.net.intent.IntentId; |
21 | 19 | ||
22 | import java.util.Set; | 20 | import java.util.Set; |
23 | 21 | ||
24 | public interface DeviceResourceStore { | 22 | public interface DeviceResourceStore { |
25 | - /** | ||
26 | - * Returns unallocated ports on the given device. | ||
27 | - * | ||
28 | - * @param deviceId device ID | ||
29 | - * @return set of unallocated ports | ||
30 | - */ | ||
31 | - Set<Port> getFreePorts(DeviceId deviceId); | ||
32 | - | ||
33 | - /** | ||
34 | - * Allocates the given ports to the given intent. | ||
35 | - * | ||
36 | - * @param ports set of ports to allocate | ||
37 | - * @param intentId intent ID | ||
38 | - * @return true if allocation was successful, false otherwise | ||
39 | - */ | ||
40 | - boolean allocatePorts(Set<Port> ports, IntentId intentId); | ||
41 | - | ||
42 | - /** | ||
43 | - * Returns set of ports allocated for an intent. | ||
44 | - * | ||
45 | - * @param intentId the intent ID | ||
46 | - * @return set of allocated ports | ||
47 | - */ | ||
48 | - Set<Port> getAllocations(IntentId intentId); | ||
49 | - | ||
50 | - /** | ||
51 | - * Returns intent allocated to a port. | ||
52 | - * | ||
53 | - * @param port the port | ||
54 | - * @return intent ID allocated to the port | ||
55 | - */ | ||
56 | - IntentId getAllocations(Port port); | ||
57 | 23 | ||
58 | /** | 24 | /** |
59 | * Allocates the mapping between the given intents. | 25 | * Allocates the mapping between the given intents. |
... | @@ -78,12 +44,4 @@ public interface DeviceResourceStore { | ... | @@ -78,12 +44,4 @@ public interface DeviceResourceStore { |
78 | * @param intentId intent ID | 44 | * @param intentId intent ID |
79 | */ | 45 | */ |
80 | void releaseMapping(IntentId intentId); | 46 | void releaseMapping(IntentId intentId); |
81 | - | ||
82 | - /** | ||
83 | - * Releases the ports allocated to the given intent. | ||
84 | - * | ||
85 | - * @param intentId intent ID | ||
86 | - * @return true if release was successful, false otherwise | ||
87 | - */ | ||
88 | - boolean releasePorts(IntentId intentId); | ||
89 | } | 47 | } | ... | ... |
core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
... | @@ -21,7 +21,6 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -21,7 +21,6 @@ import org.apache.felix.scr.annotations.Deactivate; |
21 | import org.apache.felix.scr.annotations.Reference; | 21 | import org.apache.felix.scr.annotations.Reference; |
22 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
23 | import org.apache.felix.scr.annotations.Service; | 23 | import org.apache.felix.scr.annotations.Service; |
24 | -import org.onosproject.net.DeviceId; | ||
25 | import org.onosproject.net.Port; | 24 | import org.onosproject.net.Port; |
26 | import org.onosproject.net.device.DeviceService; | 25 | import org.onosproject.net.device.DeviceService; |
27 | import org.onosproject.net.intent.IntentId; | 26 | import org.onosproject.net.intent.IntentId; |
... | @@ -30,18 +29,13 @@ import org.onosproject.store.serializers.KryoNamespaces; | ... | @@ -30,18 +29,13 @@ import org.onosproject.store.serializers.KryoNamespaces; |
30 | import org.onosproject.store.service.ConsistentMap; | 29 | import org.onosproject.store.service.ConsistentMap; |
31 | import org.onosproject.store.service.Serializer; | 30 | import org.onosproject.store.service.Serializer; |
32 | import org.onosproject.store.service.StorageService; | 31 | import org.onosproject.store.service.StorageService; |
33 | -import org.onosproject.store.service.TransactionContext; | ||
34 | -import org.onosproject.store.service.TransactionalMap; | ||
35 | import org.onosproject.store.service.Versioned; | 32 | import org.onosproject.store.service.Versioned; |
36 | import org.slf4j.Logger; | 33 | import org.slf4j.Logger; |
37 | 34 | ||
38 | -import java.util.Collections; | ||
39 | import java.util.HashSet; | 35 | import java.util.HashSet; |
40 | import java.util.Set; | 36 | import java.util.Set; |
41 | 37 | ||
42 | -import static com.google.common.base.Preconditions.checkArgument; | ||
43 | import static org.slf4j.LoggerFactory.getLogger; | 38 | import static org.slf4j.LoggerFactory.getLogger; |
44 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
45 | 39 | ||
46 | /** | 40 | /** |
47 | * Store that manages device resources using Copycat-backed TransactionalMaps. | 41 | * Store that manages device resources using Copycat-backed TransactionalMaps. |
... | @@ -89,78 +83,6 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { | ... | @@ -89,78 +83,6 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { |
89 | log.info("Stopped"); | 83 | log.info("Stopped"); |
90 | } | 84 | } |
91 | 85 | ||
92 | - private TransactionalMap<Port, IntentId> getPortAllocs(TransactionContext tx) { | ||
93 | - return tx.getTransactionalMap(PORT_ALLOCATIONS, SERIALIZER); | ||
94 | - } | ||
95 | - | ||
96 | - private TransactionalMap<IntentId, Set<Port>> getIntentAllocs(TransactionContext tx) { | ||
97 | - return tx.getTransactionalMap(INTENT_ALLOCATIONS, SERIALIZER); | ||
98 | - } | ||
99 | - | ||
100 | - private TransactionContext getTxContext() { | ||
101 | - return storageService.transactionContextBuilder().build(); | ||
102 | - } | ||
103 | - | ||
104 | - @Override | ||
105 | - public Set<Port> getFreePorts(DeviceId deviceId) { | ||
106 | - checkNotNull(deviceId); | ||
107 | - | ||
108 | - Set<Port> freePorts = new HashSet<>(); | ||
109 | - for (Port port : deviceService.getPorts(deviceId)) { | ||
110 | - if (!portAllocMap.containsKey(port)) { | ||
111 | - freePorts.add(port); | ||
112 | - } | ||
113 | - } | ||
114 | - | ||
115 | - return freePorts; | ||
116 | - } | ||
117 | - | ||
118 | - @Override | ||
119 | - public boolean allocatePorts(Set<Port> ports, IntentId intentId) { | ||
120 | - checkNotNull(ports); | ||
121 | - checkArgument(ports.size() > 0); | ||
122 | - checkNotNull(intentId); | ||
123 | - | ||
124 | - TransactionContext tx = getTxContext(); | ||
125 | - tx.begin(); | ||
126 | - try { | ||
127 | - TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx); | ||
128 | - for (Port port : ports) { | ||
129 | - if (portAllocs.putIfAbsent(port, intentId) != null) { | ||
130 | - throw new Exception("Port already allocated " + port.toString()); | ||
131 | - } | ||
132 | - } | ||
133 | - | ||
134 | - TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx); | ||
135 | - intentAllocs.put(intentId, ports); | ||
136 | - tx.commit(); | ||
137 | - } catch (Exception e) { | ||
138 | - log.error("Exception thrown, rolling back", e); | ||
139 | - tx.abort(); | ||
140 | - return false; | ||
141 | - } | ||
142 | - | ||
143 | - return true; | ||
144 | - } | ||
145 | - | ||
146 | - @Override | ||
147 | - public Set<Port> getAllocations(IntentId intentId) { | ||
148 | - if (!intentAllocMap.containsKey(intentId)) { | ||
149 | - Collections.emptySet(); | ||
150 | - } | ||
151 | - | ||
152 | - return intentAllocMap.get(intentId).value(); | ||
153 | - } | ||
154 | - | ||
155 | - @Override | ||
156 | - public IntentId getAllocations(Port port) { | ||
157 | - if (!portAllocMap.containsKey(port)) { | ||
158 | - return null; | ||
159 | - } | ||
160 | - | ||
161 | - return portAllocMap.get(port).value(); | ||
162 | - } | ||
163 | - | ||
164 | @Override | 86 | @Override |
165 | public Set<IntentId> getMapping(IntentId intentId) { | 87 | public Set<IntentId> getMapping(IntentId intentId) { |
166 | Versioned<Set<IntentId>> result = intentMapping.get(intentId); | 88 | Versioned<Set<IntentId>> result = intentMapping.get(intentId); |
... | @@ -198,28 +120,4 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { | ... | @@ -198,28 +120,4 @@ public class ConsistentDeviceResourceStore implements DeviceResourceStore { |
198 | } | 120 | } |
199 | } | 121 | } |
200 | 122 | ||
201 | - @Override | ||
202 | - public boolean releasePorts(IntentId intentId) { | ||
203 | - checkNotNull(intentId); | ||
204 | - | ||
205 | - TransactionContext tx = getTxContext(); | ||
206 | - tx.begin(); | ||
207 | - try { | ||
208 | - TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx); | ||
209 | - Set<Port> ports = intentAllocs.get(intentId); | ||
210 | - intentAllocs.remove(intentId); | ||
211 | - | ||
212 | - TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx); | ||
213 | - for (Port port : ports) { | ||
214 | - portAllocs.remove(port); | ||
215 | - } | ||
216 | - tx.commit(); | ||
217 | - } catch (Exception e) { | ||
218 | - log.error("Exception thrown, rolling back", e); | ||
219 | - tx.abort(); | ||
220 | - return false; | ||
221 | - } | ||
222 | - | ||
223 | - return true; | ||
224 | - } | ||
225 | } | 123 | } | ... | ... |
-
Please register or login to post a comment