Refactor: Remove unused methods
Change-Id: Ib31bea1a27b16cdb9556748ecb9f9ab7eb689f3c
diff --git a/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
index a52a843..88c561f 100644
--- a/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
+++ b/core/api/src/main/java/org/onosproject/net/resource/device/DeviceResourceStore.java
@@ -15,45 +15,11 @@
*/
package org.onosproject.net.resource.device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
import org.onosproject.net.intent.IntentId;
import java.util.Set;
public interface DeviceResourceStore {
- /**
- * Returns unallocated ports on the given device.
- *
- * @param deviceId device ID
- * @return set of unallocated ports
- */
- Set<Port> getFreePorts(DeviceId deviceId);
-
- /**
- * Allocates the given ports to the given intent.
- *
- * @param ports set of ports to allocate
- * @param intentId intent ID
- * @return true if allocation was successful, false otherwise
- */
- boolean allocatePorts(Set<Port> ports, IntentId intentId);
-
- /**
- * Returns set of ports allocated for an intent.
- *
- * @param intentId the intent ID
- * @return set of allocated ports
- */
- Set<Port> getAllocations(IntentId intentId);
-
- /**
- * Returns intent allocated to a port.
- *
- * @param port the port
- * @return intent ID allocated to the port
- */
- IntentId getAllocations(Port port);
/**
* Allocates the mapping between the given intents.
@@ -78,12 +44,4 @@
* @param intentId intent ID
*/
void releaseMapping(IntentId intentId);
-
- /**
- * Releases the ports allocated to the given intent.
- *
- * @param intentId intent ID
- * @return true if release was successful, false otherwise
- */
- boolean releasePorts(IntentId intentId);
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
index 3266e96..dcc942c 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDeviceResourceStore.java
@@ -21,7 +21,6 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
-import org.onosproject.net.DeviceId;
import org.onosproject.net.Port;
import org.onosproject.net.device.DeviceService;
import org.onosproject.net.intent.IntentId;
@@ -30,18 +29,13 @@
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.TransactionContext;
-import org.onosproject.store.service.TransactionalMap;
import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
-import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-import static com.google.common.base.Preconditions.checkArgument;
import static org.slf4j.LoggerFactory.getLogger;
-import static com.google.common.base.Preconditions.checkNotNull;
/**
* Store that manages device resources using Copycat-backed TransactionalMaps.
@@ -89,78 +83,6 @@
log.info("Stopped");
}
- private TransactionalMap<Port, IntentId> getPortAllocs(TransactionContext tx) {
- return tx.getTransactionalMap(PORT_ALLOCATIONS, SERIALIZER);
- }
-
- private TransactionalMap<IntentId, Set<Port>> getIntentAllocs(TransactionContext tx) {
- return tx.getTransactionalMap(INTENT_ALLOCATIONS, SERIALIZER);
- }
-
- private TransactionContext getTxContext() {
- return storageService.transactionContextBuilder().build();
- }
-
- @Override
- public Set<Port> getFreePorts(DeviceId deviceId) {
- checkNotNull(deviceId);
-
- Set<Port> freePorts = new HashSet<>();
- for (Port port : deviceService.getPorts(deviceId)) {
- if (!portAllocMap.containsKey(port)) {
- freePorts.add(port);
- }
- }
-
- return freePorts;
- }
-
- @Override
- public boolean allocatePorts(Set<Port> ports, IntentId intentId) {
- checkNotNull(ports);
- checkArgument(ports.size() > 0);
- checkNotNull(intentId);
-
- TransactionContext tx = getTxContext();
- tx.begin();
- try {
- TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx);
- for (Port port : ports) {
- if (portAllocs.putIfAbsent(port, intentId) != null) {
- throw new Exception("Port already allocated " + port.toString());
- }
- }
-
- TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx);
- intentAllocs.put(intentId, ports);
- tx.commit();
- } catch (Exception e) {
- log.error("Exception thrown, rolling back", e);
- tx.abort();
- return false;
- }
-
- return true;
- }
-
- @Override
- public Set<Port> getAllocations(IntentId intentId) {
- if (!intentAllocMap.containsKey(intentId)) {
- Collections.emptySet();
- }
-
- return intentAllocMap.get(intentId).value();
- }
-
- @Override
- public IntentId getAllocations(Port port) {
- if (!portAllocMap.containsKey(port)) {
- return null;
- }
-
- return portAllocMap.get(port).value();
- }
-
@Override
public Set<IntentId> getMapping(IntentId intentId) {
Versioned<Set<IntentId>> result = intentMapping.get(intentId);
@@ -198,28 +120,4 @@
}
}
- @Override
- public boolean releasePorts(IntentId intentId) {
- checkNotNull(intentId);
-
- TransactionContext tx = getTxContext();
- tx.begin();
- try {
- TransactionalMap<IntentId, Set<Port>> intentAllocs = getIntentAllocs(tx);
- Set<Port> ports = intentAllocs.get(intentId);
- intentAllocs.remove(intentId);
-
- TransactionalMap<Port, IntentId> portAllocs = getPortAllocs(tx);
- for (Port port : ports) {
- portAllocs.remove(port);
- }
- tx.commit();
- } catch (Exception e) {
- log.error("Exception thrown, rolling back", e);
- tx.abort();
- return false;
- }
-
- return true;
- }
}