mirror of
https://github.com/opennetworkinglab/onos.git
synced 2025-11-02 17:21:05 +01:00
Refactor: extract the same procedures
Change-Id: If28960f4e9fddc3276091fd04e2b624e6168dc5c
This commit is contained in:
parent
d4712e2aac
commit
171a9380a2
@ -268,21 +268,18 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
|
||||
tx.getTransactionalMap(CONTINUOUS_CONSUMER_MAP, SERIALIZER);
|
||||
|
||||
for (Resource resource: resources) {
|
||||
if (resource instanceof DiscreteResource) {
|
||||
if (!lookup(childTxMap, resource.id()).isPresent()) {
|
||||
return abortTransaction(tx);
|
||||
}
|
||||
// if the resource is not registered, then abort
|
||||
Optional<Resource> lookedUp = lookup(childTxMap, resource.id());
|
||||
if (!lookedUp.isPresent()) {
|
||||
return abortTransaction(tx);
|
||||
}
|
||||
|
||||
if (resource instanceof DiscreteResource) {
|
||||
ResourceConsumer oldValue = discreteConsumerTxMap.put(((DiscreteResource) resource).id(), consumer);
|
||||
if (oldValue != null) {
|
||||
return abortTransaction(tx);
|
||||
}
|
||||
} else if (resource instanceof ContinuousResource) {
|
||||
Optional<Resource> lookedUp = lookup(childTxMap, resource.id());
|
||||
if (!lookedUp.isPresent()) {
|
||||
return abortTransaction(tx);
|
||||
}
|
||||
|
||||
// Down cast: this must be safe as ContinuousResource is associated with ContinuousResourceId
|
||||
ContinuousResource continuous = (ContinuousResource) lookedUp.get();
|
||||
ContinuousResourceAllocation allocations = continuousConsumerTxMap.get(continuous.id());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user