ONOS-2133: Support for purging associated stores (ConsistentMap/DistributedSet) when the application is uninstalled
Change-Id: I5bf7678f50ff3ed2792313383ff738c356bef69f
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 50d829c..eb2583b 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
@@ -1,5 +1,6 @@
package org.onosproject.store.service;
+import org.onosproject.core.ApplicationId;
/**
* Builder for consistent maps.
@@ -24,6 +25,18 @@
ConsistentMapBuilder<K, V> withName(String name);
/**
+ * Sets the owner applicationId for the map.
+ * <p>
+ * Note: If {@code purgeOnUninstall} option is enabled, applicationId
+ * must be specified.
+ * </p>
+ *
+ * @param id applicationId owning the consistent map
+ * @return this ConsistentMapBuilder
+ */
+ ConsistentMapBuilder<K, V> withApplicationId(ApplicationId id);
+
+ /**
* Sets a serializer that can be used to serialize
* both the keys and values inserted into the map. The serializer
* builder should be pre-populated with any classes that will be
@@ -65,6 +78,18 @@
ConsistentMapBuilder<K, V> withUpdatesDisabled();
/**
+ * Purges map contents when the application owning the map is uninstalled.
+ * <p>
+ * When this option is enabled, the caller must provide a applicationId via
+ * the {@code withAppliationId} builder method.
+ * <p>
+ * By default map entries will NOT be purged when owning application is uninstalled.
+ *
+ * @return this ConsistentMapBuilder
+ */
+ ConsistentMapBuilder<K, V> withPurgeOnUninstall();
+
+ /**
* 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/DistributedSetBuilder.java b/core/api/src/main/java/org/onosproject/store/service/DistributedSetBuilder.java
index c5608ce..5f4f287 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
@@ -15,6 +15,8 @@
*/
package org.onosproject.store.service;
+import org.onosproject.core.ApplicationId;
+
/**
* Builder for distributed set.
*
@@ -37,6 +39,18 @@
DistributedSetBuilder<E> withName(String name);
/**
+ * Sets the owner applicationId for the set.
+ * <p>
+ * Note: If {@code purgeOnUninstall} option is enabled, applicationId
+ * must be specified.
+ * </p>
+ *
+ * @param id applicationId owning the set
+ * @return this DistributedSetBuilder
+ */
+ DistributedSetBuilder<E> withApplicationId(ApplicationId id);
+
+ /**
* Sets a serializer that can be used to serialize
* the elements add to the set. The serializer
* builder should be pre-populated with any classes that will be
@@ -78,6 +92,18 @@
DistributedSetBuilder<E> withPartitionsDisabled();
/**
+ * Purges set contents when the application owning the set is uninstalled.
+ * <p>
+ * When this option is enabled, the caller must provide a applicationId via
+ * the {@code withAppliationId} builder method.
+ * <p>
+ * By default set contents will NOT be purged when owning application is uninstalled.
+ *
+ * @return this DistributedSetBuilder
+ */
+ DistributedSetBuilder<E> withPurgeOnUninstall();
+
+ /**
* Builds an set based on the configuration options
* supplied to this builder.
*