Madan Jampani
Committed by Gerrit Code Review

New ApplicationStore that uses a single ConsistentMap to track all app related state

Change-Id: Ieacc97f213add8ece8f462cd9971fb6ef3d0dde5
(cherry picked from commit 6c02d9e1)
......@@ -96,7 +96,7 @@ public class Versioned<V> {
* @param <U> value type of the returned instance
* @return mapped instance
*/
public <U> Versioned<U> map(Function<V, U> transformer) {
public synchronized <U> Versioned<U> map(Function<V, U> transformer) {
return new Versioned<>(transformer.apply(value), version, creationTime);
}
......
......@@ -15,6 +15,6 @@
*/
/**
* Implementation of distributed applications store.
* Implementation of distributed application store.
*/
package org.onosproject.store.app;
......
......@@ -38,7 +38,6 @@ 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;
......@@ -109,8 +108,14 @@ public class DistributedApplicationIdStore implements ApplicationIdStore {
@Override
public ApplicationId registerApplication(String name) {
return Versioned.valueOrNull(registeredIds.computeIfAbsent(name,
key -> new DefaultApplicationId((int) appIdCounter.incrementAndGet(), name)));
ApplicationId exisitingAppId = registeredIds.asJavaMap().get(name);
if (exisitingAppId == null) {
ApplicationId newAppId = new DefaultApplicationId((int) appIdCounter.incrementAndGet(), name);
exisitingAppId = registeredIds.asJavaMap().putIfAbsent(name, newAppId);
return exisitingAppId == null ? newAppId : exisitingAppId;
} else {
return exisitingAppId;
}
}
private void primeIdToAppIdCache() {
......
......@@ -54,7 +54,6 @@ import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.store.AbstractStore;
import org.onosproject.store.app.GossipApplicationStore.InternalState;
import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.EventuallyConsistentMap;
......@@ -121,8 +120,7 @@ public class DistributedTunnelStore
public void activate() {
KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(MultiValuedTimestamp.class)
.register(InternalState.class);
.register(MultiValuedTimestamp.class);
tunnelIdAsKeyStore = storageService
.<TunnelId, Tunnel>eventuallyConsistentMapBuilder()
.withName("all_tunnel").withSerializer(serializer)
......