alshabib
Committed by Gerrit Code Review

making the olt pipeline support distributed cookie values.

Change-Id: I8e9d1c2736c0b62b887ef621e148a2bce6fe620e
...@@ -72,6 +72,8 @@ import org.onosproject.net.group.GroupKey; ...@@ -72,6 +72,8 @@ import org.onosproject.net.group.GroupKey;
72 import org.onosproject.net.group.GroupListener; 72 import org.onosproject.net.group.GroupListener;
73 import org.onosproject.net.group.GroupService; 73 import org.onosproject.net.group.GroupService;
74 import org.onosproject.store.serializers.KryoNamespaces; 74 import org.onosproject.store.serializers.KryoNamespaces;
75 +import org.onosproject.store.service.AtomicCounter;
76 +import org.onosproject.store.service.StorageService;
75 import org.slf4j.Logger; 77 import org.slf4j.Logger;
76 78
77 import java.util.Collection; 79 import java.util.Collection;
...@@ -79,7 +81,6 @@ import java.util.Collections; ...@@ -79,7 +81,6 @@ import java.util.Collections;
79 import java.util.List; 81 import java.util.List;
80 import java.util.Optional; 82 import java.util.Optional;
81 import java.util.concurrent.TimeUnit; 83 import java.util.concurrent.TimeUnit;
82 -import java.util.concurrent.atomic.AtomicLong;
83 import java.util.stream.Collectors; 84 import java.util.stream.Collectors;
84 85
85 import static org.slf4j.LoggerFactory.getLogger; 86 import static org.slf4j.LoggerFactory.getLogger;
...@@ -92,18 +93,20 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { ...@@ -92,18 +93,20 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner {
92 93
93 private static final Integer QQ_TABLE = 1; 94 private static final Integer QQ_TABLE = 1;
94 private static final short MCAST_VLAN = 4000; 95 private static final short MCAST_VLAN = 4000;
96 + private static final String OLTCOOKIES = "olt-cookies-must-be-unique";
95 private final Logger log = getLogger(getClass()); 97 private final Logger log = getLogger(getClass());
96 98
97 private ServiceDirectory serviceDirectory; 99 private ServiceDirectory serviceDirectory;
98 private FlowRuleService flowRuleService; 100 private FlowRuleService flowRuleService;
99 private GroupService groupService; 101 private GroupService groupService;
100 private CoreService coreService; 102 private CoreService coreService;
103 + private StorageService storageService;
101 104
102 private DeviceId deviceId; 105 private DeviceId deviceId;
103 private ApplicationId appId; 106 private ApplicationId appId;
104 // NOTE: OLT currently has some issue with cookie 0. Pick something larger 107 // NOTE: OLT currently has some issue with cookie 0. Pick something larger
105 // to avoid collision 108 // to avoid collision
106 - private AtomicLong counter = new AtomicLong(123); 109 + private AtomicCounter counter;
107 110
108 protected FlowObjectiveStore flowObjectiveStore; 111 protected FlowObjectiveStore flowObjectiveStore;
109 112
...@@ -127,6 +130,18 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner { ...@@ -127,6 +130,18 @@ public class OltPipeline extends AbstractHandlerBehaviour implements Pipeliner {
127 coreService = serviceDirectory.get(CoreService.class); 130 coreService = serviceDirectory.get(CoreService.class);
128 groupService = serviceDirectory.get(GroupService.class); 131 groupService = serviceDirectory.get(GroupService.class);
129 flowObjectiveStore = context.store(); 132 flowObjectiveStore = context.store();
133 + storageService = serviceDirectory.get(StorageService.class);
134 +
135 + counter = storageService.atomicCounterBuilder()
136 + .withName(String.format(OLTCOOKIES, deviceId))
137 + .build()
138 + .asAtomicCounter();
139 +
140 + /*
141 + magic olt number to make sure we don't collide with it's internal
142 + processing
143 + */
144 + counter.set(123);
130 145
131 146
132 appId = coreService.registerApplication( 147 appId = coreService.registerApplication(
......