[ONOS-3558] Add AtomicCounterMap to DistributedPrimitive
Change-Id: If2a0af0d48a3aa2c6a20412bf1c232724ace0bcb
diff --git a/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounterMap.java b/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounterMap.java
index 6609fb8..6ac096f 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounterMap.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AsyncAtomicCounterMap.java
@@ -20,7 +20,12 @@
/**
* An async atomic counter map dispenses monotonically increasing values associated with key.
*/
-public interface AsyncAtomicCounterMap<K> {
+public interface AsyncAtomicCounterMap<K> extends DistributedPrimitive {
+
+ @Override
+ default DistributedPrimitive.Type primitiveType() {
+ return DistributedPrimitive.Type.COUNTER_MAP;
+ }
/**
* Increments by one the value currently associated with key, and returns the new value.
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMap.java b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMap.java
index fcb957e..f6ab5d5 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMap.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMap.java
@@ -18,7 +18,12 @@
/**
* Distributed version of com.google.common.util.concurrent.AtomicLongMap.
*/
-public interface AtomicCounterMap<K> {
+public interface AtomicCounterMap<K> extends DistributedPrimitive {
+
+ @Override
+ default DistributedPrimitive.Type primitiveType() {
+ return DistributedPrimitive.Type.COUNTER_MAP;
+ }
/**
* Increments by one the value currently associated with key, and returns the new value.
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMapBuilder.java b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMapBuilder.java
index 436457d..56934f4 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMapBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMapBuilder.java
@@ -15,61 +15,14 @@
*/
package org.onosproject.store.service;
+import org.onosproject.store.primitives.DistributedPrimitiveBuilder;
+
/**
* Builder for AtomicCounterMap.
*/
-public interface AtomicCounterMapBuilder<K> {
-
- /**
- * Sets the name for the atomic counter map.
- * <p>
- * Each atomic counter map is identified by a unique name.
- * </p>
- * <p>
- * Note: This is a mandatory parameter.
- * </p>
- *
- * @param name name of the atomic counter
- * @return this AtomicCounterMapBuilder
- */
- AtomicCounterMapBuilder<K> withName(String name);
-
- /**
- * Creates this counter map on the partition that spans the entire cluster.
- * <p>
- * When partitioning is disabled, the counter state will be
- * ephemeral and does not survive a full cluster restart.
- * </p>
- * <p>
- * Note: By default partitions are enabled.
- * </p>
- * @return this AtomicCounterMapBuilder
- */
- AtomicCounterMapBuilder<K> withPartitionsDisabled();
-
- /**
- * Instantiates Metering service to gather usage and performance metrics.
- * By default, usage data will be stored.
- *
- * @return this AtomicCounterMapBuilder
- */
- AtomicCounterMapBuilder<K> withMeteringDisabled();
-
- /**
- * Builds a AtomicCounterMap based on the configuration options
- * supplied to this builder.
- *
- * @return new AtomicCounterMap
- * @throws java.lang.RuntimeException if a mandatory parameter is missing
- */
- AtomicCounterMap<K> build();
-
- /**
- * Builds a AsyncAtomicCounterMap based on the configuration options
- * supplied to this builder.
- *
- * @return new AsyncAtomicCounterMap
- * @throws java.lang.RuntimeException if a mandatory parameter is missing
- */
- AsyncAtomicCounterMap<K> buildAsyncAtomicCounterMap();
-}
+public abstract class AtomicCounterMapBuilder
+ extends DistributedPrimitiveBuilder<AtomicCounterMapBuilder, AsyncAtomicCounterMap> {
+ public AtomicCounterMapBuilder() {
+ super(DistributedPrimitive.Type.COUNTER_MAP);
+ }
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/store/service/DistributedPrimitive.java b/core/api/src/main/java/org/onosproject/store/service/DistributedPrimitive.java
index 5c93b54..21c494b 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DistributedPrimitive.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DistributedPrimitive.java
@@ -47,7 +47,7 @@
CONSISTENT_MULTIMAP,
/**
- * distributed set.
+ * Distributed set.
*/
SET,
@@ -57,11 +57,16 @@
CONSISTENT_TREEMAP,
/**
- * atomic counter.
+ * Atomic counter.
*/
COUNTER,
/**
+ * Atomic counter map.
+ */
+ COUNTER_MAP,
+
+ /**
* Atomic value.
*/
VALUE,