ONOS-2456 Added usage metrics to Atomic Counter and Distributed Queue plus refactored the code a bit

Refactored code plus instrumented AtomicValue and DistributedSet

Change-Id: I9c5f7c9f23d530131f15d3c98250ea33238dd2ec
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterBuilder.java b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterBuilder.java
index 3c2e516..e43d7dd 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterBuilder.java
@@ -59,6 +59,14 @@
     AtomicCounterBuilder withRetryOnFailure();
 
     /**
+     * Instantiates Metering service to gather usage and performance metrics.
+     * By default, usage data will be stored.
+     *
+     * @return this AtomicCounterBuilder
+     */
+    AtomicCounterBuilder withMeteringDisabled();
+
+    /**
      * Sets the executor service to use for retrying failed operations.
      * <p>
      * Note: Must be set when retries are enabled
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicValueBuilder.java b/core/api/src/main/java/org/onosproject/store/service/AtomicValueBuilder.java
index 6527b9c..3478ce0 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AtomicValueBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicValueBuilder.java
@@ -60,6 +60,14 @@
     AtomicValueBuilder<V> withPartitionsDisabled();
 
     /**
+     * Instantiates Metering service to gather usage and performance metrics.
+     * By default, usage data will be stored.
+     *
+     * @return this AtomicValueBuilder for method chaining
+     */
+    AtomicValueBuilder<V> withMeteringDisabled();
+
+    /**
      * Builds a AtomicValue based on the configuration options
      * supplied to this builder.
      *
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentMapBuilder.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentMapBuilder.java
index b65cfad..b4251c6 100644
--- a/core/api/src/main/java/org/onosproject/store/service/ConsistentMapBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentMapBuilder.java
@@ -105,6 +105,14 @@
     ConsistentMapBuilder<K, V> withPurgeOnUninstall();
 
     /**
+     * Instantiates Metering service to gather usage and performance metrics.
+     * By default, usage data will be stored.
+     *
+     * @return this ConsistentMapBuilder
+     */
+    ConsistentMapBuilder<K, V> withMeteringDisabled();
+
+    /**
      * Builds an consistent map based on the configuration options
      * supplied to this builder.
      *
diff --git a/core/api/src/main/java/org/onosproject/store/service/DistributedQueueBuilder.java b/core/api/src/main/java/org/onosproject/store/service/DistributedQueueBuilder.java
index f938b64..646dc28 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DistributedQueueBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DistributedQueueBuilder.java
@@ -51,6 +51,14 @@
     DistributedQueueBuilder<E> withSerializer(Serializer serializer);
 
     /**
+     *
+     *
+     * @return this DistributedQueueBuilder for method chaining
+     */
+    DistributedQueueBuilder<E> withMeteringDisabled();
+
+
+    /**
      * Disables persistence of queues entries.
      * <p>
      * When persistence is disabled, a full cluster restart will wipe out all
diff --git a/core/api/src/main/java/org/onosproject/store/service/DistributedSetBuilder.java b/core/api/src/main/java/org/onosproject/store/service/DistributedSetBuilder.java
index 5f4f287..1706c8f 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DistributedSetBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DistributedSetBuilder.java
@@ -92,6 +92,13 @@
     DistributedSetBuilder<E> withPartitionsDisabled();
 
     /**
+     * Instantiate Metrics service to gather usage and performance metrics.
+     * By default usage information is enabled
+     * @return this DistributedSetBuilder
+     */
+    DistributedSetBuilder<E> withMeteringDisabled();
+
+    /**
      * Purges set contents when the application owning the set is uninstalled.
      * <p>
      * When this option is enabled, the caller must provide a applicationId via
diff --git a/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java b/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java
index 1494b8a..8945137 100644
--- a/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java
+++ b/core/api/src/test/java/org/onosproject/store/service/TestConsistentMap.java
@@ -247,6 +247,11 @@
         }
 
         @Override
+        public ConsistentMapBuilder<K, V> withMeteringDisabled() {
+            return this;
+        }
+
+        @Override
         public ConsistentMap<K, V> build() {
             return new TestConsistentMap<>(mapName);
         }