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)
Showing
5 changed files
with
11 additions
and
8 deletions
... | @@ -96,7 +96,7 @@ public class Versioned<V> { | ... | @@ -96,7 +96,7 @@ public class Versioned<V> { |
96 | * @param <U> value type of the returned instance | 96 | * @param <U> value type of the returned instance |
97 | * @return mapped instance | 97 | * @return mapped instance |
98 | */ | 98 | */ |
99 | - public <U> Versioned<U> map(Function<V, U> transformer) { | 99 | + public synchronized <U> Versioned<U> map(Function<V, U> transformer) { |
100 | return new Versioned<>(transformer.apply(value), version, creationTime); | 100 | return new Versioned<>(transformer.apply(value), version, creationTime); |
101 | } | 101 | } |
102 | 102 | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -38,7 +38,6 @@ import org.onosproject.store.service.MapEvent; | ... | @@ -38,7 +38,6 @@ import org.onosproject.store.service.MapEvent; |
38 | import org.onosproject.store.service.MapEventListener; | 38 | import org.onosproject.store.service.MapEventListener; |
39 | import org.onosproject.store.service.Serializer; | 39 | import org.onosproject.store.service.Serializer; |
40 | import org.onosproject.store.service.StorageService; | 40 | import org.onosproject.store.service.StorageService; |
41 | -import org.onosproject.store.service.Versioned; | ||
42 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
43 | 42 | ||
44 | 43 | ||
... | @@ -109,8 +108,14 @@ public class DistributedApplicationIdStore implements ApplicationIdStore { | ... | @@ -109,8 +108,14 @@ public class DistributedApplicationIdStore implements ApplicationIdStore { |
109 | 108 | ||
110 | @Override | 109 | @Override |
111 | public ApplicationId registerApplication(String name) { | 110 | public ApplicationId registerApplication(String name) { |
112 | - return Versioned.valueOrNull(registeredIds.computeIfAbsent(name, | 111 | + ApplicationId exisitingAppId = registeredIds.asJavaMap().get(name); |
113 | - key -> new DefaultApplicationId((int) appIdCounter.incrementAndGet(), name))); | 112 | + if (exisitingAppId == null) { |
113 | + ApplicationId newAppId = new DefaultApplicationId((int) appIdCounter.incrementAndGet(), name); | ||
114 | + exisitingAppId = registeredIds.asJavaMap().putIfAbsent(name, newAppId); | ||
115 | + return exisitingAppId == null ? newAppId : exisitingAppId; | ||
116 | + } else { | ||
117 | + return exisitingAppId; | ||
118 | + } | ||
114 | } | 119 | } |
115 | 120 | ||
116 | private void primeIdToAppIdCache() { | 121 | private void primeIdToAppIdCache() { | ... | ... |
... | @@ -54,7 +54,6 @@ import org.onosproject.net.DefaultAnnotations; | ... | @@ -54,7 +54,6 @@ import org.onosproject.net.DefaultAnnotations; |
54 | import org.onosproject.net.SparseAnnotations; | 54 | import org.onosproject.net.SparseAnnotations; |
55 | import org.onosproject.net.provider.ProviderId; | 55 | import org.onosproject.net.provider.ProviderId; |
56 | import org.onosproject.store.AbstractStore; | 56 | import org.onosproject.store.AbstractStore; |
57 | -import org.onosproject.store.app.GossipApplicationStore.InternalState; | ||
58 | import org.onosproject.store.cluster.messaging.ClusterCommunicationService; | 57 | import org.onosproject.store.cluster.messaging.ClusterCommunicationService; |
59 | import org.onosproject.store.serializers.KryoNamespaces; | 58 | import org.onosproject.store.serializers.KryoNamespaces; |
60 | import org.onosproject.store.service.EventuallyConsistentMap; | 59 | import org.onosproject.store.service.EventuallyConsistentMap; |
... | @@ -121,8 +120,7 @@ public class DistributedTunnelStore | ... | @@ -121,8 +120,7 @@ public class DistributedTunnelStore |
121 | public void activate() { | 120 | public void activate() { |
122 | KryoNamespace.Builder serializer = KryoNamespace.newBuilder() | 121 | KryoNamespace.Builder serializer = KryoNamespace.newBuilder() |
123 | .register(KryoNamespaces.API) | 122 | .register(KryoNamespaces.API) |
124 | - .register(MultiValuedTimestamp.class) | 123 | + .register(MultiValuedTimestamp.class); |
125 | - .register(InternalState.class); | ||
126 | tunnelIdAsKeyStore = storageService | 124 | tunnelIdAsKeyStore = storageService |
127 | .<TunnelId, Tunnel>eventuallyConsistentMapBuilder() | 125 | .<TunnelId, Tunnel>eventuallyConsistentMapBuilder() |
128 | .withName("all_tunnel").withSerializer(serializer) | 126 | .withName("all_tunnel").withSerializer(serializer) | ... | ... |
-
Please register or login to post a comment