From 05a1ba1dc91791a110f00d6723715f7090adb4f5 Mon Sep 17 00:00:00 2001 From: Zsolt Haraszti Date: Thu, 25 Feb 2016 09:39:10 -0800 Subject: [PATCH] Use allocateNextId when building new NextObjective In order to avoid nextId collisions, all users of the flow objective service should use the provided allocateNextId() method when constructing new NextObjectives. I found one instance where this was not the case: CordMcast. Solution: removed private id generator from CordMacst and replaced it with allocateNextId. Change-Id: I134931b58c524291ae937dd6f0051ee549236734 --- .../main/java/org/onosproject/cordmcast/CordMcast.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/apps/cordmcast/src/main/java/org/onosproject/cordmcast/CordMcast.java b/apps/cordmcast/src/main/java/org/onosproject/cordmcast/CordMcast.java index 09818798a4..661141489a 100644 --- a/apps/cordmcast/src/main/java/org/onosproject/cordmcast/CordMcast.java +++ b/apps/cordmcast/src/main/java/org/onosproject/cordmcast/CordMcast.java @@ -77,7 +77,6 @@ import java.util.Map; import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicInteger; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Strings.isNullOrEmpty; @@ -129,9 +128,6 @@ public class CordMcast { //TODO: move this to a ec map private Map groups = Maps.newConcurrentMap(); - //TODO: move this to distributed atomic long - private AtomicInteger channels = new AtomicInteger(0); - private ApplicationId appId; @Property(name = "mcastVlan", intValue = DEFAULT_MCAST_VLAN, @@ -331,7 +327,7 @@ public class CordMcast { final AtomicBoolean sync = new AtomicBoolean(false); Integer nextId = groups.computeIfAbsent(route.group(), (g) -> { - Integer id = allocateId(); + Integer id = flowObjectiveService.allocateNextId(); NextObjective next = DefaultNextObjective.builder() .fromApp(appId) @@ -497,10 +493,6 @@ public class CordMcast { mcastRoutes.forEach(this::removeRemoteRoute); } - private Integer allocateId() { - return channels.getAndIncrement(); - } - private WebResource.Builder getClientBuilder(String uri) { Client client = Client.create(); client.setConnectTimeout(DEFAULT_REST_TIMEOUT_MS);