Fixing various exception issues.
Change-Id: Ic02d66c2ebceda8c05f93b367aa9ff38a11a7a5b
diff --git a/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
index f15bc86..c2a1a7c 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
@@ -22,6 +22,7 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
+import org.onlab.util.Tools;
import org.onosproject.net.newresource.ResourceConsumer;
import org.onosproject.net.newresource.ResourceEvent;
import org.onosproject.net.newresource.ResourcePath;
@@ -30,6 +31,7 @@
import org.onosproject.store.AbstractStore;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.ConsistentMapException;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.TransactionContext;
@@ -68,6 +70,10 @@
private static final Serializer SERIALIZER = Serializer.using(
Arrays.asList(KryoNamespaces.BASIC, KryoNamespaces.API));
+ // TODO: We should provide centralized values for this
+ private static final int MAX_RETRIES = 5;
+ private static final int RETRY_DELAY = 1_000; // millis
+
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService service;
@@ -85,7 +91,8 @@
.withSerializer(SERIALIZER)
.build();
- childMap.put(ResourcePath.ROOT, ImmutableList.of());
+ Tools.retryable(() -> childMap.put(ResourcePath.ROOT, ImmutableList.of()),
+ ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY);
log.info("Started");
}
diff --git a/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java
index 9885521..bf88f57 100644
--- a/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java
+++ b/providers/lldp/src/main/java/org/onosproject/provider/lldp/impl/LldpLinkProvider.java
@@ -242,7 +242,9 @@
cfgRegistry.addListener(cfgListener);
factories.forEach(cfgRegistry::registerConfigFactory);
- SuppressionConfig cfg = cfgRegistry.getConfig(appId, SuppressionConfig.class);
+ SuppressionConfig cfg =
+ Tools.retryable(() -> cfgRegistry.getConfig(appId, SuppressionConfig.class),
+ ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY).get();
if (cfg == null) {
// If no configuration is found, register default.
cfg = Tools.retryable(this::setDefaultSuppressionConfig,