Committed by
Gerrit Code Review
Refactor: Remove intermediate layer just delegating to DeviceResourceStore
Change-Id: Ie46298311e889a737c4c2ecaefa09ba1bc13d547
Showing
4 changed files
with
7 additions
and
128 deletions
| ... | @@ -46,7 +46,7 @@ import org.onosproject.net.intent.OpticalCircuitIntent; | ... | @@ -46,7 +46,7 @@ import org.onosproject.net.intent.OpticalCircuitIntent; |
| 46 | import org.onosproject.net.intent.OpticalConnectivityIntent; | 46 | import org.onosproject.net.intent.OpticalConnectivityIntent; |
| 47 | import org.onosproject.net.intent.PointToPointIntent; | 47 | import org.onosproject.net.intent.PointToPointIntent; |
| 48 | import org.onosproject.net.newresource.ResourceService; | 48 | import org.onosproject.net.newresource.ResourceService; |
| 49 | -import org.onosproject.net.resource.device.DeviceResourceService; | 49 | +import org.onosproject.net.resource.device.DeviceResourceStore; |
| 50 | import org.onosproject.net.resource.link.LinkResourceAllocations; | 50 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
| 51 | import org.onosproject.net.resource.link.LinkResourceService; | 51 | import org.onosproject.net.resource.link.LinkResourceService; |
| 52 | import org.onosproject.net.topology.LinkWeight; | 52 | import org.onosproject.net.topology.LinkWeight; |
| ... | @@ -98,7 +98,7 @@ public class OpticalPathProvisioner { | ... | @@ -98,7 +98,7 @@ public class OpticalPathProvisioner { |
| 98 | protected DeviceService deviceService; | 98 | protected DeviceService deviceService; |
| 99 | 99 | ||
| 100 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 100 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 101 | - protected DeviceResourceService deviceResourceService; | 101 | + protected DeviceResourceStore deviceResourceStore; |
| 102 | 102 | ||
| 103 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 103 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 104 | protected LinkResourceService linkResourceService; | 104 | protected LinkResourceService linkResourceService; |
| ... | @@ -385,7 +385,7 @@ public class OpticalPathProvisioner { | ... | @@ -385,7 +385,7 @@ public class OpticalPathProvisioner { |
| 385 | } | 385 | } |
| 386 | } else if (intent instanceof OpticalCircuitIntent) { | 386 | } else if (intent instanceof OpticalCircuitIntent) { |
| 387 | resourceService.release(intent.id()); | 387 | resourceService.release(intent.id()); |
| 388 | - deviceResourceService.releaseMapping(intent.id()); | 388 | + deviceResourceStore.releaseMapping(intent.id()); |
| 389 | if (lra != null) { | 389 | if (lra != null) { |
| 390 | linkResourceService.releaseResources(lra); | 390 | linkResourceService.releaseResources(lra); |
| 391 | } | 391 | } | ... | ... |
core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceService.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.net.resource.device; | ||
| 17 | - | ||
| 18 | -import com.google.common.annotations.Beta; | ||
| 19 | -import org.onosproject.net.intent.IntentId; | ||
| 20 | - | ||
| 21 | -import java.util.Set; | ||
| 22 | - | ||
| 23 | -/** | ||
| 24 | - * Service for providing device resources. | ||
| 25 | - */ | ||
| 26 | -@Beta | ||
| 27 | -public interface DeviceResourceService { | ||
| 28 | - | ||
| 29 | - /** | ||
| 30 | - * Request a mapping between the given intents. | ||
| 31 | - * | ||
| 32 | - * @param keyIntentId the key intent ID | ||
| 33 | - * @param valIntentId the value intent ID | ||
| 34 | - * @return true if mapping was successful, false otherwise | ||
| 35 | - */ | ||
| 36 | - boolean requestMapping(IntentId keyIntentId, IntentId valIntentId); | ||
| 37 | - | ||
| 38 | - /** | ||
| 39 | - * Returns the intents mapped to a lower intent. | ||
| 40 | - * | ||
| 41 | - * @param intentId the intent ID | ||
| 42 | - * @return the set of intent IDs | ||
| 43 | - */ | ||
| 44 | - Set<IntentId> getMapping(IntentId intentId); | ||
| 45 | - | ||
| 46 | - /** | ||
| 47 | - * Release mapping of given intent. | ||
| 48 | - * | ||
| 49 | - * @param intentId intent ID | ||
| 50 | - */ | ||
| 51 | - void releaseMapping(IntentId intentId); | ||
| 52 | -} |
| ... | @@ -52,7 +52,7 @@ import org.onosproject.net.intent.impl.IntentCompilationException; | ... | @@ -52,7 +52,7 @@ import org.onosproject.net.intent.impl.IntentCompilationException; |
| 52 | import org.onosproject.net.newresource.ResourceAllocation; | 52 | import org.onosproject.net.newresource.ResourceAllocation; |
| 53 | import org.onosproject.net.newresource.ResourcePath; | 53 | import org.onosproject.net.newresource.ResourcePath; |
| 54 | import org.onosproject.net.newresource.ResourceService; | 54 | import org.onosproject.net.newresource.ResourceService; |
| 55 | -import org.onosproject.net.resource.device.DeviceResourceService; | 55 | +import org.onosproject.net.resource.device.DeviceResourceStore; |
| 56 | import org.onosproject.net.resource.link.LinkResourceAllocations; | 56 | import org.onosproject.net.resource.link.LinkResourceAllocations; |
| 57 | import org.osgi.service.component.ComponentContext; | 57 | import org.osgi.service.component.ComponentContext; |
| 58 | import org.slf4j.Logger; | 58 | import org.slf4j.Logger; |
| ... | @@ -98,7 +98,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -98,7 +98,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 98 | protected ResourceService resourceService; | 98 | protected ResourceService resourceService; |
| 99 | 99 | ||
| 100 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 100 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 101 | - protected DeviceResourceService deviceResourceService; | 101 | + protected DeviceResourceStore deviceResourceStore; |
| 102 | 102 | ||
| 103 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 103 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 104 | protected IntentService intentService; | 104 | protected IntentService intentService; |
| ... | @@ -208,7 +208,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -208,7 +208,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 208 | circuitIntent = new FlowRuleIntent(appId, rules, intent.resources()); | 208 | circuitIntent = new FlowRuleIntent(appId, rules, intent.resources()); |
| 209 | 209 | ||
| 210 | // Save circuit to connectivity intent mapping | 210 | // Save circuit to connectivity intent mapping |
| 211 | - deviceResourceService.requestMapping(connIntent.id(), intent.id()); | 211 | + deviceResourceStore.allocateMapping(connIntent.id(), intent.id()); |
| 212 | intents.add(circuitIntent); | 212 | intents.add(circuitIntent); |
| 213 | 213 | ||
| 214 | return intents; | 214 | return intents; |
| ... | @@ -226,7 +226,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu | ... | @@ -226,7 +226,7 @@ public class OpticalCircuitIntentCompiler implements IntentCompiler<OpticalCircu |
| 226 | return true; | 226 | return true; |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | - Set<IntentId> mapping = deviceResourceService.getMapping(resource); | 229 | + Set<IntentId> mapping = deviceResourceStore.getMapping(resource); |
| 230 | 230 | ||
| 231 | if (mapping == null) { | 231 | if (mapping == null) { |
| 232 | return true; | 232 | return true; | ... | ... |
core/net/src/main/java/org/onosproject/net/resource/impl/DeviceResourceManager.java
deleted
100644 → 0
| 1 | -/* | ||
| 2 | - * Copyright 2015 Open Networking Laboratory | ||
| 3 | - * | ||
| 4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | - * you may not use this file except in compliance with the License. | ||
| 6 | - * You may obtain a copy of the License at | ||
| 7 | - * | ||
| 8 | - * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | - * | ||
| 10 | - * Unless required by applicable law or agreed to in writing, software | ||
| 11 | - * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | - * See the License for the specific language governing permissions and | ||
| 14 | - * limitations under the License. | ||
| 15 | - */ | ||
| 16 | -package org.onosproject.net.resource.impl; | ||
| 17 | - | ||
| 18 | -import org.apache.felix.scr.annotations.Activate; | ||
| 19 | -import org.apache.felix.scr.annotations.Component; | ||
| 20 | -import org.apache.felix.scr.annotations.Deactivate; | ||
| 21 | -import org.apache.felix.scr.annotations.Reference; | ||
| 22 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
| 23 | -import org.apache.felix.scr.annotations.Service; | ||
| 24 | -import org.onosproject.net.intent.IntentId; | ||
| 25 | -import org.onosproject.net.resource.device.DeviceResourceService; | ||
| 26 | -import org.onosproject.net.resource.device.DeviceResourceStore; | ||
| 27 | -import org.slf4j.Logger; | ||
| 28 | - | ||
| 29 | -import java.util.Set; | ||
| 30 | - | ||
| 31 | -import static org.slf4j.LoggerFactory.getLogger; | ||
| 32 | - | ||
| 33 | -/** | ||
| 34 | - * Provides basic implementation of device resources allocation. | ||
| 35 | - */ | ||
| 36 | -@Component(immediate = true) | ||
| 37 | -@Service | ||
| 38 | -public class DeviceResourceManager implements DeviceResourceService { | ||
| 39 | - | ||
| 40 | - private final Logger log = getLogger(getClass()); | ||
| 41 | - | ||
| 42 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 43 | - private DeviceResourceStore store; | ||
| 44 | - | ||
| 45 | - @Activate | ||
| 46 | - public void activate() { | ||
| 47 | - log.info("Started"); | ||
| 48 | - } | ||
| 49 | - | ||
| 50 | - @Deactivate | ||
| 51 | - public void deactivate() { | ||
| 52 | - log.info("Stopped"); | ||
| 53 | - } | ||
| 54 | - | ||
| 55 | - @Override | ||
| 56 | - public void releaseMapping(IntentId intentId) { | ||
| 57 | - store.releaseMapping(intentId); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - @Override | ||
| 61 | - public boolean requestMapping(IntentId keyIntentId, IntentId valIntentId) { | ||
| 62 | - return store.allocateMapping(keyIntentId, valIntentId); | ||
| 63 | - } | ||
| 64 | - | ||
| 65 | - @Override | ||
| 66 | - public Set<IntentId> getMapping(IntentId intentId) { | ||
| 67 | - return store.getMapping(intentId); | ||
| 68 | - } | ||
| 69 | -} |
-
Please register or login to post a comment