Register API in segment routing Kryo serializers.
Also use a different builder instance for each map. Change-Id: Id594ea708d7bc2cfa06d514f50273dd0f8cb45f6
Showing
2 changed files
with
56 additions
and
58 deletions
... | @@ -67,6 +67,11 @@ | ... | @@ -67,6 +67,11 @@ |
67 | <version>${project.version}</version> | 67 | <version>${project.version}</version> |
68 | </dependency> | 68 | </dependency> |
69 | <dependency> | 69 | <dependency> |
70 | + <groupId>org.onosproject</groupId> | ||
71 | + <artifactId>onos-core-serializers</artifactId> | ||
72 | + <version>${project.version}</version> | ||
73 | + </dependency> | ||
74 | + <dependency> | ||
70 | <groupId>javax.ws.rs</groupId> | 75 | <groupId>javax.ws.rs</groupId> |
71 | <artifactId>javax.ws.rs-api</artifactId> | 76 | <artifactId>javax.ws.rs-api</artifactId> |
72 | <version>2.0.1</version> | 77 | <version>2.0.1</version> | ... | ... |
... | @@ -22,64 +22,64 @@ import org.apache.felix.scr.annotations.Reference; | ... | @@ -22,64 +22,64 @@ import org.apache.felix.scr.annotations.Reference; |
22 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
23 | import org.apache.felix.scr.annotations.Service; | 23 | import org.apache.felix.scr.annotations.Service; |
24 | import org.onlab.packet.Ethernet; | 24 | import org.onlab.packet.Ethernet; |
25 | -import org.onlab.packet.MacAddress; | ||
26 | -import org.onlab.packet.VlanId; | ||
27 | import org.onlab.packet.IPv4; | 25 | import org.onlab.packet.IPv4; |
28 | -import org.onlab.packet.Ip4Address; | ||
29 | import org.onlab.packet.Ip4Prefix; | 26 | import org.onlab.packet.Ip4Prefix; |
30 | import org.onlab.packet.IpAddress; | 27 | import org.onlab.packet.IpAddress; |
31 | import org.onlab.packet.IpPrefix; | 28 | import org.onlab.packet.IpPrefix; |
29 | +import org.onlab.packet.MacAddress; | ||
30 | +import org.onlab.packet.VlanId; | ||
32 | import org.onlab.util.KryoNamespace; | 31 | import org.onlab.util.KryoNamespace; |
33 | import org.onosproject.cfg.ComponentConfigService; | 32 | import org.onosproject.cfg.ComponentConfigService; |
34 | import org.onosproject.core.ApplicationId; | 33 | import org.onosproject.core.ApplicationId; |
35 | import org.onosproject.core.CoreService; | 34 | import org.onosproject.core.CoreService; |
36 | import org.onosproject.event.Event; | 35 | import org.onosproject.event.Event; |
36 | +import org.onosproject.mastership.MastershipService; | ||
37 | import org.onosproject.net.ConnectPoint; | 37 | import org.onosproject.net.ConnectPoint; |
38 | +import org.onosproject.net.Device; | ||
39 | +import org.onosproject.net.DeviceId; | ||
40 | +import org.onosproject.net.Link; | ||
41 | +import org.onosproject.net.Port; | ||
38 | import org.onosproject.net.PortNumber; | 42 | import org.onosproject.net.PortNumber; |
39 | import org.onosproject.net.config.ConfigFactory; | 43 | import org.onosproject.net.config.ConfigFactory; |
40 | import org.onosproject.net.config.NetworkConfigEvent; | 44 | import org.onosproject.net.config.NetworkConfigEvent; |
41 | -import org.onosproject.net.config.NetworkConfigRegistry; | ||
42 | import org.onosproject.net.config.NetworkConfigListener; | 45 | import org.onosproject.net.config.NetworkConfigListener; |
46 | +import org.onosproject.net.config.NetworkConfigRegistry; | ||
43 | import org.onosproject.net.config.basics.SubjectFactories; | 47 | import org.onosproject.net.config.basics.SubjectFactories; |
48 | +import org.onosproject.net.device.DeviceEvent; | ||
49 | +import org.onosproject.net.device.DeviceListener; | ||
50 | +import org.onosproject.net.device.DeviceService; | ||
44 | import org.onosproject.net.flow.DefaultTrafficSelector; | 51 | import org.onosproject.net.flow.DefaultTrafficSelector; |
45 | import org.onosproject.net.flow.DefaultTrafficTreatment; | 52 | import org.onosproject.net.flow.DefaultTrafficTreatment; |
46 | import org.onosproject.net.flow.TrafficSelector; | 53 | import org.onosproject.net.flow.TrafficSelector; |
47 | import org.onosproject.net.flow.TrafficTreatment; | 54 | import org.onosproject.net.flow.TrafficTreatment; |
48 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; | 55 | import org.onosproject.net.flowobjective.DefaultForwardingObjective; |
56 | +import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
49 | import org.onosproject.net.flowobjective.ForwardingObjective; | 57 | import org.onosproject.net.flowobjective.ForwardingObjective; |
50 | import org.onosproject.net.flowobjective.Objective; | 58 | import org.onosproject.net.flowobjective.Objective; |
51 | import org.onosproject.net.flowobjective.ObjectiveContext; | 59 | import org.onosproject.net.flowobjective.ObjectiveContext; |
52 | import org.onosproject.net.flowobjective.ObjectiveError; | 60 | import org.onosproject.net.flowobjective.ObjectiveError; |
53 | import org.onosproject.net.host.HostEvent; | 61 | import org.onosproject.net.host.HostEvent; |
54 | import org.onosproject.net.host.HostListener; | 62 | import org.onosproject.net.host.HostListener; |
55 | -import org.onosproject.net.packet.PacketPriority; | ||
56 | -import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
57 | -import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
58 | -import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig; | ||
59 | -import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig; | ||
60 | -import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; | ||
61 | -import org.onosproject.segmentrouting.grouphandler.NeighborSet; | ||
62 | -import org.onosproject.segmentrouting.grouphandler.NeighborSetNextObjectiveStoreKey; | ||
63 | -import org.onosproject.segmentrouting.grouphandler.PortNextObjectiveStoreKey; | ||
64 | -import org.onosproject.mastership.MastershipService; | ||
65 | -import org.onosproject.net.Device; | ||
66 | -import org.onosproject.net.DeviceId; | ||
67 | -import org.onosproject.net.Link; | ||
68 | -import org.onosproject.net.Port; | ||
69 | -import org.onosproject.net.device.DeviceEvent; | ||
70 | -import org.onosproject.net.device.DeviceListener; | ||
71 | -import org.onosproject.net.device.DeviceService; | ||
72 | -import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
73 | import org.onosproject.net.host.HostService; | 63 | import org.onosproject.net.host.HostService; |
74 | import org.onosproject.net.link.LinkEvent; | 64 | import org.onosproject.net.link.LinkEvent; |
75 | import org.onosproject.net.link.LinkListener; | 65 | import org.onosproject.net.link.LinkListener; |
76 | import org.onosproject.net.link.LinkService; | 66 | import org.onosproject.net.link.LinkService; |
77 | import org.onosproject.net.packet.InboundPacket; | 67 | import org.onosproject.net.packet.InboundPacket; |
78 | import org.onosproject.net.packet.PacketContext; | 68 | import org.onosproject.net.packet.PacketContext; |
69 | +import org.onosproject.net.packet.PacketPriority; | ||
79 | import org.onosproject.net.packet.PacketProcessor; | 70 | import org.onosproject.net.packet.PacketProcessor; |
80 | import org.onosproject.net.packet.PacketService; | 71 | import org.onosproject.net.packet.PacketService; |
72 | +import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException; | ||
73 | +import org.onosproject.segmentrouting.config.DeviceConfiguration; | ||
74 | +import org.onosproject.segmentrouting.config.SegmentRoutingAppConfig; | ||
75 | +import org.onosproject.segmentrouting.config.SegmentRoutingDeviceConfig; | ||
76 | +import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler; | ||
77 | +import org.onosproject.segmentrouting.grouphandler.NeighborSet; | ||
78 | +import org.onosproject.segmentrouting.grouphandler.NeighborSetNextObjectiveStoreKey; | ||
79 | +import org.onosproject.segmentrouting.grouphandler.PortNextObjectiveStoreKey; | ||
81 | import org.onosproject.segmentrouting.grouphandler.SubnetNextObjectiveStoreKey; | 80 | import org.onosproject.segmentrouting.grouphandler.SubnetNextObjectiveStoreKey; |
82 | import org.onosproject.segmentrouting.grouphandler.XConnectNextObjectiveStoreKey; | 81 | import org.onosproject.segmentrouting.grouphandler.XConnectNextObjectiveStoreKey; |
82 | +import org.onosproject.store.serializers.KryoNamespaces; | ||
83 | import org.onosproject.store.service.EventuallyConsistentMap; | 83 | import org.onosproject.store.service.EventuallyConsistentMap; |
84 | import org.onosproject.store.service.EventuallyConsistentMapBuilder; | 84 | import org.onosproject.store.service.EventuallyConsistentMapBuilder; |
85 | import org.onosproject.store.service.StorageService; | 85 | import org.onosproject.store.service.StorageService; |
... | @@ -87,7 +87,6 @@ import org.onosproject.store.service.WallClockTimestamp; | ... | @@ -87,7 +87,6 @@ import org.onosproject.store.service.WallClockTimestamp; |
87 | import org.slf4j.Logger; | 87 | import org.slf4j.Logger; |
88 | import org.slf4j.LoggerFactory; | 88 | import org.slf4j.LoggerFactory; |
89 | 89 | ||
90 | -import java.net.URI; | ||
91 | import java.util.Collections; | 90 | import java.util.Collections; |
92 | import java.util.HashSet; | 91 | import java.util.HashSet; |
93 | import java.util.List; | 92 | import java.util.List; |
... | @@ -103,11 +102,12 @@ import java.util.concurrent.TimeUnit; | ... | @@ -103,11 +102,12 @@ import java.util.concurrent.TimeUnit; |
103 | 102 | ||
104 | import static com.google.common.base.Preconditions.checkState; | 103 | import static com.google.common.base.Preconditions.checkState; |
105 | 104 | ||
106 | -@Service | 105 | + |
107 | -@Component(immediate = true) | ||
108 | /** | 106 | /** |
109 | * Segment routing manager. | 107 | * Segment routing manager. |
110 | */ | 108 | */ |
109 | +@Service | ||
110 | +@Component(immediate = true) | ||
111 | public class SegmentRoutingManager implements SegmentRoutingService { | 111 | public class SegmentRoutingManager implements SegmentRoutingService { |
112 | 112 | ||
113 | private static Logger log = LoggerFactory | 113 | private static Logger log = LoggerFactory |
... | @@ -225,7 +225,6 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -225,7 +225,6 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
225 | private static int numOfHandlerExecution = 0; | 225 | private static int numOfHandlerExecution = 0; |
226 | private static int numOfHandlerScheduled = 0; | 226 | private static int numOfHandlerScheduled = 0; |
227 | 227 | ||
228 | - private KryoNamespace.Builder kryoBuilder = null; | ||
229 | /** | 228 | /** |
230 | * Segment Routing App ID. | 229 | * Segment Routing App ID. |
231 | */ | 230 | */ |
... | @@ -241,37 +240,14 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -241,37 +240,14 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
241 | 240 | ||
242 | @Activate | 241 | @Activate |
243 | protected void activate() { | 242 | protected void activate() { |
244 | - appId = coreService | 243 | + appId = coreService.registerApplication(SR_APP_ID); |
245 | - .registerApplication(SR_APP_ID); | ||
246 | - | ||
247 | - kryoBuilder = new KryoNamespace.Builder() | ||
248 | - .register(NeighborSetNextObjectiveStoreKey.class, | ||
249 | - SubnetNextObjectiveStoreKey.class, | ||
250 | - SubnetAssignedVidStoreKey.class, | ||
251 | - NeighborSet.class, | ||
252 | - DeviceId.class, | ||
253 | - URI.class, | ||
254 | - WallClockTimestamp.class, | ||
255 | - org.onosproject.cluster.NodeId.class, | ||
256 | - HashSet.class, | ||
257 | - Tunnel.class, | ||
258 | - DefaultTunnel.class, | ||
259 | - Policy.class, | ||
260 | - TunnelPolicy.class, | ||
261 | - Policy.Type.class, | ||
262 | - VlanId.class, | ||
263 | - Ip4Address.class, | ||
264 | - Ip4Prefix.class, | ||
265 | - IpAddress.Version.class, | ||
266 | - ConnectPoint.class | ||
267 | - ); | ||
268 | 244 | ||
269 | log.debug("Creating EC map nsnextobjectivestore"); | 245 | log.debug("Creating EC map nsnextobjectivestore"); |
270 | EventuallyConsistentMapBuilder<NeighborSetNextObjectiveStoreKey, Integer> | 246 | EventuallyConsistentMapBuilder<NeighborSetNextObjectiveStoreKey, Integer> |
271 | nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); | 247 | nsNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
272 | nsNextObjStore = nsNextObjMapBuilder | 248 | nsNextObjStore = nsNextObjMapBuilder |
273 | .withName("nsnextobjectivestore") | 249 | .withName("nsnextobjectivestore") |
274 | - .withSerializer(kryoBuilder) | 250 | + .withSerializer(createSerializer()) |
275 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) | 251 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
276 | .build(); | 252 | .build(); |
277 | log.trace("Current size {}", nsNextObjStore.size()); | 253 | log.trace("Current size {}", nsNextObjStore.size()); |
... | @@ -281,7 +257,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -281,7 +257,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
281 | subnetNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); | 257 | subnetNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
282 | subnetNextObjStore = subnetNextObjMapBuilder | 258 | subnetNextObjStore = subnetNextObjMapBuilder |
283 | .withName("subnetnextobjectivestore") | 259 | .withName("subnetnextobjectivestore") |
284 | - .withSerializer(kryoBuilder) | 260 | + .withSerializer(createSerializer()) |
285 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) | 261 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
286 | .build(); | 262 | .build(); |
287 | 263 | ||
... | @@ -290,7 +266,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -290,7 +266,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
290 | portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); | 266 | portNextObjMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
291 | portNextObjStore = portNextObjMapBuilder | 267 | portNextObjStore = portNextObjMapBuilder |
292 | .withName("portnextobjectivestore") | 268 | .withName("portnextobjectivestore") |
293 | - .withSerializer(kryoBuilder) | 269 | + .withSerializer(createSerializer()) |
294 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) | 270 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
295 | .build(); | 271 | .build(); |
296 | 272 | ||
... | @@ -299,7 +275,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -299,7 +275,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
299 | xConnectNextObjStoreBuilder = storageService.eventuallyConsistentMapBuilder(); | 275 | xConnectNextObjStoreBuilder = storageService.eventuallyConsistentMapBuilder(); |
300 | xConnectNextObjStore = xConnectNextObjStoreBuilder | 276 | xConnectNextObjStore = xConnectNextObjStoreBuilder |
301 | .withName("xconnectnextobjectivestore") | 277 | .withName("xconnectnextobjectivestore") |
302 | - .withSerializer(kryoBuilder) | 278 | + .withSerializer(createSerializer()) |
303 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) | 279 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
304 | .build(); | 280 | .build(); |
305 | 281 | ||
... | @@ -307,7 +283,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -307,7 +283,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
307 | storageService.eventuallyConsistentMapBuilder(); | 283 | storageService.eventuallyConsistentMapBuilder(); |
308 | tunnelStore = tunnelMapBuilder | 284 | tunnelStore = tunnelMapBuilder |
309 | .withName("tunnelstore") | 285 | .withName("tunnelstore") |
310 | - .withSerializer(kryoBuilder) | 286 | + .withSerializer(createSerializer()) |
311 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) | 287 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
312 | .build(); | 288 | .build(); |
313 | 289 | ||
... | @@ -315,7 +291,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -315,7 +291,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
315 | storageService.eventuallyConsistentMapBuilder(); | 291 | storageService.eventuallyConsistentMapBuilder(); |
316 | policyStore = policyMapBuilder | 292 | policyStore = policyMapBuilder |
317 | .withName("policystore") | 293 | .withName("policystore") |
318 | - .withSerializer(kryoBuilder) | 294 | + .withSerializer(createSerializer()) |
319 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) | 295 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
320 | .build(); | 296 | .build(); |
321 | 297 | ||
... | @@ -323,7 +299,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -323,7 +299,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
323 | subnetVidStoreMapBuilder = storageService.eventuallyConsistentMapBuilder(); | 299 | subnetVidStoreMapBuilder = storageService.eventuallyConsistentMapBuilder(); |
324 | subnetVidStore = subnetVidStoreMapBuilder | 300 | subnetVidStore = subnetVidStoreMapBuilder |
325 | .withName("subnetvidstore") | 301 | .withName("subnetvidstore") |
326 | - .withSerializer(kryoBuilder) | 302 | + .withSerializer(createSerializer()) |
327 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) | 303 | .withTimestampProvider((k, v) -> new WallClockTimestamp()) |
328 | .build(); | 304 | .build(); |
329 | 305 | ||
... | @@ -355,6 +331,23 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -355,6 +331,23 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
355 | log.info("Started"); | 331 | log.info("Started"); |
356 | } | 332 | } |
357 | 333 | ||
334 | + private KryoNamespace.Builder createSerializer() { | ||
335 | + return new KryoNamespace.Builder() | ||
336 | + .register(KryoNamespaces.API) | ||
337 | + .register(NeighborSetNextObjectiveStoreKey.class, | ||
338 | + SubnetNextObjectiveStoreKey.class, | ||
339 | + SubnetAssignedVidStoreKey.class, | ||
340 | + NeighborSet.class, | ||
341 | + Tunnel.class, | ||
342 | + DefaultTunnel.class, | ||
343 | + Policy.class, | ||
344 | + TunnelPolicy.class, | ||
345 | + Policy.Type.class, | ||
346 | + PortNextObjectiveStoreKey.class, | ||
347 | + XConnectNextObjectiveStoreKey.class | ||
348 | + ); | ||
349 | + } | ||
350 | + | ||
358 | @Deactivate | 351 | @Deactivate |
359 | protected void deactivate() { | 352 | protected void deactivate() { |
360 | cfgService.removeListener(cfgListener); | 353 | cfgService.removeListener(cfgListener); |
... | @@ -649,7 +642,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { | ... | @@ -649,7 +642,7 @@ public class SegmentRoutingManager implements SegmentRoutingService { |
649 | .schedule(eventHandler, 100, TimeUnit.MILLISECONDS); | 642 | .schedule(eventHandler, 100, TimeUnit.MILLISECONDS); |
650 | numOfHandlerScheduled++; | 643 | numOfHandlerScheduled++; |
651 | } | 644 | } |
652 | - log.trace("numOfEventsQueued {}, numOfEventHanlderScheduled {}", | 645 | + log.trace("numOfEventsQueued {}, numOfEventHandlerScheduled {}", |
653 | numOfEventsQueued, | 646 | numOfEventsQueued, |
654 | numOfHandlerScheduled); | 647 | numOfHandlerScheduled); |
655 | } | 648 | } | ... | ... |
-
Please register or login to post a comment