[SDFAB-500][SDFAB-499] Implement user defined index mode for the meter service

- Introduce a boolean to control the meter service modes
- User defined mode does not provide any coordination to the apps
- Only one mode can be active at time
- In addition some sanity checks are peformed by the meter service
- Update existing unit tests and add new ones to test the new behaviors
- Initial clean up of the meters subsystems

Change-Id: I61500b794f27e94abd11637c84bce0dbb2e073f3
diff --git a/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java b/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java
index 811b418..7f4de4b 100644
--- a/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java
+++ b/core/api/src/main/java/org/onosproject/net/meter/MeterStore.java
@@ -86,16 +86,6 @@
     MeterStoreResult deleteMeterFeatures(Collection<MeterFeatures> meterfeatures);
 
     /**
-     * Updates a meter whose meter id is the same as the passed meter.
-     *
-     * @param meter a new meter
-     * @return a future indicating the result of the store operation
-     * @deprecated in onos-2.5 replaced by {@link #addOrUpdateMeter(Meter)}
-     */
-    @Deprecated
-    CompletableFuture<MeterStoreResult> updateMeter(Meter meter);
-
-    /**
      * Updates a given meter's state with the provided state.
      *
      * @param meter a meter
@@ -200,10 +190,20 @@
      * This API is typically used when the device is offline.
      *
      * @param deviceId the device id
+     * @deprecated in onos-2.5, replaced by {@link #purgeMeters(DeviceId)}
      */
+    @Deprecated
     void purgeMeter(DeviceId deviceId);
 
     /**
+     * Removes all meters of given device from store.
+     * This API is typically used when the device is offline.
+     *
+     * @param deviceId the device id
+     */
+    void purgeMeters(DeviceId deviceId);
+
+    /**
      * Removes all meters of given device and for the given application from store.
      * This API is typically used when the device is offline.
      *
@@ -212,4 +212,14 @@
      */
     void purgeMeters(DeviceId deviceId, ApplicationId appId);
 
+    /**
+     * Enables/disables user defined index mode for the store. In this mode users
+     * can provide an index for the meter. Store may reject switching mode requests
+     * at run time if meters were already allocated.
+     *
+     * @param enable to enable/disable the user defined index mode.
+     * @return true if user defined index mode is enabled. False otherwise.
+     */
+    boolean userDefinedIndexMode(boolean enable);
+
 }