HIGUCHI Yuta
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
......@@ -146,18 +146,13 @@ public class OpenstackRoutingManager implements OpenstackRoutingService {
private static final KryoNamespace.Builder FLOATING_IP_SERIALIZER = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(OpenstackFloatingIP.FloatingIpStatus.class)
.register(OpenstackFloatingIP.class)
.register(Ip4Address.class)
.register(String.class);
.register(OpenstackFloatingIP.class);
private static final KryoNamespace.Builder NUMBER_SERIALIZER = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(Integer.class)
.register(String.class);
.register(KryoNamespaces.API);
private static final KryoNamespace.Builder ROUTER_INTERFACE_SERIALIZER = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(String.class);
.register(KryoNamespaces.API);
private InternalPacketProcessor internalPacketProcessor = new InternalPacketProcessor();
private InternalDeviceListener internalDeviceListener = new InternalDeviceListener();
......
......@@ -236,8 +236,6 @@ public class GossipDeviceStore
// Create a distributed map for port stats.
KryoNamespace.Builder deviceDataSerializer = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
.register(DefaultPortStatistics.class)
.register(DeviceId.class)
.register(MultiValuedTimestamp.class)
.register(WallClockTimestamp.class);
......
......@@ -103,7 +103,7 @@ public class DistributedLabelResourceStore
private static final Serializer SERIALIZER = Serializer
.using(new KryoNamespace.Builder().register(KryoNamespaces.API)
.register(LabelResourceEvent.class)
.register(LabelResourcePool.class).register(DeviceId.class)
.register(LabelResourcePool.class)
.register(LabelResourceRequest.class)
.register(LabelResourceRequest.Type.class)
.register(LabelResourceEvent.Type.class)
......@@ -197,7 +197,7 @@ public class DistributedLabelResourceStore
}
private boolean create(LabelResourcePool pool) {
Device device = (Device) deviceService.getDevice(pool.deviceId());
Device device = deviceService.getDevice(pool.deviceId());
if (device == null) {
return false;
}
......@@ -238,7 +238,7 @@ public class DistributedLabelResourceStore
@Override
public boolean destroyDevicePool(DeviceId deviceId) {
Device device = (Device) deviceService.getDevice(deviceId);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
return false;
}
......@@ -280,7 +280,7 @@ public class DistributedLabelResourceStore
@Override
public Collection<LabelResource> applyFromDevicePool(DeviceId deviceId,
long applyNum) {
Device device = (Device) deviceService.getDevice(deviceId);
Device device = deviceService.getDevice(deviceId);
if (device == null) {
return Collections.emptyList();
}
......@@ -317,13 +317,13 @@ public class DistributedLabelResourceStore
return Collections.emptyList();
}
LabelResourcePool pool = poolOld.value();
Collection<LabelResource> result = new HashSet<LabelResource>();
Collection<LabelResource> result = new HashSet<>();
long freeNum = this.getFreeNumOfDevicePool(deviceId);
if (applyNum > freeNum) {
log.info("the free number of the label resource pool of deviceId {} is not enough.");
return Collections.emptyList();
}
Set<LabelResource> releaseLabels = new HashSet<LabelResource>(pool.releaseLabelId());
Set<LabelResource> releaseLabels = new HashSet<>(pool.releaseLabelId());
long tmp = releaseLabels.size() > applyNum ? applyNum : releaseLabels
.size();
LabelResource resource = null;
......@@ -364,8 +364,8 @@ public class DistributedLabelResourceStore
Set<DeviceId> deviceIdSet = maps.keySet();
LabelResourceRequest request = null;
for (Iterator<DeviceId> it = deviceIdSet.iterator(); it.hasNext();) {
DeviceId deviceId = (DeviceId) it.next();
Device device = (Device) deviceService.getDevice(deviceId);
DeviceId deviceId = it.next();
Device device = deviceService.getDevice(deviceId);
if (device == null) {
continue;
}
......@@ -410,7 +410,7 @@ public class DistributedLabelResourceStore
log.info("the label resource pool of device id {} does not exist");
return false;
}
Set<LabelResource> storeSet = new HashSet<LabelResource>(pool.releaseLabelId());
Set<LabelResource> storeSet = new HashSet<>(pool.releaseLabelId());
LabelResource labelResource = null;
long realReleasedNum = 0;
for (Iterator<LabelResource> it = release.iterator(); it.hasNext();) {
......@@ -486,7 +486,7 @@ public class DistributedLabelResourceStore
@Override
public boolean releaseToGlobalPool(Set<LabelResourceId> release) {
Set<LabelResource> set = new HashSet<LabelResource>();
Set<LabelResource> set = new HashSet<>();
DefaultLabelResource resource = null;
for (LabelResourceId labelResource : release) {
resource = new DefaultLabelResource(DeviceId.deviceId(GLOBAL_RESOURCE_POOL_DEVICE_ID),
......
......@@ -123,7 +123,7 @@ public class DistributedVirtualNetworkStore
private static final Serializer SERIALIZER = Serializer
.using(new KryoNamespace.Builder().register(KryoNamespaces.API)
.register(TenantId.class)
.register(NetworkId.class).register(DeviceId.class)
.register(NetworkId.class)
.register(VirtualNetwork.class)
.register(DefaultVirtualNetwork.class)
.register(VirtualDevice.class)
......@@ -132,7 +132,6 @@ public class DistributedVirtualNetworkStore
.register(DefaultVirtualLink.class)
.register(VirtualPort.class)
.register(DefaultVirtualPort.class)
.register(DeviceId.class)
.register(Device.class)
.register(DefaultDevice.class)
.register(DefaultPort.class)
......@@ -284,9 +283,9 @@ public class DistributedVirtualNetworkStore
tenantIdNetworkIdSetMap.compute(virtualNetwork.tenantId(), (id, existingNetworkIds) -> {
if (existingNetworkIds == null || existingNetworkIds.isEmpty()) {
return new HashSet<NetworkId>();
return new HashSet<>();
} else {
return new HashSet<NetworkId>(Sets.difference(existingNetworkIds, networkIdSet));
return new HashSet<>(Sets.difference(existingNetworkIds, networkIdSet));
}
});
}
......@@ -332,9 +331,9 @@ public class DistributedVirtualNetworkStore
if (deviceIdSet != null) {
networkIdDeviceIdSetMap.compute(networkId, (id, existingDeviceIds) -> {
if (existingDeviceIds == null || existingDeviceIds.isEmpty()) {
return new HashSet<DeviceId>();
return new HashSet<>();
} else {
return new HashSet<DeviceId>(Sets.difference(existingDeviceIds, deviceIdSet));
return new HashSet<>(Sets.difference(existingDeviceIds, deviceIdSet));
}
});
......@@ -398,9 +397,9 @@ public class DistributedVirtualNetworkStore
if (virtualLinkSet != null) {
networkIdVirtualLinkSetMap.compute(networkId, (id, existingVirtualLinks) -> {
if (existingVirtualLinks == null || existingVirtualLinks.isEmpty()) {
return new HashSet<VirtualLink>();
return new HashSet<>();
} else {
return new HashSet<VirtualLink>(Sets.difference(existingVirtualLinks, virtualLinkSet));
return new HashSet<>(Sets.difference(existingVirtualLinks, virtualLinkSet));
}
});
}
......@@ -436,9 +435,9 @@ public class DistributedVirtualNetworkStore
if (virtualPortSet != null) {
networkIdVirtualPortSetMap.compute(networkId, (id, existingVirtualPorts) -> {
if (existingVirtualPorts == null || existingVirtualPorts.isEmpty()) {
return new HashSet<VirtualPort>();
return new HashSet<>();
} else {
return new HashSet<VirtualPort>(Sets.difference(existingVirtualPorts, virtualPortSet));
return new HashSet<>(Sets.difference(existingVirtualPorts, virtualPortSet));
}
});
}
......