Removed operation retry wrappers around various consistent map/atomic counter operations
Change-Id: Ie6c22a983a01bf3488eff51a493554319c5d15f8
diff --git a/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java b/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
index 8a8ca84..ac7b5a1 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/config/impl/DistributedNetworkConfigStore.java
@@ -36,7 +36,6 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.util.KryoNamespace;
-import org.onlab.util.Tools;
import org.onosproject.net.config.Config;
import org.onosproject.net.config.ConfigApplyDelegate;
import org.onosproject.net.config.ConfigFactory;
@@ -47,7 +46,6 @@
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.MapEvent;
import org.onosproject.store.service.MapEventListener;
import org.onosproject.store.service.Serializer;
@@ -79,7 +77,6 @@
private final Logger log = LoggerFactory.getLogger(getClass());
- private static final int MAX_BACKOFF = 10;
private static final String INVALID_CONFIG_JSON =
"JSON node does not contain valid configuration";
private static final String INVALID_JSON_LIST =
@@ -216,9 +213,7 @@
@Override
public <S, T extends Config<S>> T getConfig(S subject, Class<T> configClass) {
- // TODO: need to identify and address the root cause for timeouts.
- Versioned<JsonNode> json = Tools.retryable(configs::get, ConsistentMapException.class, 1, MAX_BACKOFF)
- .apply(key(subject, configClass));
+ Versioned<JsonNode> json = configs.get(key(subject, configClass));
return json != null ? createConfig(subject, configClass, json.value()) : null;
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java b/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
index 83c922d..0e69e8e 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/host/impl/DistributedHostStore.java
@@ -28,7 +28,6 @@
import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onlab.util.KryoNamespace;
-import org.onlab.util.Tools;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
@@ -45,12 +44,10 @@
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.MapEvent;
import org.onosproject.store.service.MapEventListener;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
import java.util.Collection;
@@ -60,7 +57,6 @@
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Predicate;
-import java.util.function.Supplier;
import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -83,7 +79,7 @@
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
- private ConsistentMap<HostId, DefaultHost> host;
+ private ConsistentMap<HostId, DefaultHost> hostsConsistentMap;
private Map<HostId, DefaultHost> hosts;
private final ConcurrentHashMap<HostId, DefaultHost> prevHosts =
@@ -97,24 +93,24 @@
KryoNamespace.Builder hostSerializer = KryoNamespace.newBuilder()
.register(KryoNamespaces.API);
- host = storageService.<HostId, DefaultHost>consistentMapBuilder()
+ hostsConsistentMap = storageService.<HostId, DefaultHost>consistentMapBuilder()
.withName("onos-hosts")
.withRelaxedReadConsistency()
.withSerializer(Serializer.using(hostSerializer.build()))
.build();
- hosts = host.asJavaMap();
+ hosts = hostsConsistentMap.asJavaMap();
prevHosts.putAll(hosts);
- host.addListener(hostLocationTracker);
+ hostsConsistentMap.addListener(hostLocationTracker);
log.info("Started");
}
@Deactivate
public void deactivate() {
- host.removeListener(hostLocationTracker);
+ hostsConsistentMap.removeListener(hostLocationTracker);
prevHosts.clear();
log.info("Stopped");
@@ -162,8 +158,7 @@
HostId hostId,
HostDescription hostDescription,
boolean replaceIPs) {
- Supplier<Versioned<DefaultHost>> supplier =
- () -> host.computeIf(hostId,
+ hostsConsistentMap.computeIf(hostId,
existingHost -> shouldUpdate(existingHost, providerId, hostId,
hostDescription, replaceIPs),
(id, existingHost) -> {
@@ -193,12 +188,6 @@
addresses,
annotations);
});
-
- Tools.retryable(supplier,
- ConsistentMapException.ConcurrentModification.class,
- Integer.MAX_VALUE,
- 50).get();
-
return null;
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java b/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java
index 6ec5b58..30a4de1 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/packet/impl/DistributedPacketStore.java
@@ -42,7 +42,6 @@
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.serializers.StoreSerializer;
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.osgi.service.component.ComponentContext;
@@ -60,7 +59,6 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.onlab.util.Tools.get;
import static org.onlab.util.Tools.groupedThreads;
-import static org.onlab.util.Tools.retryable;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -206,9 +204,7 @@
}
private void add(PacketRequest request) {
- AtomicBoolean firstRequest =
- retryable(this::addInternal, ConsistentMapException.ConcurrentModification.class,
- Integer.MAX_VALUE, MAX_BACKOFF).apply(request);
+ AtomicBoolean firstRequest = addInternal(request);
if (firstRequest.get() && delegate != null) {
// The instance that makes the first request will push to all devices
delegate.requestPackets(request);
@@ -234,9 +230,7 @@
}
private void remove(PacketRequest request) {
- AtomicBoolean removedLast =
- retryable(this::removeInternal, ConsistentMapException.ConcurrentModification.class,
- Integer.MAX_VALUE, MAX_BACKOFF).apply(request);
+ AtomicBoolean removedLast = removeInternal(request);
if (removedLast.get() && delegate != null) {
// The instance that removes the last request will remove from all devices
delegate.cancelPackets(request);
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentContinuousResourceSubStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentContinuousResourceSubStore.java
index 7b4a4b5..e9c9ad7 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentContinuousResourceSubStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentContinuousResourceSubStore.java
@@ -18,7 +18,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import org.onlab.util.GuavaCollectors;
-import org.onlab.util.Tools;
import org.onosproject.net.resource.ContinuousResource;
import org.onosproject.net.resource.ContinuousResourceId;
import org.onosproject.net.resource.DiscreteResourceId;
@@ -26,7 +25,6 @@
import org.onosproject.net.resource.ResourceAllocation;
import org.onosproject.net.resource.ResourceConsumerId;
import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.ConsistentMapException;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.TransactionContext;
import org.onosproject.store.service.Versioned;
@@ -36,8 +34,6 @@
import java.util.Set;
import java.util.stream.Stream;
-import static org.onosproject.store.resource.impl.ConsistentResourceStore.MAX_RETRIES;
-import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_DELAY;
import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER;
class ConsistentContinuousResourceSubStore {
@@ -54,8 +50,7 @@
.withSerializer(SERIALIZER)
.build();
- Tools.retryable(() -> childMap.put(Resource.ROOT.id(), new LinkedHashSet<>()),
- ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY);
+ childMap.put(Resource.ROOT.id(), new LinkedHashSet<>());
}
TransactionalContinuousResourceSubStore transactional(TransactionContext tx) {
diff --git a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDiscreteResourceSubStore.java b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDiscreteResourceSubStore.java
index c19e6c3..5650585 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDiscreteResourceSubStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/resource/impl/ConsistentDiscreteResourceSubStore.java
@@ -17,7 +17,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import org.onlab.util.Tools;
import org.onosproject.net.resource.DiscreteResource;
import org.onosproject.net.resource.DiscreteResourceId;
import org.onosproject.net.resource.Resource;
@@ -25,7 +24,6 @@
import org.onosproject.net.resource.ResourceConsumerId;
import org.onosproject.net.resource.Resources;
import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.ConsistentMapException;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.TransactionContext;
import org.onosproject.store.service.Versioned;
@@ -35,8 +33,6 @@
import java.util.Set;
import java.util.stream.Stream;
-import static org.onosproject.store.resource.impl.ConsistentResourceStore.MAX_RETRIES;
-import static org.onosproject.store.resource.impl.ConsistentResourceStore.RETRY_DELAY;
import static org.onosproject.store.resource.impl.ConsistentResourceStore.SERIALIZER;
class ConsistentDiscreteResourceSubStore {
@@ -53,8 +49,7 @@
.withSerializer(SERIALIZER)
.build();
- Tools.retryable(() -> childMap.put(Resource.ROOT.id(), DiscreteResources.empty()),
- ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY);
+ childMap.put(Resource.ROOT.id(), DiscreteResources.empty());
}
TransactionalDiscreteResourceSubStore transactional(TransactionContext tx) {
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 37fedba..16a6fc0 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
@@ -33,7 +33,6 @@
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.packet.Ethernet;
-import org.onlab.util.Tools;
import org.onosproject.cfg.ComponentConfigService;
import org.onosproject.cluster.ClusterMetadataService;
import org.onosproject.cluster.ClusterService;
@@ -70,7 +69,6 @@
import org.onosproject.net.provider.ProviderId;
import org.onosproject.provider.lldpcommon.LinkDiscovery;
import org.onosproject.provider.lldpcommon.LinkDiscoveryContext;
-import org.onosproject.store.service.ConsistentMapException;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
@@ -252,14 +250,10 @@
cfgRegistry.addListener(cfgListener);
factories.forEach(cfgRegistry::registerConfigFactory);
- SuppressionConfig cfg =
- Tools.retryable(() -> cfgRegistry.getConfig(appId, SuppressionConfig.class),
- ConsistentMapException.class, MAX_RETRIES, RETRY_DELAY).get();
+ SuppressionConfig cfg = cfgRegistry.getConfig(appId, SuppressionConfig.class);
if (cfg == null) {
// If no configuration is found, register default.
- cfg = Tools.retryable(this::setDefaultSuppressionConfig,
- ConsistentMapException.class,
- MAX_RETRIES, RETRY_DELAY).get();
+ cfg = this.setDefaultSuppressionConfig();
}
cfgListener.reconfigureSuppressionRules(cfg);