[ONOS-7551] Support primitive revisions for upgrades
Change-Id: Ib56e10f06ab9abedd176cdd84add6cbf4e3d4c50
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveBuilder.java b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveBuilder.java
index 2339926..c091d98 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveBuilder.java
@@ -15,168 +15,18 @@
*/
package org.onosproject.store.primitives;
-import org.onosproject.core.ApplicationId;
import org.onosproject.store.service.DistributedPrimitive;
-import org.onosproject.store.service.Serializer;
/**
* Abstract builder for distributed primitives.
*
* @param <T> distributed primitive type
*/
-public abstract class DistributedPrimitiveBuilder<B extends DistributedPrimitiveBuilder<B, T>,
- T extends DistributedPrimitive> {
-
- private final DistributedPrimitive.Type type;
- private String name;
- private ApplicationId applicationId;
- private Serializer serializer;
- private boolean partitionsDisabled = false;
- private boolean meteringDisabled = false;
- private boolean readOnly = false;
- private boolean relaxedReadConsistency = false;
-
- public DistributedPrimitiveBuilder(DistributedPrimitive.Type type) {
- this.type = type;
- }
-
- /**
- * Sets the primitive name.
- *
- * @param name primitive name
- * @return this builder
- */
- public B withName(String name) {
- this.name = name;
- return (B) this;
- }
-
- /**
- * Sets the serializer to use for transcoding info held in the primitive.
- *
- * @param serializer serializer
- * @return this builder
- */
- public B withSerializer(Serializer serializer) {
- this.serializer = serializer;
- return (B) this;
- }
-
- /**
- * Sets the application id that owns this primitive.
- *
- * @param applicationId application identifier
- * @return this builder
- */
- public B withApplicationId(ApplicationId applicationId) {
- this.applicationId = applicationId;
- return (B) this;
- }
-
- /**
- * Disables recording usage stats for this primitive.
- * @deprecated usage of this method is discouraged for most common scenarios.
- * @return this builder
- */
- @Deprecated
- public B withMeteringDisabled() {
- this.meteringDisabled = true;
- return (B) this;
- }
-
- /**
- * Disables state changing operations on the returned distributed primitive.
- * @return this builder
- */
- public B withUpdatesDisabled() {
- this.readOnly = true;
- return (B) this;
- }
-
- /**
- * Turns on relaxed consistency for read operations.
- * @return this builder
- */
- public B withRelaxedReadConsistency() {
- this.relaxedReadConsistency = true;
- return (B) this;
- }
-
- /**
- * Returns if metering is enabled.
- *
- * @return {@code true} if yes; {@code false} otherwise
- */
- public final boolean meteringEnabled() {
- return !meteringDisabled;
- }
-
- /**
- * Returns if partitions are disabled.
- *
- * @return {@code true} if yes; {@code false} otherwise
- */
- public final boolean partitionsDisabled() {
- return partitionsDisabled;
- }
-
- /**
- * Returns if updates are disabled.
- *
- * @return {@code true} if yes; {@code false} otherwise
- */
- public final boolean readOnly() {
- return readOnly;
- }
-
- /**
- * Returns if consistency is relaxed for read operations.
- *
- * @return {@code true} if yes; {@code false} otherwise
- */
- public final boolean relaxedReadConsistency() {
- return relaxedReadConsistency;
- }
-
- /**
- * Returns the serializer.
- *
- * @return serializer
- */
- public final Serializer serializer() {
- return serializer;
- }
-
- /**
- * Returns the application identifier.
- *
- * @return application id
- */
- public final ApplicationId applicationId() {
- return applicationId;
- }
-
- /**
- * Returns the name of the primitive.
- *
- * @return primitive name
- */
- public final String name() {
- return name;
- }
-
- /**
- * Returns the primitive type.
- *
- * @return primitive type
- */
- public final DistributedPrimitive.Type type() {
- return type;
- }
+public interface DistributedPrimitiveBuilder<T extends DistributedPrimitive> {
/**
* Constructs an instance of the distributed primitive.
* @return distributed primitive
*/
- public abstract T build();
+ T build();
}
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveCreator.java b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveCreator.java
index 1e68bdb..5fa88a7 100644
--- a/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveCreator.java
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveCreator.java
@@ -29,9 +29,21 @@
import org.onosproject.store.service.AsyncDistributedSet;
import org.onosproject.store.service.AsyncDocumentTree;
import org.onosproject.store.service.AsyncLeaderElector;
+import org.onosproject.store.service.AtomicCounterMapOptions;
+import org.onosproject.store.service.AtomicCounterOptions;
+import org.onosproject.store.service.AtomicIdGeneratorOptions;
+import org.onosproject.store.service.AtomicValueOptions;
+import org.onosproject.store.service.ConsistentMapOptions;
+import org.onosproject.store.service.ConsistentMultimapOptions;
+import org.onosproject.store.service.ConsistentTreeMapOptions;
+import org.onosproject.store.service.DistributedLockOptions;
+import org.onosproject.store.service.DistributedSetOptions;
+import org.onosproject.store.service.DocumentTreeOptions;
+import org.onosproject.store.service.LeaderElectorOptions;
import org.onosproject.store.service.Ordering;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.WorkQueue;
+import org.onosproject.store.service.WorkQueueOptions;
import static org.onosproject.store.service.DistributedPrimitive.DEFAULT_OPERATION_TIMEOUT_MILLIS;
@@ -48,8 +60,23 @@
* @param <K> key type
* @param <V> value type
* @return map
+ * @deprecated in Nightingale Release (1.13)
*/
- <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(String name, Serializer serializer);
+ @Deprecated
+ default <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(String name, Serializer serializer) {
+ return newAsyncConsistentMap((ConsistentMapOptions) new ConsistentMapOptions() {
+ }.withName(name).withSerializer(serializer));
+ }
+
+ /**
+ * Creates a new {@code AsyncConsistentMap}.
+ *
+ * @param options map options
+ * @param <K> key type
+ * @param <V> value type
+ * @return map
+ */
+ <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(ConsistentMapOptions options);
/**
* Creates a new {@code AsyncConsistentTreeMap}.
@@ -58,8 +85,22 @@
* @param serializer serializer to use for serializing/deserializing map entries
* @param <V> value type
* @return distributedTreeMap
+ * @deprecated in Nightingale Release (1.13)
*/
- <V> AsyncConsistentTreeMap<V> newAsyncConsistentTreeMap(String name, Serializer serializer);
+ @Deprecated
+ default <V> AsyncConsistentTreeMap<V> newAsyncConsistentTreeMap(String name, Serializer serializer) {
+ return newAsyncConsistentTreeMap((ConsistentTreeMapOptions) new ConsistentTreeMapOptions() {
+ }.withName(name).withSerializer(serializer));
+ }
+
+ /**
+ * Creates a new {@code AsyncConsistentTreeMap}.
+ *
+ * @param options tree map options
+ * @param <V> value type
+ * @return distributedTreeMap
+ */
+ <V> AsyncConsistentTreeMap<V> newAsyncConsistentTreeMap(ConsistentTreeMapOptions options);
/**
* Creates a new set backed {@code AsyncConsistentMultimap}.
@@ -69,8 +110,23 @@
* @param <K> key type
* @param <V> value type
* @return set backed distributedMultimap
+ * @deprecated in Nightingale Release (1.13)
*/
- <K, V> AsyncConsistentMultimap<K, V> newAsyncConsistentSetMultimap(String name, Serializer serializer);
+ @Deprecated
+ default <K, V> AsyncConsistentMultimap<K, V> newAsyncConsistentSetMultimap(String name, Serializer serializer) {
+ return newAsyncConsistentSetMultimap((ConsistentMultimapOptions) new ConsistentMultimapOptions() {
+ }.withName(name).withSerializer(serializer));
+ }
+
+ /**
+ * Creates a new set backed {@code AsyncConsistentMultimap}.
+ *
+ * @param options multimap options
+ * @param <K> key type
+ * @param <V> value type
+ * @return set backed distributedMultimap
+ */
+ <K, V> AsyncConsistentMultimap<K, V> newAsyncConsistentSetMultimap(ConsistentMultimapOptions options);
/**
* Creates a new {@code AsyncAtomicCounterMap}.
@@ -79,24 +135,64 @@
* @param serializer serializer to use for serializing/deserializing keys
* @param <K> key type
* @return atomic counter map
+ * @deprecated in Nightingale Release (1.13)
*/
- <K> AsyncAtomicCounterMap<K> newAsyncAtomicCounterMap(String name, Serializer serializer);
+ @Deprecated
+ default <K> AsyncAtomicCounterMap<K> newAsyncAtomicCounterMap(String name, Serializer serializer) {
+ return newAsyncAtomicCounterMap((AtomicCounterMapOptions) new AtomicCounterMapOptions() {
+ }.withName(name).withSerializer(serializer));
+ }
+
+ /**
+ * Creates a new {@code AsyncAtomicCounterMap}.
+ *
+ * @param options counter map options
+ * @param <K> key type
+ * @return atomic counter map
+ */
+ <K> AsyncAtomicCounterMap<K> newAsyncAtomicCounterMap(AtomicCounterMapOptions options);
/**
* Creates a new {@code AsyncAtomicCounter}.
*
* @param name counter name
* @return counter
+ * @deprecated in Nightingale Release (1.13)
*/
- AsyncAtomicCounter newAsyncCounter(String name);
+ @Deprecated
+ default AsyncAtomicCounter newAsyncCounter(String name) {
+ return newAsyncCounter((AtomicCounterOptions) new AtomicCounterOptions() {
+ }.withName(name));
+ }
+
+ /**
+ * Creates a new {@code AsyncAtomicCounter}.
+ *
+ * @param options counter options
+ * @return counter
+ */
+ AsyncAtomicCounter newAsyncCounter(AtomicCounterOptions options);
/**
* Creates a new {@code AsyncAtomixIdGenerator}.
*
* @param name ID generator name
* @return ID generator
+ * @deprecated in Nightingale Release (1.13)
*/
- AsyncAtomicIdGenerator newAsyncIdGenerator(String name);
+ @Deprecated
+ default AsyncAtomicIdGenerator newAsyncIdGenerator(String name) {
+ return newAsyncIdGenerator((AtomicIdGeneratorOptions) new AtomicIdGeneratorOptions() {
+ }.withName(name));
+ }
+
+ /**
+ * Creates a new {@code AsyncAtomixIdGenerator}.
+ *
+ * @param options ID generator options
+ * @return ID generator
+ */
+ AsyncAtomicIdGenerator newAsyncIdGenerator(AtomicIdGeneratorOptions options);
/**
* Creates a new {@code AsyncAtomicValue}.
@@ -105,8 +201,22 @@
* @param serializer serializer to use for serializing/deserializing value type
* @param <V> value type
* @return value
+ * @deprecated in Nightingale Release (1.13)
*/
- <V> AsyncAtomicValue<V> newAsyncAtomicValue(String name, Serializer serializer);
+ @Deprecated
+ default <V> AsyncAtomicValue<V> newAsyncAtomicValue(String name, Serializer serializer) {
+ return newAsyncAtomicValue((AtomicValueOptions) new AtomicValueOptions() {
+ }.withName(name).withSerializer(serializer));
+ }
+
+ /**
+ * Creates a new {@code AsyncAtomicValue}.
+ *
+ * @param options value options
+ * @param <V> value type
+ * @return value
+ */
+ <V> AsyncAtomicValue<V> newAsyncAtomicValue(AtomicValueOptions options);
/**
* Creates a new {@code AsyncDistributedSet}.
@@ -115,23 +225,52 @@
* @param serializer serializer to use for serializing/deserializing set entries
* @param <E> set entry type
* @return set
+ * @deprecated in Nightingale Release (1.13)
*/
- <E> AsyncDistributedSet<E> newAsyncDistributedSet(String name, Serializer serializer);
+ @Deprecated
+ default <E> AsyncDistributedSet<E> newAsyncDistributedSet(String name, Serializer serializer) {
+ return newAsyncDistributedSet((DistributedSetOptions) new DistributedSetOptions() {
+ }.withName(name).withSerializer(serializer));
+ }
+
+ /**
+ * Creates a new {@code AsyncDistributedSet}.
+ *
+ * @param options set options
+ * @param <E> set entry type
+ * @return set
+ */
+ <E> AsyncDistributedSet<E> newAsyncDistributedSet(DistributedSetOptions options);
/**
* Creates a new {@code AsyncDistributedLock}.
*
* @param name lock name
* @return lock
+ * @deprecated in Nightingale Release (1.13)
*/
- AsyncDistributedLock newAsyncDistributedLock(String name);
+ @Deprecated
+ default AsyncDistributedLock newAsyncDistributedLock(String name) {
+ return newAsyncDistributedLock((DistributedLockOptions) new DistributedLockOptions() {
+ }.withName(name));
+ }
+
+ /**
+ * Creates a new {@code AsyncDistributedLock}.
+ *
+ * @param options lock options
+ * @return lock
+ */
+ AsyncDistributedLock newAsyncDistributedLock(DistributedLockOptions options);
/**
* Creates a new {@code AsyncLeaderElector}.
*
* @param name leader elector name
* @return leader elector
+ * @deprecated in Nightingale Release (1.13)
*/
+ @Deprecated
default AsyncLeaderElector newAsyncLeaderElector(String name) {
return newAsyncLeaderElector(name, DEFAULT_OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
@@ -143,8 +282,24 @@
* @param electionTimeout leader election timeout
* @param timeUnit leader election timeout time unit
* @return leader elector
+ * @deprecated in Nightingale Release (1.13)
*/
- AsyncLeaderElector newAsyncLeaderElector(String name, long electionTimeout, TimeUnit timeUnit);
+ @Deprecated
+ default AsyncLeaderElector newAsyncLeaderElector(String name, long electionTimeout, TimeUnit timeUnit) {
+ LeaderElectorOptions options = new LeaderElectorOptions() {
+ };
+ options.withName(name);
+ options.withElectionTimeout(electionTimeout, timeUnit);
+ return newAsyncLeaderElector(options);
+ }
+
+ /**
+ * Creates a new {@code AsyncLeaderElector}.
+ *
+ * @param options leader elector options
+ * @return leader elector
+ */
+ AsyncLeaderElector newAsyncLeaderElector(LeaderElectorOptions options);
/**
* Creates a new {@code WorkQueue}.
@@ -153,8 +308,22 @@
* @param name work queue name
* @param serializer serializer
* @return work queue
+ * @deprecated in Nightingale Release (1.13)
*/
- <E> WorkQueue<E> newWorkQueue(String name, Serializer serializer);
+ @Deprecated
+ default <E> WorkQueue<E> newWorkQueue(String name, Serializer serializer) {
+ return newWorkQueue((WorkQueueOptions) new WorkQueueOptions() {
+ }.withName(name).withSerializer(serializer));
+ }
+
+ /**
+ * Creates a new {@code WorkQueue}.
+ *
+ * @param <E> work element type
+ * @param options work queue options
+ * @return work queue
+ */
+ <E> WorkQueue<E> newWorkQueue(WorkQueueOptions options);
/**
* Creates a new {@code AsyncDocumentTree}.
@@ -163,7 +332,9 @@
* @param name tree name
* @param serializer serializer
* @return document tree
+ * @deprecated in Nightingale Release (1.13)
*/
+ @Deprecated
default <V> AsyncDocumentTree<V> newAsyncDocumentTree(String name, Serializer serializer) {
return newAsyncDocumentTree(name, serializer, Ordering.NATURAL);
}
@@ -176,8 +347,26 @@
* @param serializer serializer
* @param ordering tree node ordering
* @return document tree
+ * @deprecated in Nightingale Release (1.13)
*/
- <V> AsyncDocumentTree<V> newAsyncDocumentTree(String name, Serializer serializer, Ordering ordering);
+ @Deprecated
+ default <V> AsyncDocumentTree<V> newAsyncDocumentTree(String name, Serializer serializer, Ordering ordering) {
+ DocumentTreeOptions options = new DocumentTreeOptions() {
+ };
+ options.withName(name);
+ options.withSerializer(serializer);
+ options.withOrdering(ordering);
+ return newAsyncDocumentTree(options);
+ }
+
+ /**
+ * Creates a new {@code AsyncDocumentTree}.
+ *
+ * @param <V> document tree node value type
+ * @param options tree options
+ * @return document tree
+ */
+ <V> AsyncDocumentTree<V> newAsyncDocumentTree(DocumentTreeOptions options);
/**
* Returns the names of all created {@code AsyncConsistentMap} instances.
diff --git a/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveOptions.java b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveOptions.java
new file mode 100644
index 0000000..c576375
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/primitives/DistributedPrimitiveOptions.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.primitives;
+
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.Version;
+import org.onosproject.store.service.DistributedPrimitive;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.RevisionType;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Abstract builder for distributed primitives.
+ *
+ * @param <O> distributed primitive options type
+ */
+public abstract class DistributedPrimitiveOptions<O extends DistributedPrimitiveOptions<O>> {
+
+ private final DistributedPrimitive.Type type;
+ private String name;
+ private ApplicationId applicationId;
+ private Serializer serializer;
+ private boolean partitionsDisabled = false;
+ private boolean meteringDisabled = false;
+ private boolean readOnly = false;
+ private boolean relaxedReadConsistency = false;
+ private int revisionNumber = 1;
+ private RevisionType revisionType = RevisionType.NONE;
+
+ public DistributedPrimitiveOptions(DistributedPrimitive.Type type) {
+ this.type = type;
+ }
+
+ /**
+ * Sets the primitive name.
+ *
+ * @param name primitive name
+ * @return this builder
+ */
+ public O withName(String name) {
+ this.name = name;
+ return (O) this;
+ }
+
+ /**
+ * Sets the serializer to use for transcoding info held in the primitive.
+ *
+ * @param serializer serializer
+ * @return this builder
+ */
+ public O withSerializer(Serializer serializer) {
+ this.serializer = serializer;
+ return (O) this;
+ }
+
+ /**
+ * Sets the application id that owns this primitive.
+ *
+ * @param applicationId application identifier
+ * @return this builder
+ */
+ public O withApplicationId(ApplicationId applicationId) {
+ this.applicationId = applicationId;
+ return (O) this;
+ }
+
+ /**
+ * Sets the primitive version.
+ *
+ * @param version the primitive version
+ * @return this builder
+ */
+ public O withVersion(Version version) {
+ return withRevisionNumber(version.toInt());
+ }
+
+ /**
+ * Sets the primitive revision.
+ *
+ * @param revision the primitive revision
+ * @return this builder
+ */
+ public O withRevisionNumber(int revision) {
+ this.revisionNumber = revision;
+ return (O) this;
+ }
+
+ /**
+ * Sets the primitive revision type.
+ *
+ * @param revisionType the revision type
+ * @return this builder
+ */
+ public O withRevisionType(RevisionType revisionType) {
+ this.revisionType = checkNotNull(revisionType);
+ return (O) this;
+ }
+
+ /**
+ * Disables recording usage stats for this primitive.
+ * @deprecated usage of this method is discouraged for most common scenarios.
+ * @return this builder
+ */
+ @Deprecated
+ public O withMeteringDisabled() {
+ this.meteringDisabled = true;
+ return (O) this;
+ }
+
+ /**
+ * Disables state changing operations on the returned distributed primitive.
+ * @return this builder
+ */
+ public O withUpdatesDisabled() {
+ this.readOnly = true;
+ return (O) this;
+ }
+
+ /**
+ * Turns on relaxed consistency for read operations.
+ * @return this builder
+ */
+ public O withRelaxedReadConsistency() {
+ this.relaxedReadConsistency = true;
+ return (O) this;
+ }
+
+ /**
+ * Returns if metering is enabled.
+ *
+ * @return {@code true} if yes; {@code false} otherwise
+ */
+ public final boolean meteringEnabled() {
+ return !meteringDisabled;
+ }
+
+ /**
+ * Returns if partitions are disabled.
+ *
+ * @return {@code true} if yes; {@code false} otherwise
+ */
+ public final boolean partitionsDisabled() {
+ return partitionsDisabled;
+ }
+
+ /**
+ * Returns if updates are disabled.
+ *
+ * @return {@code true} if yes; {@code false} otherwise
+ */
+ public final boolean readOnly() {
+ return readOnly;
+ }
+
+ /**
+ * Returns if consistency is relaxed for read operations.
+ *
+ * @return {@code true} if yes; {@code false} otherwise
+ */
+ public final boolean relaxedReadConsistency() {
+ return relaxedReadConsistency;
+ }
+
+ /**
+ * Returns the serializer.
+ *
+ * @return serializer
+ */
+ public final Serializer serializer() {
+ return serializer;
+ }
+
+ /**
+ * Returns the application identifier.
+ *
+ * @return application id
+ */
+ public final ApplicationId applicationId() {
+ return applicationId;
+ }
+
+ /**
+ * Returns the name of the primitive.
+ *
+ * @return primitive name
+ */
+ public final String name() {
+ return name;
+ }
+
+ /**
+ * Returns the primitive type.
+ *
+ * @return primitive type
+ */
+ public final DistributedPrimitive.Type type() {
+ return type;
+ }
+
+ /**
+ * Returns the primitive revision number.
+ *
+ * @return the primitive revision number
+ */
+ public final int revision() {
+ return revisionNumber;
+ }
+
+ /**
+ * Returns the primitive revision type.
+ *
+ * @return the primitive revision type
+ */
+ public RevisionType revisionType() {
+ return revisionType;
+ }
+}
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 e0f8efd..0fdd778 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
@@ -21,8 +21,6 @@
* Builder for AtomicCounter.
*/
public abstract class AtomicCounterBuilder
- extends DistributedPrimitiveBuilder<AtomicCounterBuilder, AsyncAtomicCounter> {
- public AtomicCounterBuilder() {
- super(DistributedPrimitive.Type.COUNTER);
- }
+ extends AtomicCounterOptions<AtomicCounterBuilder>
+ implements DistributedPrimitiveBuilder<AsyncAtomicCounter> {
}
\ No newline at end of file
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 96c8e91..9598e34 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
@@ -21,10 +21,8 @@
* Builder for AtomicCounterMap.
*/
public abstract class AtomicCounterMapBuilder<K>
- extends DistributedPrimitiveBuilder<AtomicCounterMapBuilder<K>, AtomicCounterMap<K>> {
- public AtomicCounterMapBuilder() {
- super(DistributedPrimitive.Type.COUNTER_MAP);
- }
+ extends AtomicCounterMapOptions<AtomicCounterMapBuilder<K>, K>
+ implements DistributedPrimitiveBuilder<AtomicCounterMap<K>> {
/**
* Builds an async atomic counter map based on the configuration options
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMapOptions.java b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMapOptions.java
new file mode 100644
index 0000000..f9c5d3e
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterMapOptions.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for AtomicCounterMap.
+ */
+public abstract class AtomicCounterMapOptions<O extends AtomicCounterMapOptions<O, K>, K>
+ extends DistributedPrimitiveOptions<O> {
+ public AtomicCounterMapOptions() {
+ super(DistributedPrimitive.Type.COUNTER_MAP);
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicCounterOptions.java b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterOptions.java
new file mode 100644
index 0000000..1a0bd9b
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicCounterOptions.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Options for AtomicCounter.
+ */
+public abstract class AtomicCounterOptions<O extends AtomicCounterOptions<O>>
+ extends DistributedPrimitiveOptions<O> {
+ public AtomicCounterOptions() {
+ super(DistributedPrimitive.Type.COUNTER);
+ }
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicIdGeneratorBuilder.java b/core/api/src/main/java/org/onosproject/store/service/AtomicIdGeneratorBuilder.java
index ef90642..b7d8e88 100644
--- a/core/api/src/main/java/org/onosproject/store/service/AtomicIdGeneratorBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicIdGeneratorBuilder.java
@@ -21,8 +21,6 @@
* Builder for AtomicIdGenerator.
*/
public abstract class AtomicIdGeneratorBuilder
- extends DistributedPrimitiveBuilder<AtomicIdGeneratorBuilder, AsyncAtomicIdGenerator> {
- public AtomicIdGeneratorBuilder() {
- super(DistributedPrimitive.Type.ID_GENERATOR);
- }
+ extends AtomicIdGeneratorOptions<AtomicIdGeneratorBuilder>
+ implements DistributedPrimitiveBuilder<AsyncAtomicIdGenerator> {
}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicIdGeneratorOptions.java b/core/api/src/main/java/org/onosproject/store/service/AtomicIdGeneratorOptions.java
new file mode 100644
index 0000000..44e2649
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicIdGeneratorOptions.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Options for AtomicIdGenerator.
+ */
+public abstract class AtomicIdGeneratorOptions<O extends AtomicIdGeneratorOptions<O>>
+ extends DistributedPrimitiveOptions<O> {
+ public AtomicIdGeneratorOptions() {
+ super(DistributedPrimitive.Type.ID_GENERATOR);
+ }
+}
\ No newline at end of file
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 10b26d3..4c08707 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
@@ -23,9 +23,6 @@
* @param <V> atomic value type
*/
public abstract class AtomicValueBuilder<V>
- extends DistributedPrimitiveBuilder<AtomicValueBuilder<V>, AsyncAtomicValue<V>> {
-
- public AtomicValueBuilder() {
- super(DistributedPrimitive.Type.VALUE);
- }
+ extends AtomicValueOptions<AtomicValueBuilder<V>, V>
+ implements DistributedPrimitiveBuilder<AsyncAtomicValue<V>> {
}
diff --git a/core/api/src/main/java/org/onosproject/store/service/AtomicValueOptions.java b/core/api/src/main/java/org/onosproject/store/service/AtomicValueOptions.java
new file mode 100644
index 0000000..b00a7af
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/AtomicValueOptions.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for constructing new AtomicValue instances.
+ *
+ * @param <V> atomic value type
+ */
+public abstract class AtomicValueOptions<O extends AtomicValueOptions<O, V>, V> extends DistributedPrimitiveOptions<O> {
+ public AtomicValueOptions() {
+ super(DistributedPrimitive.Type.VALUE);
+ }
+}
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 d991072..4773035 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
@@ -24,51 +24,8 @@
* @param <V> type for map value
*/
public abstract class ConsistentMapBuilder<K, V>
- extends DistributedPrimitiveBuilder<ConsistentMapBuilder<K, V>, ConsistentMap<K, V>> {
-
- private boolean nullValues = false;
- private boolean purgeOnUninstall = false;
-
- public ConsistentMapBuilder() {
- super(DistributedPrimitive.Type.CONSISTENT_MAP);
- }
-
- /**
- * Enables null values in the map.
- *
- * @return this builder
- */
- public ConsistentMapBuilder<K, V> withNullValues() {
- nullValues = true;
- return this;
- }
-
- /**
- * Clears map contents when the owning application is uninstalled.
- *
- * @return this builder
- */
- public ConsistentMapBuilder<K, V> withPurgeOnUninstall() {
- purgeOnUninstall = true;
- return this;
- }
-
- /**
- * Returns whether null values are supported by the map.
- *
- * @return {@code true} if null values are supported; {@code false} otherwise
- */
- public boolean nullValues() {
- return nullValues;
- }
-
- /**
- * Returns if map entries need to be cleared when owning application is uninstalled.
- * @return {@code true} if yes; {@code false} otherwise.
- */
- public boolean purgeOnUninstall() {
- return purgeOnUninstall;
- }
+ extends ConsistentMapOptions<ConsistentMapBuilder<K, V>, K, V>
+ implements DistributedPrimitiveBuilder<ConsistentMap<K, V>> {
/**
* Builds an async consistent map based on the configuration options
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentMapOptions.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentMapOptions.java
new file mode 100644
index 0000000..587789d
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentMapOptions.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for {@link ConsistentMap} instances.
+ *
+ * @param <K> type for map key
+ * @param <V> type for map value
+ */
+public abstract class ConsistentMapOptions<O extends ConsistentMapOptions<O, K, V>, K, V>
+ extends DistributedPrimitiveOptions<O> {
+
+ private boolean nullValues = false;
+ private boolean purgeOnUninstall = false;
+
+ public ConsistentMapOptions() {
+ super(DistributedPrimitive.Type.CONSISTENT_MAP);
+ }
+
+ /**
+ * Enables null values in the map.
+ *
+ * @return this builder
+ */
+ public O withNullValues() {
+ nullValues = true;
+ return (O) this;
+ }
+
+ /**
+ * Clears map contents when the owning application is uninstalled.
+ *
+ * @return this builder
+ */
+ public O withPurgeOnUninstall() {
+ purgeOnUninstall = true;
+ return (O) this;
+ }
+
+ /**
+ * Returns whether null values are supported by the map.
+ *
+ * @return {@code true} if null values are supported; {@code false} otherwise
+ */
+ public boolean nullValues() {
+ return nullValues;
+ }
+
+ /**
+ * Returns if map entries need to be cleared when owning application is uninstalled.
+ * @return {@code true} if yes; {@code false} otherwise.
+ */
+ public boolean purgeOnUninstall() {
+ return purgeOnUninstall;
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimapBuilder.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimapBuilder.java
index 15f4606..3af5e65 100644
--- a/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimapBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimapBuilder.java
@@ -22,34 +22,8 @@
* A builder class for {@code AsyncConsistentMultimap}.
*/
public abstract class ConsistentMultimapBuilder<K, V>
- extends DistributedPrimitiveBuilder<ConsistentMultimapBuilder<K, V>,
- ConsistentMultimap<K, V>> {
-
- private boolean purgeOnUninstall = false;
-
- public ConsistentMultimapBuilder() {
- super(DistributedPrimitive.Type.CONSISTENT_MULTIMAP);
- }
-
- /**
- * Clears multimap contents when the owning application is uninstalled.
- *
- * @return this builder
- */
- public ConsistentMultimapBuilder<K, V> withPurgeOnUninstall() {
- purgeOnUninstall = true;
- return this;
- }
-
- /**
- * Returns if multimap entries need to be cleared when owning application
- * is uninstalled.
- *
- * @return true if items are to be cleared on uninstall
- */
- public boolean purgeOnUninstall() {
- return purgeOnUninstall;
- }
+ extends ConsistentMultimapOptions<ConsistentMultimapBuilder<K, V>, K, V>
+ implements DistributedPrimitiveBuilder<ConsistentMultimap<K, V>> {
/**
* Builds the distributed multimap based on the configuration options
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimapOptions.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimapOptions.java
new file mode 100644
index 0000000..84fe6bb
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentMultimapOptions.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * A builder class for {@code AsyncConsistentMultimap}.
+ */
+public abstract class ConsistentMultimapOptions<O extends ConsistentMultimapOptions<O, K, V>, K, V>
+ extends DistributedPrimitiveOptions<O> {
+
+ private boolean purgeOnUninstall = false;
+
+ public ConsistentMultimapOptions() {
+ super(DistributedPrimitive.Type.CONSISTENT_MULTIMAP);
+ }
+
+ /**
+ * Clears multimap contents when the owning application is uninstalled.
+ *
+ * @return this builder
+ */
+ public O withPurgeOnUninstall() {
+ purgeOnUninstall = true;
+ return (O) this;
+ }
+
+ /**
+ * Returns if multimap entries need to be cleared when owning application
+ * is uninstalled.
+ *
+ * @return true if items are to be cleared on uninstall
+ */
+ public boolean purgeOnUninstall() {
+ return purgeOnUninstall;
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentTreeMapBuilder.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentTreeMapBuilder.java
index 6c8d3b0..fc7c2f9 100644
--- a/core/api/src/main/java/org/onosproject/store/service/ConsistentTreeMapBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentTreeMapBuilder.java
@@ -22,32 +22,8 @@
* Builder for {@link ConsistentTreeMap}.
*/
public abstract class ConsistentTreeMapBuilder<V>
- extends DistributedPrimitiveBuilder<ConsistentTreeMapBuilder<V>, ConsistentTreeMap<V>> {
-
- private boolean purgeOnUninstall = false;
-
- public ConsistentTreeMapBuilder() {
- super(DistributedPrimitive.Type.CONSISTENT_TREEMAP);
- }
-
- /**
- * Clears map contents when the owning application is uninstalled.
- *
- * @return this builder
- */
- public ConsistentTreeMapBuilder<V> withPurgeOnUninstall() {
- purgeOnUninstall = true;
- return this;
- }
-
- /**
- * Return if map entries need to be cleared when owning application is uninstalled.
- *
- * @return true if items are to be cleared on uninstall
- */
- public boolean purgeOnUninstall() {
- return purgeOnUninstall;
- }
+ extends ConsistentTreeMapOptions<ConsistentTreeMapBuilder<V>, V>
+ implements DistributedPrimitiveBuilder<ConsistentTreeMap<V>> {
/**
* Builds the distributed tree map based on the configuration options supplied
diff --git a/core/api/src/main/java/org/onosproject/store/service/ConsistentTreeMapOptions.java b/core/api/src/main/java/org/onosproject/store/service/ConsistentTreeMapOptions.java
new file mode 100644
index 0000000..5725683
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/ConsistentTreeMapOptions.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for {@link ConsistentTreeMap}.
+ */
+public abstract class ConsistentTreeMapOptions<O extends ConsistentTreeMapOptions<O, V>, V>
+ extends DistributedPrimitiveOptions<O> {
+
+ private boolean purgeOnUninstall = false;
+
+ public ConsistentTreeMapOptions() {
+ super(DistributedPrimitive.Type.CONSISTENT_TREEMAP);
+ }
+
+ /**
+ * Clears map contents when the owning application is uninstalled.
+ *
+ * @return this builder
+ */
+ public O withPurgeOnUninstall() {
+ purgeOnUninstall = true;
+ return (O) this;
+ }
+
+ /**
+ * Return if map entries need to be cleared when owning application is uninstalled.
+ *
+ * @return true if items are to be cleared on uninstall
+ */
+ public boolean purgeOnUninstall() {
+ return purgeOnUninstall;
+ }
+
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/DistributedLockBuilder.java b/core/api/src/main/java/org/onosproject/store/service/DistributedLockBuilder.java
index 7e61c6a..32e77e3 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DistributedLockBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DistributedLockBuilder.java
@@ -21,8 +21,6 @@
* Builder for DistributedLock.
*/
public abstract class DistributedLockBuilder
- extends DistributedPrimitiveBuilder<DistributedLockBuilder, AsyncDistributedLock> {
- public DistributedLockBuilder() {
- super(DistributedPrimitive.Type.LOCK);
- }
+ extends DistributedLockOptions<DistributedLockBuilder>
+ implements DistributedPrimitiveBuilder<AsyncDistributedLock> {
}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/store/service/DistributedLockOptions.java b/core/api/src/main/java/org/onosproject/store/service/DistributedLockOptions.java
new file mode 100644
index 0000000..21a8c6f
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/DistributedLockOptions.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for DistributedLock.
+ */
+public abstract class DistributedLockOptions<O extends DistributedLockOptions<O>>
+ extends DistributedPrimitiveOptions<O> {
+ public DistributedLockOptions() {
+ super(DistributedPrimitive.Type.LOCK);
+ }
+}
\ No newline at end of file
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 c80bd0e..1420e4b 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
@@ -22,30 +22,7 @@
*
* @param <E> type set elements.
*/
-public abstract class DistributedSetBuilder<E> extends DistributedPrimitiveBuilder<DistributedSetBuilder<E>,
- AsyncDistributedSet<E>> {
-
- private boolean purgeOnUninstall = false;
-
- public DistributedSetBuilder() {
- super(DistributedPrimitive.Type.SET);
- }
-
- /**
- * Enables clearing set contents when the owning application is uninstalled.
- *
- * @return this builder
- */
- public DistributedSetBuilder<E> withPurgeOnUninstall() {
- purgeOnUninstall = true;
- return this;
- }
-
- /**
- * Returns if set contents need to be cleared when owning application is uninstalled.
- * @return {@code true} if yes; {@code false} otherwise.
- */
- public boolean purgeOnUninstall() {
- return purgeOnUninstall;
- }
+public abstract class DistributedSetBuilder<E>
+ extends DistributedSetOptions<DistributedSetBuilder<E>, E>
+ implements DistributedPrimitiveBuilder<AsyncDistributedSet<E>> {
}
diff --git a/core/api/src/main/java/org/onosproject/store/service/DistributedSetOptions.java b/core/api/src/main/java/org/onosproject/store/service/DistributedSetOptions.java
new file mode 100644
index 0000000..2c6efd0
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/DistributedSetOptions.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for distributed set.
+ *
+ * @param <E> type set elements.
+ */
+public abstract class DistributedSetOptions<O extends DistributedSetOptions<O, E>, E>
+ extends DistributedPrimitiveOptions<O> {
+
+ private boolean purgeOnUninstall = false;
+
+ public DistributedSetOptions() {
+ super(DistributedPrimitive.Type.SET);
+ }
+
+ /**
+ * Enables clearing set contents when the owning application is uninstalled.
+ *
+ * @return this builder
+ */
+ public O withPurgeOnUninstall() {
+ purgeOnUninstall = true;
+ return (O) this;
+ }
+
+ /**
+ * Returns if set contents need to be cleared when owning application is uninstalled.
+ * @return {@code true} if yes; {@code false} otherwise.
+ */
+ public boolean purgeOnUninstall() {
+ return purgeOnUninstall;
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/DocumentTreeBuilder.java b/core/api/src/main/java/org/onosproject/store/service/DocumentTreeBuilder.java
index 14ecd5c..fb012db 100644
--- a/core/api/src/main/java/org/onosproject/store/service/DocumentTreeBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/DocumentTreeBuilder.java
@@ -22,59 +22,8 @@
* Builder for {@link DocumentTree}.
*/
public abstract class DocumentTreeBuilder<V>
- extends DistributedPrimitiveBuilder<DocumentTreeBuilder<V>, AsyncDocumentTree<V>> {
-
- private boolean purgeOnUninstall = false;
- private Ordering ordering = Ordering.NATURAL;
-
- public DocumentTreeBuilder() {
- super(DistributedPrimitive.Type.DOCUMENT_TREE);
- }
-
- /**
- * Clears document tree contents when the owning application is uninstalled.
- *
- * @return this builder
- */
- public DocumentTreeBuilder<V> withPurgeOnUninstall() {
- purgeOnUninstall = true;
- return this;
- }
-
- /**
- * Return if document tree entries need to be cleared when owning application is uninstalled.
- *
- * @return true if items are to be cleared on uninstall
- */
- public boolean purgeOnUninstall() {
- return purgeOnUninstall;
- }
-
- /**
- * Sets the ordering of the tree nodes.
- * <p>
- * When {@link AsyncDocumentTree#getChildren(DocumentPath)} is called, children will be returned according to
- * the specified sort order.
- *
- * @param ordering ordering of the tree nodes
- * @return this builder
- */
- public DocumentTreeBuilder<V> withOrdering(Ordering ordering) {
- this.ordering = ordering;
- return this;
- }
-
- /**
- * Returns the ordering of tree nodes.
- * <p>
- * When {@link AsyncDocumentTree#getChildren(DocumentPath)} is called, children will be returned according to
- * the specified sort order.
- *
- * @return the ordering of tree nodes
- */
- public Ordering ordering() {
- return ordering;
- }
+ extends DocumentTreeOptions<DocumentTreeBuilder<V>, V>
+ implements DistributedPrimitiveBuilder<AsyncDocumentTree<V>> {
/**
* Builds the distributed Document tree based on the configuration options supplied
diff --git a/core/api/src/main/java/org/onosproject/store/service/DocumentTreeOptions.java b/core/api/src/main/java/org/onosproject/store/service/DocumentTreeOptions.java
new file mode 100644
index 0000000..d93b9c3
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/DocumentTreeOptions.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for {@link DocumentTree}.
+ */
+public abstract class DocumentTreeOptions<O extends DocumentTreeOptions<O, V>, V>
+ extends DistributedPrimitiveOptions<O> {
+
+ private boolean purgeOnUninstall = false;
+ private Ordering ordering = Ordering.NATURAL;
+
+ public DocumentTreeOptions() {
+ super(DistributedPrimitive.Type.DOCUMENT_TREE);
+ }
+
+ /**
+ * Clears document tree contents when the owning application is uninstalled.
+ *
+ * @return this builder
+ */
+ public O withPurgeOnUninstall() {
+ purgeOnUninstall = true;
+ return (O) this;
+ }
+
+ /**
+ * Return if document tree entries need to be cleared when owning application is uninstalled.
+ *
+ * @return true if items are to be cleared on uninstall
+ */
+ public boolean purgeOnUninstall() {
+ return purgeOnUninstall;
+ }
+
+ /**
+ * Sets the ordering of the tree nodes.
+ * <p>
+ * When {@link AsyncDocumentTree#getChildren(DocumentPath)} is called, children will be returned according to
+ * the specified sort order.
+ *
+ * @param ordering ordering of the tree nodes
+ * @return this builder
+ */
+ public O withOrdering(Ordering ordering) {
+ this.ordering = ordering;
+ return (O) this;
+ }
+
+ /**
+ * Returns the ordering of tree nodes.
+ * <p>
+ * When {@link AsyncDocumentTree#getChildren(DocumentPath)} is called, children will be returned according to
+ * the specified sort order.
+ *
+ * @return the ordering of tree nodes
+ */
+ public Ordering ordering() {
+ return ordering;
+ }
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/store/service/LeaderElectorBuilder.java b/core/api/src/main/java/org/onosproject/store/service/LeaderElectorBuilder.java
index d3d6951..aef492d 100644
--- a/core/api/src/main/java/org/onosproject/store/service/LeaderElectorBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/LeaderElectorBuilder.java
@@ -15,50 +15,12 @@
*/
package org.onosproject.store.service;
-import java.util.concurrent.TimeUnit;
-
import org.onosproject.store.primitives.DistributedPrimitiveBuilder;
/**
* Builder for constructing new {@link AsyncLeaderElector} instances.
*/
public abstract class LeaderElectorBuilder
- extends DistributedPrimitiveBuilder<LeaderElectorBuilder, AsyncLeaderElector> {
-
- private long electionTimeoutMillis = DistributedPrimitive.DEFAULT_OPERATION_TIMEOUT_MILLIS;
-
- public LeaderElectorBuilder() {
- super(DistributedPrimitive.Type.LEADER_ELECTOR);
- }
-
- /**
- * Sets the election timeout in milliseconds.
- *
- * @param electionTimeoutMillis the election timeout in milliseconds
- * @return leader elector builder
- */
- public LeaderElectorBuilder withElectionTimeout(long electionTimeoutMillis) {
- this.electionTimeoutMillis = electionTimeoutMillis;
- return this;
- }
-
- /**
- * Sets the election timeout.
- *
- * @param electionTimeout the election timeout
- * @param timeUnit the timeout time unit
- * @return leader elector builder
- */
- public LeaderElectorBuilder withElectionTimeout(long electionTimeout, TimeUnit timeUnit) {
- return withElectionTimeout(timeUnit.toMillis(electionTimeout));
- }
-
- /**
- * Returns the election timeout in milliseconds.
- *
- * @return the election timeout in milliseconds
- */
- public final long electionTimeoutMillis() {
- return electionTimeoutMillis;
- }
+ extends LeaderElectorOptions<LeaderElectorBuilder>
+ implements DistributedPrimitiveBuilder<AsyncLeaderElector> {
}
diff --git a/core/api/src/main/java/org/onosproject/store/service/LeaderElectorOptions.java b/core/api/src/main/java/org/onosproject/store/service/LeaderElectorOptions.java
new file mode 100644
index 0000000..ff879b5
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/LeaderElectorOptions.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import java.util.concurrent.TimeUnit;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for constructing new {@link AsyncLeaderElector} instances.
+ */
+public abstract class LeaderElectorOptions<O extends LeaderElectorOptions<O>>
+ extends DistributedPrimitiveOptions<O> {
+
+ private long electionTimeoutMillis = DistributedPrimitive.DEFAULT_OPERATION_TIMEOUT_MILLIS;
+
+ public LeaderElectorOptions() {
+ super(DistributedPrimitive.Type.LEADER_ELECTOR);
+ }
+
+ /**
+ * Sets the election timeout in milliseconds.
+ *
+ * @param electionTimeoutMillis the election timeout in milliseconds
+ * @return leader elector builder
+ */
+ public O withElectionTimeout(long electionTimeoutMillis) {
+ this.electionTimeoutMillis = electionTimeoutMillis;
+ return (O) this;
+ }
+
+ /**
+ * Sets the election timeout.
+ *
+ * @param electionTimeout the election timeout
+ * @param timeUnit the timeout time unit
+ * @return leader elector builder
+ */
+ public O withElectionTimeout(long electionTimeout, TimeUnit timeUnit) {
+ return withElectionTimeout(timeUnit.toMillis(electionTimeout));
+ }
+
+ /**
+ * Returns the election timeout in milliseconds.
+ *
+ * @return the election timeout in milliseconds
+ */
+ public final long electionTimeoutMillis() {
+ return electionTimeoutMillis;
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/RevisionType.java b/core/api/src/main/java/org/onosproject/store/service/RevisionType.java
new file mode 100644
index 0000000..77152aa
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/RevisionType.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+/**
+ * Distributed primitive revision types.
+ * <p>
+ * Revision types dictate the semantics of new revisions of a distributed primitive. They indicate how the new
+ * revision is initialized and how it relates to prior revisions.
+ */
+public enum RevisionType {
+
+ /**
+ * A distributed primitive that is initialized with an empty state.
+ */
+ NONE,
+
+ /**
+ * A distributed primitive that is initialized from the previous revision and sets the previous revision to
+ * read-only mode.
+ */
+ VERSION,
+
+ /**
+ * A distributed primitive that is initialized from the state of the previous revision and to which changes to
+ * the previous revision are propagated.
+ */
+ PROPAGATE,
+
+ /**
+ * A distributed primitive that is initialized from the state of the previous revision and thereafter diverges.
+ */
+ ISOLATE,
+
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/TransactionContextBuilder.java b/core/api/src/main/java/org/onosproject/store/service/TransactionContextBuilder.java
index c9af8e9..d456d1c7 100644
--- a/core/api/src/main/java/org/onosproject/store/service/TransactionContextBuilder.java
+++ b/core/api/src/main/java/org/onosproject/store/service/TransactionContextBuilder.java
@@ -21,9 +21,6 @@
* Abstract base class for a transaction context builder.
*/
public abstract class TransactionContextBuilder
- extends DistributedPrimitiveBuilder<TransactionContextBuilder, TransactionContext> {
-
- public TransactionContextBuilder() {
- super(DistributedPrimitive.Type.TRANSACTION_CONTEXT);
- }
+ extends TransactionContextOptions<TransactionContextBuilder>
+ implements DistributedPrimitiveBuilder<TransactionContext> {
}
diff --git a/core/api/src/main/java/org/onosproject/store/service/TransactionContextOptions.java b/core/api/src/main/java/org/onosproject/store/service/TransactionContextOptions.java
new file mode 100644
index 0000000..7336f2f
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/TransactionContextOptions.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Abstract base class for a transaction context builder.
+ */
+public abstract class TransactionContextOptions<O extends TransactionContextOptions<O>>
+ extends DistributedPrimitiveOptions<O> {
+ public TransactionContextOptions() {
+ super(DistributedPrimitive.Type.TRANSACTION_CONTEXT);
+ }
+}
diff --git a/core/api/src/main/java/org/onosproject/store/service/WorkQueueBuilder.java b/core/api/src/main/java/org/onosproject/store/service/WorkQueueBuilder.java
new file mode 100644
index 0000000..52bf3ae
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/WorkQueueBuilder.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveBuilder;
+
+/**
+ * Builder for WorkQueue.
+ */
+public abstract class WorkQueueBuilder<E>
+ extends WorkQueueOptions<WorkQueueBuilder<E>, E>
+ implements DistributedPrimitiveBuilder<WorkQueue<E>> {
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/store/service/WorkQueueOptions.java b/core/api/src/main/java/org/onosproject/store/service/WorkQueueOptions.java
new file mode 100644
index 0000000..8d5e23a
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/store/service/WorkQueueOptions.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.store.service;
+
+import org.onosproject.store.primitives.DistributedPrimitiveOptions;
+
+/**
+ * Builder for WorkQueue.
+ */
+public abstract class WorkQueueOptions<O extends WorkQueueOptions<O, E>, E>
+ extends DistributedPrimitiveOptions<O> {
+ public WorkQueueOptions() {
+ super(DistributedPrimitive.Type.LOCK);
+ }
+}
\ No newline at end of file
diff --git a/core/store/primitives/pom.xml b/core/store/primitives/pom.xml
index aaa9bdf..bbdf9a3 100644
--- a/core/store/primitives/pom.xml
+++ b/core/store/primitives/pom.xml
@@ -69,7 +69,7 @@
<dependency>
<groupId>io.atomix</groupId>
<artifactId>atomix</artifactId>
- <version>2.0.18</version>
+ <version>2.0.20</version>
</dependency>
<dependency>
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java
index 0e53f77..b6f27f0 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/FederatedDistributedPrimitiveCreator.java
@@ -19,7 +19,6 @@
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import com.google.common.base.Charsets;
@@ -44,10 +43,20 @@
import org.onosproject.store.service.AsyncDistributedSet;
import org.onosproject.store.service.AsyncDocumentTree;
import org.onosproject.store.service.AsyncLeaderElector;
+import org.onosproject.store.service.AtomicCounterMapOptions;
+import org.onosproject.store.service.AtomicCounterOptions;
+import org.onosproject.store.service.AtomicIdGeneratorOptions;
+import org.onosproject.store.service.AtomicValueOptions;
+import org.onosproject.store.service.ConsistentMapOptions;
+import org.onosproject.store.service.ConsistentMultimapOptions;
+import org.onosproject.store.service.ConsistentTreeMapOptions;
+import org.onosproject.store.service.DistributedLockOptions;
+import org.onosproject.store.service.DistributedSetOptions;
import org.onosproject.store.service.DocumentPath;
-import org.onosproject.store.service.Ordering;
-import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.DocumentTreeOptions;
+import org.onosproject.store.service.LeaderElectorOptions;
import org.onosproject.store.service.WorkQueue;
+import org.onosproject.store.service.WorkQueueOptions;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -72,13 +81,11 @@
}
@Override
- public <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(String name, Serializer serializer) {
- checkNotNull(name);
- checkNotNull(serializer);
+ public <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(ConsistentMapOptions options) {
Map<PartitionId, AsyncConsistentMap<byte[], byte[]>> maps =
Maps.transformValues(members,
partition -> DistributedPrimitives.newTranscodingMap(
- partition.<String, byte[]>newAsyncConsistentMap(name, null),
+ partition.<String, byte[]>newAsyncConsistentMap(options.name(), null),
HexString::toHexString,
HexString::fromHexString,
Function.identity(),
@@ -87,78 +94,76 @@
int bucket = Math.abs(Hashing.murmur3_32().hashBytes(key).asInt()) % buckets;
return sortedMemberPartitionIds.get(Hashing.consistentHash(bucket, sortedMemberPartitionIds.size()));
};
- AsyncConsistentMap<byte[], byte[]> partitionedMap = new PartitionedAsyncConsistentMap<>(name, maps, hasher);
+ AsyncConsistentMap<byte[], byte[]> partitionedMap =
+ new PartitionedAsyncConsistentMap<>(options.name(), maps, hasher);
return DistributedPrimitives.newTranscodingMap(partitionedMap,
- key -> serializer.encode(key),
- bytes -> serializer.decode(bytes),
- value -> value == null ? null : serializer.encode(value),
- bytes -> serializer.decode(bytes));
+ key -> options.serializer().encode(key),
+ bytes -> options.serializer().decode(bytes),
+ value -> value == null ? null : options.serializer().encode(value),
+ bytes -> options.serializer().decode(bytes));
}
@Override
- public <V> AsyncConsistentTreeMap<V> newAsyncConsistentTreeMap(String name, Serializer serializer) {
- return getCreator(name).newAsyncConsistentTreeMap(name, serializer);
+ public <V> AsyncConsistentTreeMap<V> newAsyncConsistentTreeMap(ConsistentTreeMapOptions options) {
+ return getCreator(options.name()).newAsyncConsistentTreeMap(options.name(), options.serializer());
}
@Override
- public <K, V> AsyncConsistentMultimap<K, V> newAsyncConsistentSetMultimap(String name, Serializer serializer) {
- return getCreator(name).newAsyncConsistentSetMultimap(name, serializer);
+ public <K, V> AsyncConsistentMultimap<K, V> newAsyncConsistentSetMultimap(ConsistentMultimapOptions options) {
+ return getCreator(options.name()).newAsyncConsistentSetMultimap(options);
}
@Override
- public <E> AsyncDistributedSet<E> newAsyncDistributedSet(String name, Serializer serializer) {
- return DistributedPrimitives.newSetFromMap(newAsyncConsistentMap(name, serializer));
+ public <E> AsyncDistributedSet<E> newAsyncDistributedSet(DistributedSetOptions options) {
+ return DistributedPrimitives.newSetFromMap(newAsyncConsistentMap(options.name(), options.serializer()));
}
@Override
- public <K> AsyncAtomicCounterMap<K> newAsyncAtomicCounterMap(String name, Serializer serializer) {
- return getCreator(name).newAsyncAtomicCounterMap(name, serializer);
+ public <K> AsyncAtomicCounterMap<K> newAsyncAtomicCounterMap(AtomicCounterMapOptions options) {
+ return getCreator(options.name()).newAsyncAtomicCounterMap(options);
}
@Override
- public AsyncAtomicCounter newAsyncCounter(String name) {
- return getCreator(name).newAsyncCounter(name);
+ public AsyncAtomicCounter newAsyncCounter(AtomicCounterOptions options) {
+ return getCreator(options.name()).newAsyncCounter(options);
}
@Override
- public AsyncAtomicIdGenerator newAsyncIdGenerator(String name) {
- return getCreator(name).newAsyncIdGenerator(name);
+ public AsyncAtomicIdGenerator newAsyncIdGenerator(AtomicIdGeneratorOptions options) {
+ return getCreator(options.name()).newAsyncIdGenerator(options);
}
@Override
- public <V> AsyncAtomicValue<V> newAsyncAtomicValue(String name, Serializer serializer) {
- return getCreator(name).newAsyncAtomicValue(name, serializer);
+ public <V> AsyncAtomicValue<V> newAsyncAtomicValue(AtomicValueOptions options) {
+ return getCreator(options.name()).newAsyncAtomicValue(options);
}
@Override
- public AsyncDistributedLock newAsyncDistributedLock(String name) {
- return getCreator(name).newAsyncDistributedLock(name);
+ public AsyncDistributedLock newAsyncDistributedLock(DistributedLockOptions options) {
+ return getCreator(options.name()).newAsyncDistributedLock(options);
}
@Override
- public AsyncLeaderElector newAsyncLeaderElector(String name, long leaderTimeout, TimeUnit timeUnit) {
- checkNotNull(name);
+ public AsyncLeaderElector newAsyncLeaderElector(LeaderElectorOptions options) {
Map<PartitionId, AsyncLeaderElector> leaderElectors =
Maps.transformValues(members,
- partition -> partition.newAsyncLeaderElector(name, leaderTimeout, timeUnit));
+ partition -> partition.newAsyncLeaderElector(options));
Hasher<String> hasher = topic -> {
int hashCode = Hashing.sha256().hashString(topic, Charsets.UTF_8).asInt();
return sortedMemberPartitionIds.get(Math.abs(hashCode) % members.size());
};
- return new PartitionedAsyncLeaderElector(name, leaderElectors, hasher);
+ return new PartitionedAsyncLeaderElector(options.name(), leaderElectors, hasher);
}
@Override
- public <E> WorkQueue<E> newWorkQueue(String name, Serializer serializer) {
- return getCreator(name).newWorkQueue(name, serializer);
+ public <E> WorkQueue<E> newWorkQueue(WorkQueueOptions options) {
+ return getCreator(options.name()).newWorkQueue(options);
}
@Override
- public <V> AsyncDocumentTree<V> newAsyncDocumentTree(String name, Serializer serializer, Ordering ordering) {
- checkNotNull(name);
- checkNotNull(serializer);
+ public <V> AsyncDocumentTree<V> newAsyncDocumentTree(DocumentTreeOptions options) {
Map<PartitionId, AsyncDocumentTree<V>> trees =
- Maps.transformValues(members, part -> part.<V>newAsyncDocumentTree(name, serializer, ordering));
+ Maps.transformValues(members, part -> part.<V>newAsyncDocumentTree(options));
Hasher<DocumentPath> hasher = key -> {
int bucket = (key == null) ? 0 :
Math.abs(Hashing.murmur3_32()
@@ -166,7 +171,7 @@
.asInt()) % buckets;
return sortedMemberPartitionIds.get(Hashing.consistentHash(bucket, sortedMemberPartitionIds.size()));
};
- return new PartitionedAsyncDocumentTree<>(name, trees, hasher);
+ return new PartitionedAsyncDocumentTree<>(options.name(), trees, hasher);
}
@Override
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageNamespaces.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageNamespaces.java
index 6639f72..4eaac99 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageNamespaces.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StorageNamespaces.java
@@ -64,6 +64,7 @@
import io.atomix.protocols.raft.protocol.ResetRequest;
import io.atomix.protocols.raft.protocol.VoteRequest;
import io.atomix.protocols.raft.protocol.VoteResponse;
+import io.atomix.protocols.raft.service.PropagationStrategy;
import io.atomix.protocols.raft.session.RaftSessionMetadata;
import io.atomix.protocols.raft.session.SessionId;
import io.atomix.protocols.raft.storage.log.entry.CloseSessionEntry;
@@ -149,6 +150,7 @@
.register(RaftMember.Type.class)
.register(Instant.class)
.register(Configuration.class)
+ .register(PropagationStrategy.class)
.build("RaftProtocol");
/**
@@ -176,6 +178,7 @@
.register(RaftMember.Type.class)
.register(Instant.class)
.register(Configuration.class)
+ .register(PropagationStrategy.class)
.build("RaftStorage");
private StorageNamespaces() {
diff --git a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java
index 2318d08..0438fe5 100644
--- a/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java
+++ b/core/store/primitives/src/main/java/org/onosproject/store/primitives/impl/StoragePartitionClient.java
@@ -18,7 +18,6 @@
import java.time.Duration;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.google.common.base.Suppliers;
@@ -27,6 +26,7 @@
import io.atomix.protocols.raft.cluster.MemberId;
import io.atomix.protocols.raft.protocol.RaftClientProtocol;
import io.atomix.protocols.raft.proxy.CommunicationStrategy;
+import io.atomix.protocols.raft.service.PropagationStrategy;
import io.atomix.protocols.raft.session.RaftSessionMetadata;
import org.onlab.util.HexString;
import org.onosproject.store.primitives.DistributedPrimitiveCreator;
@@ -52,11 +52,22 @@
import org.onosproject.store.service.AsyncDistributedSet;
import org.onosproject.store.service.AsyncDocumentTree;
import org.onosproject.store.service.AsyncLeaderElector;
+import org.onosproject.store.service.AtomicCounterMapOptions;
+import org.onosproject.store.service.AtomicCounterOptions;
+import org.onosproject.store.service.AtomicIdGeneratorOptions;
+import org.onosproject.store.service.AtomicValueOptions;
+import org.onosproject.store.service.ConsistentMapOptions;
+import org.onosproject.store.service.ConsistentMultimapOptions;
+import org.onosproject.store.service.ConsistentTreeMapOptions;
+import org.onosproject.store.service.DistributedLockOptions;
import org.onosproject.store.service.DistributedPrimitive;
-import org.onosproject.store.service.Ordering;
+import org.onosproject.store.service.DistributedSetOptions;
+import org.onosproject.store.service.DocumentTreeOptions;
+import org.onosproject.store.service.LeaderElectorOptions;
import org.onosproject.store.service.PartitionClientInfo;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.WorkQueue;
+import org.onosproject.store.service.WorkQueueOptions;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
@@ -137,193 +148,212 @@
@Override
@SuppressWarnings("unchecked")
- public <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(String name, Serializer serializer) {
+ public <K, V> AsyncConsistentMap<K, V> newAsyncConsistentMap(ConsistentMapOptions options) {
AtomixConsistentMap rawMap =
new AtomixConsistentMap(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.CONSISTENT_MAP.name())
.withReadConsistency(ReadConsistency.SEQUENTIAL)
.withCommunicationStrategy(CommunicationStrategy.ANY)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MAX_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
- if (serializer != null) {
+ if (options.serializer() != null) {
return DistributedPrimitives.newTranscodingMap(rawMap,
- key -> HexString.toHexString(serializer.encode(key)),
- string -> serializer.decode(HexString.fromHexString(string)),
- value -> value == null ? null : serializer.encode(value),
- bytes -> serializer.decode(bytes));
+ key -> HexString.toHexString(options.serializer().encode(key)),
+ string -> options.serializer().decode(HexString.fromHexString(string)),
+ value -> value == null ? null : options.serializer().encode(value),
+ bytes -> options.serializer().decode(bytes));
}
return (AsyncConsistentMap<K, V>) rawMap;
}
@Override
@SuppressWarnings("unchecked")
- public <V> AsyncConsistentTreeMap<V> newAsyncConsistentTreeMap(String name, Serializer serializer) {
+ public <V> AsyncConsistentTreeMap<V> newAsyncConsistentTreeMap(ConsistentTreeMapOptions options) {
AtomixConsistentTreeMap rawMap =
new AtomixConsistentTreeMap(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.CONSISTENT_TREEMAP.name())
.withReadConsistency(ReadConsistency.SEQUENTIAL)
.withCommunicationStrategy(CommunicationStrategy.ANY)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MAX_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
- if (serializer != null) {
+ if (options.serializer() != null) {
return DistributedPrimitives.newTranscodingTreeMap(
rawMap,
- value -> value == null ? null : serializer.encode(value),
- bytes -> serializer.decode(bytes));
+ value -> value == null ? null : options.serializer().encode(value),
+ bytes -> options.serializer().decode(bytes));
}
return (AsyncConsistentTreeMap<V>) rawMap;
}
@Override
@SuppressWarnings("unchecked")
- public <K, V> AsyncConsistentMultimap<K, V> newAsyncConsistentSetMultimap(String name, Serializer serializer) {
+ public <K, V> AsyncConsistentMultimap<K, V> newAsyncConsistentSetMultimap(ConsistentMultimapOptions options) {
AtomixConsistentSetMultimap rawMap =
new AtomixConsistentSetMultimap(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.CONSISTENT_MULTIMAP.name())
.withReadConsistency(ReadConsistency.SEQUENTIAL)
.withCommunicationStrategy(CommunicationStrategy.ANY)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MAX_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
- if (serializer != null) {
+ if (options.serializer() != null) {
return DistributedPrimitives.newTranscodingMultimap(
rawMap,
- key -> HexString.toHexString(serializer.encode(key)),
- string -> serializer.decode(HexString.fromHexString(string)),
- value -> serializer.encode(value),
- bytes -> serializer.decode(bytes));
+ key -> HexString.toHexString(options.serializer().encode(key)),
+ string -> options.serializer().decode(HexString.fromHexString(string)),
+ value -> options.serializer().encode(value),
+ bytes -> options.serializer().decode(bytes));
}
return (AsyncConsistentMultimap<K, V>) rawMap;
}
@Override
- public <E> AsyncDistributedSet<E> newAsyncDistributedSet(String name, Serializer serializer) {
- return DistributedPrimitives.newSetFromMap(newAsyncConsistentMap(name, serializer));
+ public <E> AsyncDistributedSet<E> newAsyncDistributedSet(DistributedSetOptions options) {
+ return DistributedPrimitives.newSetFromMap(newAsyncConsistentMap(options.name(), options.serializer()));
}
@Override
@SuppressWarnings("unchecked")
- public <K> AsyncAtomicCounterMap<K> newAsyncAtomicCounterMap(String name, Serializer serializer) {
+ public <K> AsyncAtomicCounterMap<K> newAsyncAtomicCounterMap(AtomicCounterMapOptions options) {
AtomixAtomicCounterMap rawMap = new AtomixAtomicCounterMap(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.COUNTER_MAP.name())
.withReadConsistency(ReadConsistency.LINEARIZABLE_LEASE)
.withCommunicationStrategy(CommunicationStrategy.LEADER)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MAX_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
- if (serializer != null) {
+ if (options.serializer() != null) {
return DistributedPrimitives.newTranscodingAtomicCounterMap(
rawMap,
- key -> HexString.toHexString(serializer.encode(key)),
- string -> serializer.decode(HexString.fromHexString(string)));
+ key -> HexString.toHexString(options.serializer().encode(key)),
+ string -> options.serializer().decode(HexString.fromHexString(string)));
}
return (AsyncAtomicCounterMap<K>) rawMap;
}
@Override
- public AsyncAtomicCounter newAsyncCounter(String name) {
+ public AsyncAtomicCounter newAsyncCounter(AtomicCounterOptions options) {
return new AtomixCounter(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.COUNTER.name())
.withReadConsistency(ReadConsistency.LINEARIZABLE_LEASE)
.withCommunicationStrategy(CommunicationStrategy.LEADER)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MAX_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
}
@Override
- public AsyncAtomicIdGenerator newAsyncIdGenerator(String name) {
- return new AtomixIdGenerator(newAsyncCounter(name));
+ public AsyncAtomicIdGenerator newAsyncIdGenerator(AtomicIdGeneratorOptions options) {
+ return new AtomixIdGenerator(newAsyncCounter(options.name()));
}
@Override
- public <V> AsyncAtomicValue<V> newAsyncAtomicValue(String name, Serializer serializer) {
- return new DefaultAsyncAtomicValue<>(name, serializer, onosAtomicValuesMap.get());
+ public <V> AsyncAtomicValue<V> newAsyncAtomicValue(AtomicValueOptions options) {
+ return new DefaultAsyncAtomicValue<>(options.name(), options.serializer(), onosAtomicValuesMap.get());
}
@Override
- public <E> WorkQueue<E> newWorkQueue(String name, Serializer serializer) {
+ public <E> WorkQueue<E> newWorkQueue(WorkQueueOptions options) {
AtomixWorkQueue atomixWorkQueue = new AtomixWorkQueue(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.WORK_QUEUE.name())
.withReadConsistency(ReadConsistency.LINEARIZABLE_LEASE)
.withCommunicationStrategy(CommunicationStrategy.LEADER)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MAX_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
- return new DefaultDistributedWorkQueue<>(atomixWorkQueue, serializer);
+ return new DefaultDistributedWorkQueue<>(atomixWorkQueue, options.serializer());
}
@Override
- public <V> AsyncDocumentTree<V> newAsyncDocumentTree(String name, Serializer serializer, Ordering ordering) {
+ public <V> AsyncDocumentTree<V> newAsyncDocumentTree(DocumentTreeOptions options) {
+ String serviceType = String.format("%s-%s", DistributedPrimitive.Type.DOCUMENT_TREE.name(), options.ordering());
AtomixDocumentTree atomixDocumentTree = new AtomixDocumentTree(client.newProxyBuilder()
- .withName(name)
- .withServiceType(String.format("%s-%s", DistributedPrimitive.Type.DOCUMENT_TREE.name(), ordering))
+ .withName(options.name())
+ .withServiceType(serviceType)
.withReadConsistency(ReadConsistency.SEQUENTIAL)
.withCommunicationStrategy(CommunicationStrategy.ANY)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MAX_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
- return new DefaultDistributedDocumentTree<>(name, atomixDocumentTree, serializer);
+ return new DefaultDistributedDocumentTree<>(options.name(), atomixDocumentTree, options.serializer());
}
@Override
- public AsyncDistributedLock newAsyncDistributedLock(String name) {
+ public AsyncDistributedLock newAsyncDistributedLock(DistributedLockOptions options) {
return new AtomixDistributedLock(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.LOCK.name())
.withReadConsistency(ReadConsistency.LINEARIZABLE)
.withCommunicationStrategy(CommunicationStrategy.LEADER)
.withMinTimeout(MIN_TIMEOUT)
.withMaxTimeout(MIN_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
}
@Override
- public AsyncLeaderElector newAsyncLeaderElector(String name, long leaderTimeout, TimeUnit timeUnit) {
+ public AsyncLeaderElector newAsyncLeaderElector(LeaderElectorOptions options) {
return new AtomixLeaderElector(client.newProxyBuilder()
- .withName(name)
+ .withName(options.name())
.withServiceType(DistributedPrimitive.Type.LEADER_ELECTOR.name())
.withReadConsistency(ReadConsistency.LINEARIZABLE)
.withCommunicationStrategy(CommunicationStrategy.LEADER)
- .withMinTimeout(Duration.ofMillis(timeUnit.toMillis(leaderTimeout)))
+ .withMinTimeout(Duration.ofMillis(options.electionTimeoutMillis()))
.withMaxTimeout(MIN_TIMEOUT)
.withMaxRetries(MAX_RETRIES)
+ .withRevision(options.revision())
+ .withPropagationStrategy(PropagationStrategy.valueOf(options.revisionType().name()))
.build()
.open()
.join());
diff --git a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDistributedLockServiceTest.java b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDistributedLockServiceTest.java
index fb92eba..cf3e051 100644
--- a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDistributedLockServiceTest.java
+++ b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/AtomixDistributedLockServiceTest.java
@@ -65,6 +65,7 @@
expect(context.serviceId()).andReturn(ServiceId.from(1)).anyTimes();
expect(context.currentIndex()).andReturn(index.get()).anyTimes();
expect(context.currentOperation()).andReturn(OperationType.COMMAND).anyTimes();
+ expect(context.locked()).andReturn(false).anyTimes();
RaftContext server = mock(RaftContext.class);
expect(server.getProtocol()).andReturn(mock(RaftServerProtocol.class)).anyTimes();
diff --git a/features/features.xml b/features/features.xml
index eddb899..02c9805 100644
--- a/features/features.xml
+++ b/features/features.xml
@@ -59,7 +59,7 @@
<bundle>mvn:com.typesafe/config/1.2.1</bundle>
<bundle>mvn:com.googlecode.concurrent-trees/concurrent-trees/2.6.0</bundle>
<bundle>mvn:commons-io/commons-io/2.4</bundle>
- <bundle>mvn:io.atomix/atomix/2.0.18</bundle>
+ <bundle>mvn:io.atomix/atomix/2.0.20</bundle>
<bundle>mvn:org.glassfish.jersey.core/jersey-client/2.26</bundle>
diff --git a/lib/BUCK b/lib/BUCK
index f742a37..1302f55 100644
--- a/lib/BUCK
+++ b/lib/BUCK
@@ -1,4 +1,4 @@
-# ***** This file was auto-generated at Mon, 2 Apr 2018 16:16:40 GMT. Do not edit this file manually. *****
+# ***** This file was auto-generated at Wed, 4 Apr 2018 19:53:12 GMT. Do not edit this file manually. *****
# ***** Use onos-lib-gen *****
pass_thru_pom(
@@ -207,10 +207,10 @@
remote_jar (
name = 'atomix',
- out = 'atomix-2.0.18.jar',
- url = 'mvn:io.atomix:atomix:jar:2.0.18',
- sha1 = 'e5a9ea68155a7c97c591a4c40d608bf5f80e5c73',
- maven_coords = 'io.atomix:atomix:2.0.18',
+ out = 'atomix-2.0.20.jar',
+ url = 'mvn:io.atomix:atomix:jar:2.0.20',
+ sha1 = '7039de42423b8cd80d6a99208d61f7ee7ec52e50',
+ maven_coords = 'io.atomix:atomix:2.0.20',
visibility = [ 'PUBLIC' ],
)
diff --git a/lib/deps.json b/lib/deps.json
index 692ffa6..8192ee7 100644
--- a/lib/deps.json
+++ b/lib/deps.json
@@ -116,7 +116,7 @@
"aopalliance-repackaged": "mvn:org.glassfish.hk2.external:aopalliance-repackaged:2.5.0-b42",
"amqp-client": "mvn:com.rabbitmq:amqp-client:jar:3.6.1",
"asm": "mvn:org.ow2.asm:asm:5.0.4",
- "atomix": "mvn:io.atomix:atomix:2.0.18",
+ "atomix": "mvn:io.atomix:atomix:2.0.20",
"commons-codec": "mvn:commons-codec:commons-codec:1.10",
"commons-collections": "mvn:commons-collections:commons-collections:3.2.2",
"commons-configuration": "mvn:commons-configuration:commons-configuration:1.10",