Committed by
Gerrit Code Review
Fixing various exception issues.
Change-Id: Ic02d66c2ebceda8c05f93b367aa9ff38a11a7a5b
Showing
2 changed files
with
11 additions
and
2 deletions
... | @@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Component; | ... | @@ -22,6 +22,7 @@ import org.apache.felix.scr.annotations.Component; |
22 | import org.apache.felix.scr.annotations.Reference; | 22 | import org.apache.felix.scr.annotations.Reference; |
23 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 23 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
24 | import org.apache.felix.scr.annotations.Service; | 24 | import org.apache.felix.scr.annotations.Service; |
25 | +import org.onlab.util.Tools; | ||
25 | import org.onosproject.net.newresource.ResourceConsumer; | 26 | import org.onosproject.net.newresource.ResourceConsumer; |
26 | import org.onosproject.net.newresource.ResourceEvent; | 27 | import org.onosproject.net.newresource.ResourceEvent; |
27 | import org.onosproject.net.newresource.ResourcePath; | 28 | import org.onosproject.net.newresource.ResourcePath; |
... | @@ -30,6 +31,7 @@ import org.onosproject.net.newresource.ResourceStoreDelegate; | ... | @@ -30,6 +31,7 @@ import org.onosproject.net.newresource.ResourceStoreDelegate; |
30 | import org.onosproject.store.AbstractStore; | 31 | import org.onosproject.store.AbstractStore; |
31 | import org.onosproject.store.serializers.KryoNamespaces; | 32 | import org.onosproject.store.serializers.KryoNamespaces; |
32 | import org.onosproject.store.service.ConsistentMap; | 33 | import org.onosproject.store.service.ConsistentMap; |
34 | +import org.onosproject.store.service.ConsistentMapException; | ||
33 | import org.onosproject.store.service.Serializer; | 35 | import org.onosproject.store.service.Serializer; |
34 | import org.onosproject.store.service.StorageService; | 36 | import org.onosproject.store.service.StorageService; |
35 | import org.onosproject.store.service.TransactionContext; | 37 | import org.onosproject.store.service.TransactionContext; |
... | @@ -68,6 +70,10 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -68,6 +70,10 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
68 | private static final Serializer SERIALIZER = Serializer.using( | 70 | private static final Serializer SERIALIZER = Serializer.using( |
69 | Arrays.asList(KryoNamespaces.BASIC, KryoNamespaces.API)); | 71 | Arrays.asList(KryoNamespaces.BASIC, KryoNamespaces.API)); |
70 | 72 | ||
73 | + // TODO: We should provide centralized values for this | ||
74 | + private static final int MAX_RETRIES = 5; | ||
75 | + private static final int RETRY_DELAY = 1_000; // millis | ||
76 | + | ||
71 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 77 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
72 | protected StorageService service; | 78 | protected StorageService service; |
73 | 79 | ||
... | @@ -85,7 +91,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour | ... | @@ -85,7 +91,8 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour |
85 | .withSerializer(SERIALIZER) | 91 | .withSerializer(SERIALIZER) |
86 | .build(); | 92 | .build(); |
87 | 93 | ||
88 | - childMap.put(ResourcePath.ROOT, ImmutableList.of()); | 94 | + Tools.retryable(() -> childMap.put(ResourcePath.ROOT, ImmutableList.of()), |
95 | + ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY); | ||
89 | log.info("Started"); | 96 | log.info("Started"); |
90 | } | 97 | } |
91 | 98 | ... | ... |
... | @@ -242,7 +242,9 @@ public class LldpLinkProvider extends AbstractProvider implements LinkProvider { | ... | @@ -242,7 +242,9 @@ public class LldpLinkProvider extends AbstractProvider implements LinkProvider { |
242 | cfgRegistry.addListener(cfgListener); | 242 | cfgRegistry.addListener(cfgListener); |
243 | factories.forEach(cfgRegistry::registerConfigFactory); | 243 | factories.forEach(cfgRegistry::registerConfigFactory); |
244 | 244 | ||
245 | - SuppressionConfig cfg = cfgRegistry.getConfig(appId, SuppressionConfig.class); | 245 | + SuppressionConfig cfg = |
246 | + Tools.retryable(() -> cfgRegistry.getConfig(appId, SuppressionConfig.class), | ||
247 | + ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY).get(); | ||
246 | if (cfg == null) { | 248 | if (cfg == null) { |
247 | // If no configuration is found, register default. | 249 | // If no configuration is found, register default. |
248 | cfg = Tools.retryable(this::setDefaultSuppressionConfig, | 250 | cfg = Tools.retryable(this::setDefaultSuppressionConfig, | ... | ... |
-
Please register or login to post a comment