Committed by
Gerrit Code Review
Remove some of unnecessary register calls.
Partial fix for ONOS-4528 - String, primitives, and it's boxed type is pre-registered. https://github.com/EsotericSoftware/kryo#registration - Ip4Address part of MISC ⊂ API - DefaultPortStatistics, DeviceId part of API Change-Id: Iabf4b497f3680245bd8897c41c573febe936ff3d
Showing
4 changed files
with
22 additions
and
30 deletions
... | @@ -146,18 +146,13 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { | ... | @@ -146,18 +146,13 @@ public class OpenstackRoutingManager implements OpenstackRoutingService { |
146 | private static final KryoNamespace.Builder FLOATING_IP_SERIALIZER = KryoNamespace.newBuilder() | 146 | private static final KryoNamespace.Builder FLOATING_IP_SERIALIZER = KryoNamespace.newBuilder() |
147 | .register(KryoNamespaces.API) | 147 | .register(KryoNamespaces.API) |
148 | .register(OpenstackFloatingIP.FloatingIpStatus.class) | 148 | .register(OpenstackFloatingIP.FloatingIpStatus.class) |
149 | - .register(OpenstackFloatingIP.class) | 149 | + .register(OpenstackFloatingIP.class); |
150 | - .register(Ip4Address.class) | ||
151 | - .register(String.class); | ||
152 | 150 | ||
153 | private static final KryoNamespace.Builder NUMBER_SERIALIZER = KryoNamespace.newBuilder() | 151 | private static final KryoNamespace.Builder NUMBER_SERIALIZER = KryoNamespace.newBuilder() |
154 | - .register(KryoNamespaces.API) | 152 | + .register(KryoNamespaces.API); |
155 | - .register(Integer.class) | ||
156 | - .register(String.class); | ||
157 | 153 | ||
158 | private static final KryoNamespace.Builder ROUTER_INTERFACE_SERIALIZER = KryoNamespace.newBuilder() | 154 | private static final KryoNamespace.Builder ROUTER_INTERFACE_SERIALIZER = KryoNamespace.newBuilder() |
159 | - .register(KryoNamespaces.API) | 155 | + .register(KryoNamespaces.API); |
160 | - .register(String.class); | ||
161 | 156 | ||
162 | private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor(); | 157 | private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor(); |
163 | private InternalDeviceListener internalDeviceListener = new InternalDeviceListener(); | 158 | private InternalDeviceListener internalDeviceListener = new InternalDeviceListener(); | ... | ... |
... | @@ -236,8 +236,6 @@ public class GossipDeviceStore | ... | @@ -236,8 +236,6 @@ public class GossipDeviceStore |
236 | // Create a distributed map for port stats. | 236 | // Create a distributed map for port stats. |
237 | KryoNamespace.Builder deviceDataSerializer = KryoNamespace.newBuilder() | 237 | KryoNamespace.Builder deviceDataSerializer = KryoNamespace.newBuilder() |
238 | .register(KryoNamespaces.API) | 238 | .register(KryoNamespaces.API) |
239 | - .register(DefaultPortStatistics.class) | ||
240 | - .register(DeviceId.class) | ||
241 | .register(MultiValuedTimestamp.class) | 239 | .register(MultiValuedTimestamp.class) |
242 | .register(WallClockTimestamp.class); | 240 | .register(WallClockTimestamp.class); |
243 | 241 | ... | ... |
... | @@ -103,7 +103,7 @@ public class DistributedLabelResourceStore | ... | @@ -103,7 +103,7 @@ public class DistributedLabelResourceStore |
103 | private static final Serializer SERIALIZER = Serializer | 103 | private static final Serializer SERIALIZER = Serializer |
104 | .using(new KryoNamespace.Builder().register(KryoNamespaces.API) | 104 | .using(new KryoNamespace.Builder().register(KryoNamespaces.API) |
105 | .register(LabelResourceEvent.class) | 105 | .register(LabelResourceEvent.class) |
106 | - .register(LabelResourcePool.class).register(DeviceId.class) | 106 | + .register(LabelResourcePool.class) |
107 | .register(LabelResourceRequest.class) | 107 | .register(LabelResourceRequest.class) |
108 | .register(LabelResourceRequest.Type.class) | 108 | .register(LabelResourceRequest.Type.class) |
109 | .register(LabelResourceEvent.Type.class) | 109 | .register(LabelResourceEvent.Type.class) |
... | @@ -197,7 +197,7 @@ public class DistributedLabelResourceStore | ... | @@ -197,7 +197,7 @@ public class DistributedLabelResourceStore |
197 | } | 197 | } |
198 | 198 | ||
199 | private boolean create(LabelResourcePool pool) { | 199 | private boolean create(LabelResourcePool pool) { |
200 | - Device device = (Device) deviceService.getDevice(pool.deviceId()); | 200 | + Device device = deviceService.getDevice(pool.deviceId()); |
201 | if (device == null) { | 201 | if (device == null) { |
202 | return false; | 202 | return false; |
203 | } | 203 | } |
... | @@ -238,7 +238,7 @@ public class DistributedLabelResourceStore | ... | @@ -238,7 +238,7 @@ public class DistributedLabelResourceStore |
238 | 238 | ||
239 | @Override | 239 | @Override |
240 | public boolean destroyDevicePool(DeviceId deviceId) { | 240 | public boolean destroyDevicePool(DeviceId deviceId) { |
241 | - Device device = (Device) deviceService.getDevice(deviceId); | 241 | + Device device = deviceService.getDevice(deviceId); |
242 | if (device == null) { | 242 | if (device == null) { |
243 | return false; | 243 | return false; |
244 | } | 244 | } |
... | @@ -280,7 +280,7 @@ public class DistributedLabelResourceStore | ... | @@ -280,7 +280,7 @@ public class DistributedLabelResourceStore |
280 | @Override | 280 | @Override |
281 | public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId, | 281 | public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId, |
282 | long applyNum) { | 282 | long applyNum) { |
283 | - Device device = (Device) deviceService.getDevice(deviceId); | 283 | + Device device = deviceService.getDevice(deviceId); |
284 | if (device == null) { | 284 | if (device == null) { |
285 | return Collections.emptyList(); | 285 | return Collections.emptyList(); |
286 | } | 286 | } |
... | @@ -317,13 +317,13 @@ public class DistributedLabelResourceStore | ... | @@ -317,13 +317,13 @@ public class DistributedLabelResourceStore |
317 | return Collections.emptyList(); | 317 | return Collections.emptyList(); |
318 | } | 318 | } |
319 | LabelResourcePool pool = poolOld.value(); | 319 | LabelResourcePool pool = poolOld.value(); |
320 | - Collection<LabelResource> result = new HashSet<LabelResource>(); | 320 | + Collection<LabelResource> result = new HashSet<>(); |
321 | long freeNum = this.getFreeNumOfDevicePool(deviceId); | 321 | long freeNum = this.getFreeNumOfDevicePool(deviceId); |
322 | if (applyNum > freeNum) { | 322 | if (applyNum > freeNum) { |
323 | log.info("the free number of the label resource pool of deviceId {} is not enough."); | 323 | log.info("the free number of the label resource pool of deviceId {} is not enough."); |
324 | return Collections.emptyList(); | 324 | return Collections.emptyList(); |
325 | } | 325 | } |
326 | - Set<LabelResource> releaseLabels = new HashSet<LabelResource>(pool.releaseLabelId()); | 326 | + Set<LabelResource> releaseLabels = new HashSet<>(pool.releaseLabelId()); |
327 | long tmp = releaseLabels.size() > applyNum ? applyNum : releaseLabels | 327 | long tmp = releaseLabels.size() > applyNum ? applyNum : releaseLabels |
328 | .size(); | 328 | .size(); |
329 | LabelResource resource = null; | 329 | LabelResource resource = null; |
... | @@ -364,8 +364,8 @@ public class DistributedLabelResourceStore | ... | @@ -364,8 +364,8 @@ public class DistributedLabelResourceStore |
364 | Set<DeviceId> deviceIdSet = maps.keySet(); | 364 | Set<DeviceId> deviceIdSet = maps.keySet(); |
365 | LabelResourceRequest request = null; | 365 | LabelResourceRequest request = null; |
366 | for (Iterator<DeviceId> it = deviceIdSet.iterator(); it.hasNext();) { | 366 | for (Iterator<DeviceId> it = deviceIdSet.iterator(); it.hasNext();) { |
367 | - DeviceId deviceId = (DeviceId) it.next(); | 367 | + DeviceId deviceId = it.next(); |
368 | - Device device = (Device) deviceService.getDevice(deviceId); | 368 | + Device device = deviceService.getDevice(deviceId); |
369 | if (device == null) { | 369 | if (device == null) { |
370 | continue; | 370 | continue; |
371 | } | 371 | } |
... | @@ -410,7 +410,7 @@ public class DistributedLabelResourceStore | ... | @@ -410,7 +410,7 @@ public class DistributedLabelResourceStore |
410 | log.info("the label resource pool of device id {} does not exist"); | 410 | log.info("the label resource pool of device id {} does not exist"); |
411 | return false; | 411 | return false; |
412 | } | 412 | } |
413 | - Set<LabelResource> storeSet = new HashSet<LabelResource>(pool.releaseLabelId()); | 413 | + Set<LabelResource> storeSet = new HashSet<>(pool.releaseLabelId()); |
414 | LabelResource labelResource = null; | 414 | LabelResource labelResource = null; |
415 | long realReleasedNum = 0; | 415 | long realReleasedNum = 0; |
416 | for (Iterator<LabelResource> it = release.iterator(); it.hasNext();) { | 416 | for (Iterator<LabelResource> it = release.iterator(); it.hasNext();) { |
... | @@ -486,7 +486,7 @@ public class DistributedLabelResourceStore | ... | @@ -486,7 +486,7 @@ public class DistributedLabelResourceStore |
486 | 486 | ||
487 | @Override | 487 | @Override |
488 | public boolean releaseToGlobalPool(Set<LabelResourceId> release) { | 488 | public boolean releaseToGlobalPool(Set<LabelResourceId> release) { |
489 | - Set<LabelResource> set = new HashSet<LabelResource>(); | 489 | + Set<LabelResource> set = new HashSet<>(); |
490 | DefaultLabelResource resource = null; | 490 | DefaultLabelResource resource = null; |
491 | for (LabelResourceId labelResource : release) { | 491 | for (LabelResourceId labelResource : release) { |
492 | resource = new DefaultLabelResource(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID), | 492 | resource = new DefaultLabelResource(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID), | ... | ... |
... | @@ -123,7 +123,7 @@ public class DistributedVirtualNetworkStore | ... | @@ -123,7 +123,7 @@ public class DistributedVirtualNetworkStore |
123 | private static final Serializer SERIALIZER = Serializer | 123 | private static final Serializer SERIALIZER = Serializer |
124 | .using(new KryoNamespace.Builder().register(KryoNamespaces.API) | 124 | .using(new KryoNamespace.Builder().register(KryoNamespaces.API) |
125 | .register(TenantId.class) | 125 | .register(TenantId.class) |
126 | - .register(NetworkId.class).register(DeviceId.class) | 126 | + .register(NetworkId.class) |
127 | .register(VirtualNetwork.class) | 127 | .register(VirtualNetwork.class) |
128 | .register(DefaultVirtualNetwork.class) | 128 | .register(DefaultVirtualNetwork.class) |
129 | .register(VirtualDevice.class) | 129 | .register(VirtualDevice.class) |
... | @@ -132,7 +132,6 @@ public class DistributedVirtualNetworkStore | ... | @@ -132,7 +132,6 @@ public class DistributedVirtualNetworkStore |
132 | .register(DefaultVirtualLink.class) | 132 | .register(DefaultVirtualLink.class) |
133 | .register(VirtualPort.class) | 133 | .register(VirtualPort.class) |
134 | .register(DefaultVirtualPort.class) | 134 | .register(DefaultVirtualPort.class) |
135 | - .register(DeviceId.class) | ||
136 | .register(Device.class) | 135 | .register(Device.class) |
137 | .register(DefaultDevice.class) | 136 | .register(DefaultDevice.class) |
138 | .register(DefaultPort.class) | 137 | .register(DefaultPort.class) |
... | @@ -284,9 +283,9 @@ public class DistributedVirtualNetworkStore | ... | @@ -284,9 +283,9 @@ public class DistributedVirtualNetworkStore |
284 | 283 | ||
285 | tenantIdNetworkIdSetMap.compute(virtualNetwork.tenantId(), (id, existingNetworkIds) -> { | 284 | tenantIdNetworkIdSetMap.compute(virtualNetwork.tenantId(), (id, existingNetworkIds) -> { |
286 | if (existingNetworkIds == null || existingNetworkIds.isEmpty()) { | 285 | if (existingNetworkIds == null || existingNetworkIds.isEmpty()) { |
287 | - return new HashSet<NetworkId>(); | 286 | + return new HashSet<>(); |
288 | } else { | 287 | } else { |
289 | - return new HashSet<NetworkId>(Sets.difference(existingNetworkIds, networkIdSet)); | 288 | + return new HashSet<>(Sets.difference(existingNetworkIds, networkIdSet)); |
290 | } | 289 | } |
291 | }); | 290 | }); |
292 | } | 291 | } |
... | @@ -332,9 +331,9 @@ public class DistributedVirtualNetworkStore | ... | @@ -332,9 +331,9 @@ public class DistributedVirtualNetworkStore |
332 | if (deviceIdSet != null) { | 331 | if (deviceIdSet != null) { |
333 | networkIdDeviceIdSetMap.compute(networkId, (id, existingDeviceIds) -> { | 332 | networkIdDeviceIdSetMap.compute(networkId, (id, existingDeviceIds) -> { |
334 | if (existingDeviceIds == null || existingDeviceIds.isEmpty()) { | 333 | if (existingDeviceIds == null || existingDeviceIds.isEmpty()) { |
335 | - return new HashSet<DeviceId>(); | 334 | + return new HashSet<>(); |
336 | } else { | 335 | } else { |
337 | - return new HashSet<DeviceId>(Sets.difference(existingDeviceIds, deviceIdSet)); | 336 | + return new HashSet<>(Sets.difference(existingDeviceIds, deviceIdSet)); |
338 | } | 337 | } |
339 | }); | 338 | }); |
340 | 339 | ||
... | @@ -398,9 +397,9 @@ public class DistributedVirtualNetworkStore | ... | @@ -398,9 +397,9 @@ public class DistributedVirtualNetworkStore |
398 | if (virtualLinkSet != null) { | 397 | if (virtualLinkSet != null) { |
399 | networkIdVirtualLinkSetMap.compute(networkId, (id, existingVirtualLinks) -> { | 398 | networkIdVirtualLinkSetMap.compute(networkId, (id, existingVirtualLinks) -> { |
400 | if (existingVirtualLinks == null || existingVirtualLinks.isEmpty()) { | 399 | if (existingVirtualLinks == null || existingVirtualLinks.isEmpty()) { |
401 | - return new HashSet<VirtualLink>(); | 400 | + return new HashSet<>(); |
402 | } else { | 401 | } else { |
403 | - return new HashSet<VirtualLink>(Sets.difference(existingVirtualLinks, virtualLinkSet)); | 402 | + return new HashSet<>(Sets.difference(existingVirtualLinks, virtualLinkSet)); |
404 | } | 403 | } |
405 | }); | 404 | }); |
406 | } | 405 | } |
... | @@ -436,9 +435,9 @@ public class DistributedVirtualNetworkStore | ... | @@ -436,9 +435,9 @@ public class DistributedVirtualNetworkStore |
436 | if (virtualPortSet != null) { | 435 | if (virtualPortSet != null) { |
437 | networkIdVirtualPortSetMap.compute(networkId, (id, existingVirtualPorts) -> { | 436 | networkIdVirtualPortSetMap.compute(networkId, (id, existingVirtualPorts) -> { |
438 | if (existingVirtualPorts == null || existingVirtualPorts.isEmpty()) { | 437 | if (existingVirtualPorts == null || existingVirtualPorts.isEmpty()) { |
439 | - return new HashSet<VirtualPort>(); | 438 | + return new HashSet<>(); |
440 | } else { | 439 | } else { |
441 | - return new HashSet<VirtualPort>(Sets.difference(existingVirtualPorts, virtualPortSet)); | 440 | + return new HashSet<>(Sets.difference(existingVirtualPorts, virtualPortSet)); |
442 | } | 441 | } |
443 | }); | 442 | }); |
444 | } | 443 | } | ... | ... |
-
Please register or login to post a comment