HIGUCHI Yuta
Committed by Thomas Vachuska

Deprecate KryoSerializer.

Change-Id: I2403b95c2d7a8af69dff55a0e40a35b223127c85
Showing 16 changed files with 97 additions and 156 deletions
...@@ -43,7 +43,7 @@ import org.onosproject.store.AbstractStore; ...@@ -43,7 +43,7 @@ import org.onosproject.store.AbstractStore;
43 import org.onosproject.store.cluster.messaging.Endpoint; 43 import org.onosproject.store.cluster.messaging.Endpoint;
44 import org.onosproject.store.cluster.messaging.MessagingService; 44 import org.onosproject.store.cluster.messaging.MessagingService;
45 import org.onosproject.store.serializers.KryoNamespaces; 45 import org.onosproject.store.serializers.KryoNamespaces;
46 -import org.onosproject.store.serializers.KryoSerializer; 46 +import org.onosproject.store.serializers.StoreSerializer;
47 import org.osgi.service.component.ComponentContext; 47 import org.osgi.service.component.ComponentContext;
48 import org.slf4j.Logger; 48 import org.slf4j.Logger;
49 49
...@@ -90,16 +90,12 @@ public class DistributedClusterStore ...@@ -90,16 +90,12 @@ public class DistributedClusterStore
90 label = "the value of Phi threshold to detect accrual failure") 90 label = "the value of Phi threshold to detect accrual failure")
91 private int phiFailureThreshold = DEFAULT_PHI_FAILURE_THRESHOLD; 91 private int phiFailureThreshold = DEFAULT_PHI_FAILURE_THRESHOLD;
92 92
93 - private static final KryoSerializer SERIALIZER = new KryoSerializer() { 93 + private static final StoreSerializer SERIALIZER = StoreSerializer.using(
94 - @Override 94 + KryoNamespace.newBuilder()
95 - protected void setupKryoPool() {
96 - serializerPool = KryoNamespace.newBuilder()
97 .register(KryoNamespaces.API) 95 .register(KryoNamespaces.API)
96 + .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
98 .register(HeartbeatMessage.class) 97 .register(HeartbeatMessage.class)
99 - .build() 98 + .build("ClusterStore"));
100 - .populate(1);
101 - }
102 - };
103 99
104 private static final String INSTANCE_ID_NULL = "Instance ID cannot be null"; 100 private static final String INSTANCE_ID_NULL = "Instance ID cannot be null";
105 101
......
...@@ -63,7 +63,7 @@ import org.onosproject.store.AbstractStore; ...@@ -63,7 +63,7 @@ import org.onosproject.store.AbstractStore;
63 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 63 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
64 import org.onosproject.store.impl.MastershipBasedTimestamp; 64 import org.onosproject.store.impl.MastershipBasedTimestamp;
65 import org.onosproject.store.serializers.KryoNamespaces; 65 import org.onosproject.store.serializers.KryoNamespaces;
66 -import org.onosproject.store.serializers.KryoSerializer; 66 +import org.onosproject.store.serializers.StoreSerializer;
67 import org.onosproject.store.serializers.custom.DistributedStoreSerializers; 67 import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
68 import org.onosproject.store.service.DistributedSet; 68 import org.onosproject.store.service.DistributedSet;
69 import org.onosproject.store.service.EventuallyConsistentMap; 69 import org.onosproject.store.service.EventuallyConsistentMap;
...@@ -157,17 +157,13 @@ public class ECDeviceStore ...@@ -157,17 +157,13 @@ public class ECDeviceStore
157 private final SetEventListener<DeviceId> deviceStatusTracker = 157 private final SetEventListener<DeviceId> deviceStatusTracker =
158 new InternalDeviceStatusTracker(); 158 new InternalDeviceStatusTracker();
159 159
160 - protected static final KryoSerializer SERIALIZER = new KryoSerializer() { 160 + protected static final StoreSerializer SERIALIZER = StoreSerializer.using(
161 - @Override 161 + KryoNamespace.newBuilder()
162 - protected void setupKryoPool() {
163 - serializerPool = KryoNamespace.newBuilder()
164 .register(DistributedStoreSerializers.STORE_COMMON) 162 .register(DistributedStoreSerializers.STORE_COMMON)
165 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN) 163 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
166 .register(DeviceInjectedEvent.class) 164 .register(DeviceInjectedEvent.class)
167 .register(PortInjectedEvent.class) 165 .register(PortInjectedEvent.class)
168 - .build(); 166 + .build("ECDevice"));
169 - }
170 - };
171 167
172 protected static final KryoNamespace.Builder SERIALIZER_BUILDER = KryoNamespace.newBuilder() 168 protected static final KryoNamespace.Builder SERIALIZER_BUILDER = KryoNamespace.newBuilder()
173 .register(KryoNamespaces.API) 169 .register(KryoNamespaces.API)
......
...@@ -72,7 +72,7 @@ import org.onosproject.store.cluster.messaging.ClusterMessageHandler; ...@@ -72,7 +72,7 @@ import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
72 import org.onosproject.store.cluster.messaging.MessageSubject; 72 import org.onosproject.store.cluster.messaging.MessageSubject;
73 import org.onosproject.store.impl.Timestamped; 73 import org.onosproject.store.impl.Timestamped;
74 import org.onosproject.store.serializers.KryoNamespaces; 74 import org.onosproject.store.serializers.KryoNamespaces;
75 -import org.onosproject.store.serializers.KryoSerializer; 75 +import org.onosproject.store.serializers.StoreSerializer;
76 import org.onosproject.store.serializers.custom.DistributedStoreSerializers; 76 import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
77 import org.onosproject.store.service.EventuallyConsistentMap; 77 import org.onosproject.store.service.EventuallyConsistentMap;
78 import org.onosproject.store.service.EventuallyConsistentMapEvent; 78 import org.onosproject.store.service.EventuallyConsistentMapEvent;
...@@ -170,10 +170,7 @@ public class GossipDeviceStore ...@@ -170,10 +170,7 @@ public class GossipDeviceStore
170 protected MastershipTermService termService; 170 protected MastershipTermService termService;
171 171
172 172
173 - protected static final KryoSerializer SERIALIZER = new KryoSerializer() { 173 + protected static final StoreSerializer SERIALIZER = StoreSerializer.using(KryoNamespace.newBuilder()
174 - @Override
175 - protected void setupKryoPool() {
176 - serializerPool = KryoNamespace.newBuilder()
177 .register(DistributedStoreSerializers.STORE_COMMON) 174 .register(DistributedStoreSerializers.STORE_COMMON)
178 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN) 175 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
179 .register(new InternalDeviceEventSerializer(), InternalDeviceEvent.class) 176 .register(new InternalDeviceEventSerializer(), InternalDeviceEvent.class)
...@@ -186,9 +183,7 @@ public class GossipDeviceStore ...@@ -186,9 +183,7 @@ public class GossipDeviceStore
186 .register(PortFragmentId.class) 183 .register(PortFragmentId.class)
187 .register(DeviceInjectedEvent.class) 184 .register(DeviceInjectedEvent.class)
188 .register(PortInjectedEvent.class) 185 .register(PortInjectedEvent.class)
189 - .build(); 186 + .build("GossipDevice"));
190 - }
191 - };
192 187
193 private ExecutorService executor; 188 private ExecutorService executor;
194 189
......
...@@ -67,7 +67,6 @@ package org.onosproject.store.flow.impl; ...@@ -67,7 +67,6 @@ package org.onosproject.store.flow.impl;
67 import org.onosproject.store.flow.ReplicaInfoService; 67 import org.onosproject.store.flow.ReplicaInfoService;
68 import org.onosproject.store.impl.MastershipBasedTimestamp; 68 import org.onosproject.store.impl.MastershipBasedTimestamp;
69 import org.onosproject.store.serializers.KryoNamespaces; 69 import org.onosproject.store.serializers.KryoNamespaces;
70 - import org.onosproject.store.serializers.KryoSerializer;
71 import org.onosproject.store.serializers.StoreSerializer; 70 import org.onosproject.store.serializers.StoreSerializer;
72 import org.onosproject.store.serializers.custom.DistributedStoreSerializers; 71 import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
73 import org.onosproject.store.service.EventuallyConsistentMap; 72 import org.onosproject.store.service.EventuallyConsistentMap;
...@@ -176,15 +175,11 @@ public class DistributedFlowRuleStore ...@@ -176,15 +175,11 @@ public class DistributedFlowRuleStore
176 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 175 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
177 protected StorageService storageService; 176 protected StorageService storageService;
178 177
179 - protected static final StoreSerializer SERIALIZER = new KryoSerializer() { 178 + protected static final StoreSerializer SERIALIZER = StoreSerializer.using(
180 - @Override 179 + KryoNamespace.newBuilder()
181 - protected void setupKryoPool() {
182 - serializerPool = KryoNamespace.newBuilder()
183 .register(DistributedStoreSerializers.STORE_COMMON) 180 .register(DistributedStoreSerializers.STORE_COMMON)
184 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN) 181 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
185 - .build(); 182 + .build("FlowRuleStore"));
186 - }
187 - };
188 183
189 protected static final KryoNamespace.Builder SERIALIZER_BUILDER = KryoNamespace.newBuilder() 184 protected static final KryoNamespace.Builder SERIALIZER_BUILDER = KryoNamespace.newBuilder()
190 .register(KryoNamespaces.API) 185 .register(KryoNamespaces.API)
......
...@@ -61,7 +61,7 @@ import org.onosproject.store.cluster.messaging.ClusterCommunicationService; ...@@ -61,7 +61,7 @@ import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
61 import org.onosproject.store.cluster.messaging.MessageSubject; 61 import org.onosproject.store.cluster.messaging.MessageSubject;
62 import org.onosproject.store.impl.MastershipBasedTimestamp; 62 import org.onosproject.store.impl.MastershipBasedTimestamp;
63 import org.onosproject.store.serializers.KryoNamespaces; 63 import org.onosproject.store.serializers.KryoNamespaces;
64 -import org.onosproject.store.serializers.KryoSerializer; 64 +import org.onosproject.store.serializers.StoreSerializer;
65 import org.onosproject.store.serializers.custom.DistributedStoreSerializers; 65 import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
66 import org.onosproject.store.service.EventuallyConsistentMap; 66 import org.onosproject.store.service.EventuallyConsistentMap;
67 import org.onosproject.store.service.EventuallyConsistentMapEvent; 67 import org.onosproject.store.service.EventuallyConsistentMapEvent;
...@@ -155,16 +155,12 @@ public class ECLinkStore ...@@ -155,16 +155,12 @@ public class ECLinkStore
155 155
156 protected LinkDiscoveryMode linkDiscoveryMode = LinkDiscoveryMode.STRICT; 156 protected LinkDiscoveryMode linkDiscoveryMode = LinkDiscoveryMode.STRICT;
157 157
158 - protected static final KryoSerializer SERIALIZER = new KryoSerializer() { 158 + protected static final StoreSerializer SERIALIZER = StoreSerializer.using(
159 - @Override 159 + KryoNamespace.newBuilder()
160 - protected void setupKryoPool() {
161 - serializerPool = KryoNamespace.newBuilder()
162 .register(DistributedStoreSerializers.STORE_COMMON) 160 .register(DistributedStoreSerializers.STORE_COMMON)
163 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN) 161 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
164 .register(Provided.class) 162 .register(Provided.class)
165 - .build(); 163 + .build("ECLink"));
166 - }
167 - };
168 164
169 @Activate 165 @Activate
170 public void activate() { 166 public void activate() {
......
...@@ -63,7 +63,7 @@ import org.onosproject.store.cluster.messaging.ClusterMessage; ...@@ -63,7 +63,7 @@ import org.onosproject.store.cluster.messaging.ClusterMessage;
63 import org.onosproject.store.cluster.messaging.ClusterMessageHandler; 63 import org.onosproject.store.cluster.messaging.ClusterMessageHandler;
64 import org.onosproject.store.cluster.messaging.MessageSubject; 64 import org.onosproject.store.cluster.messaging.MessageSubject;
65 import org.onosproject.store.impl.Timestamped; 65 import org.onosproject.store.impl.Timestamped;
66 -import org.onosproject.store.serializers.KryoSerializer; 66 +import org.onosproject.store.serializers.StoreSerializer;
67 import org.onosproject.store.serializers.custom.DistributedStoreSerializers; 67 import org.onosproject.store.serializers.custom.DistributedStoreSerializers;
68 import org.slf4j.Logger; 68 import org.slf4j.Logger;
69 69
...@@ -145,10 +145,8 @@ public class GossipLinkStore ...@@ -145,10 +145,8 @@ public class GossipLinkStore
145 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 145 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
146 protected MastershipService mastershipService; 146 protected MastershipService mastershipService;
147 147
148 - protected static final KryoSerializer SERIALIZER = new KryoSerializer() { 148 + protected static final StoreSerializer SERIALIZER = StoreSerializer.using(
149 - @Override 149 + KryoNamespace.newBuilder()
150 - protected void setupKryoPool() {
151 - serializerPool = KryoNamespace.newBuilder()
152 .register(DistributedStoreSerializers.STORE_COMMON) 150 .register(DistributedStoreSerializers.STORE_COMMON)
153 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN) 151 .nextId(DistributedStoreSerializers.STORE_CUSTOM_BEGIN)
154 .register(InternalLinkEvent.class) 152 .register(InternalLinkEvent.class)
...@@ -156,9 +154,7 @@ public class GossipLinkStore ...@@ -156,9 +154,7 @@ public class GossipLinkStore
156 .register(LinkAntiEntropyAdvertisement.class) 154 .register(LinkAntiEntropyAdvertisement.class)
157 .register(LinkFragmentId.class) 155 .register(LinkFragmentId.class)
158 .register(LinkInjectedEvent.class) 156 .register(LinkInjectedEvent.class)
159 - .build(); 157 + .build("GossipLink"));
160 - }
161 - };
162 158
163 private ExecutorService executor; 159 private ExecutorService executor;
164 160
......
...@@ -58,7 +58,6 @@ import org.onosproject.store.AbstractStore; ...@@ -58,7 +58,6 @@ import org.onosproject.store.AbstractStore;
58 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 58 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
59 import org.onosproject.store.cluster.messaging.MessageSubject; 59 import org.onosproject.store.cluster.messaging.MessageSubject;
60 import org.onosproject.store.serializers.KryoNamespaces; 60 import org.onosproject.store.serializers.KryoNamespaces;
61 -import org.onosproject.store.serializers.KryoSerializer;
62 import org.onosproject.store.serializers.StoreSerializer; 61 import org.onosproject.store.serializers.StoreSerializer;
63 import org.slf4j.Logger; 62 import org.slf4j.Logger;
64 63
...@@ -107,17 +106,13 @@ public class ConsistentDeviceMastershipStore ...@@ -107,17 +106,13 @@ public class ConsistentDeviceMastershipStore
107 private static final String DEVICE_ID_NULL = "Device ID cannot be null"; 106 private static final String DEVICE_ID_NULL = "Device ID cannot be null";
108 private static final int WAIT_BEFORE_MASTERSHIP_HANDOFF_MILLIS = 3000; 107 private static final int WAIT_BEFORE_MASTERSHIP_HANDOFF_MILLIS = 3000;
109 108
110 - public static final StoreSerializer SERIALIZER = new KryoSerializer() { 109 + public static final StoreSerializer SERIALIZER = StoreSerializer.using(
111 - @Override 110 + KryoNamespace.newBuilder()
112 - protected void setupKryoPool() {
113 - serializerPool = KryoNamespace.newBuilder()
114 .register(KryoNamespaces.API) 111 .register(KryoNamespaces.API)
115 .register(MastershipRole.class) 112 .register(MastershipRole.class)
116 .register(MastershipEvent.class) 113 .register(MastershipEvent.class)
117 .register(MastershipEvent.Type.class) 114 .register(MastershipEvent.Type.class)
118 - .build(); 115 + .build("MastershipStore"));
119 - }
120 - };
121 116
122 @Activate 117 @Activate
123 public void activate() { 118 public void activate() {
......
...@@ -26,7 +26,6 @@ import org.apache.felix.scr.annotations.Property; ...@@ -26,7 +26,6 @@ import org.apache.felix.scr.annotations.Property;
26 import org.apache.felix.scr.annotations.Reference; 26 import org.apache.felix.scr.annotations.Reference;
27 import org.apache.felix.scr.annotations.ReferenceCardinality; 27 import org.apache.felix.scr.annotations.ReferenceCardinality;
28 import org.apache.felix.scr.annotations.Service; 28 import org.apache.felix.scr.annotations.Service;
29 -import org.onlab.util.KryoNamespace;
30 import org.onosproject.cluster.ClusterService; 29 import org.onosproject.cluster.ClusterService;
31 import org.onosproject.cluster.NodeId; 30 import org.onosproject.cluster.NodeId;
32 import org.onosproject.mastership.MastershipService; 31 import org.onosproject.mastership.MastershipService;
...@@ -41,7 +40,7 @@ import org.onosproject.store.AbstractStore; ...@@ -41,7 +40,7 @@ import org.onosproject.store.AbstractStore;
41 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 40 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
42 import org.onosproject.store.cluster.messaging.MessageSubject; 41 import org.onosproject.store.cluster.messaging.MessageSubject;
43 import org.onosproject.store.serializers.KryoNamespaces; 42 import org.onosproject.store.serializers.KryoNamespaces;
44 -import org.onosproject.store.serializers.KryoSerializer; 43 +import org.onosproject.store.serializers.StoreSerializer;
45 import org.onosproject.store.service.ConsistentMap; 44 import org.onosproject.store.service.ConsistentMap;
46 import org.onosproject.store.service.ConsistentMapException; 45 import org.onosproject.store.service.ConsistentMapException;
47 import org.onosproject.store.service.Serializer; 46 import org.onosproject.store.service.Serializer;
...@@ -95,15 +94,7 @@ public class DistributedPacketStore ...@@ -95,15 +94,7 @@ public class DistributedPacketStore
95 private static final MessageSubject PACKET_OUT_SUBJECT = 94 private static final MessageSubject PACKET_OUT_SUBJECT =
96 new MessageSubject("packet-out"); 95 new MessageSubject("packet-out");
97 96
98 - private static final KryoSerializer SERIALIZER = new KryoSerializer() { 97 + private static final StoreSerializer SERIALIZER = StoreSerializer.using(KryoNamespaces.API);
99 - @Override
100 - protected void setupKryoPool() {
101 - serializerPool = KryoNamespace.newBuilder()
102 - .register(KryoNamespaces.API)
103 - .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
104 - .build();
105 - }
106 - };
107 98
108 private ExecutorService messageHandlingExecutor; 99 private ExecutorService messageHandlingExecutor;
109 100
......
...@@ -37,7 +37,7 @@ import org.onosproject.net.proxyarp.ProxyArpStoreDelegate; ...@@ -37,7 +37,7 @@ import org.onosproject.net.proxyarp.ProxyArpStoreDelegate;
37 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 37 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
38 import org.onosproject.store.cluster.messaging.MessageSubject; 38 import org.onosproject.store.cluster.messaging.MessageSubject;
39 import org.onosproject.store.serializers.KryoNamespaces; 39 import org.onosproject.store.serializers.KryoNamespaces;
40 -import org.onosproject.store.serializers.KryoSerializer; 40 +import org.onosproject.store.serializers.StoreSerializer;
41 import org.slf4j.Logger; 41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory; 42 import org.slf4j.LoggerFactory;
43 43
...@@ -60,16 +60,13 @@ public class DistributedProxyArpStore implements ProxyArpStore { ...@@ -60,16 +60,13 @@ public class DistributedProxyArpStore implements ProxyArpStore {
60 private static final MessageSubject ARP_RESPONSE_MESSAGE = 60 private static final MessageSubject ARP_RESPONSE_MESSAGE =
61 new MessageSubject("onos-arp-response"); 61 new MessageSubject("onos-arp-response");
62 62
63 - protected final KryoSerializer serializer = new KryoSerializer() { 63 + protected final StoreSerializer serializer = StoreSerializer.using(
64 - @Override 64 + KryoNamespace.newBuilder()
65 - protected void setupKryoPool() {
66 - serializerPool = KryoNamespace.newBuilder()
67 .register(KryoNamespaces.API) 65 .register(KryoNamespaces.API)
66 + .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
68 .register(ArpResponseMessage.class) 67 .register(ArpResponseMessage.class)
69 .register(ByteBuffer.class) 68 .register(ByteBuffer.class)
70 - .build(); 69 + .build("ProxyArpStore"));
71 - }
72 - };
73 70
74 private ProxyArpStoreDelegate delegate; 71 private ProxyArpStoreDelegate delegate;
75 72
......
...@@ -25,7 +25,6 @@ import org.apache.felix.scr.annotations.Property; ...@@ -25,7 +25,6 @@ import org.apache.felix.scr.annotations.Property;
25 import org.apache.felix.scr.annotations.Reference; 25 import org.apache.felix.scr.annotations.Reference;
26 import org.apache.felix.scr.annotations.ReferenceCardinality; 26 import org.apache.felix.scr.annotations.ReferenceCardinality;
27 import org.apache.felix.scr.annotations.Service; 27 import org.apache.felix.scr.annotations.Service;
28 -import org.onlab.util.KryoNamespace;
29 import org.onlab.util.Tools; 28 import org.onlab.util.Tools;
30 import org.onosproject.cluster.ClusterService; 29 import org.onosproject.cluster.ClusterService;
31 import org.onosproject.cluster.NodeId; 30 import org.onosproject.cluster.NodeId;
...@@ -40,7 +39,7 @@ import org.onosproject.net.flow.instructions.Instructions; ...@@ -40,7 +39,7 @@ import org.onosproject.net.flow.instructions.Instructions;
40 import org.onosproject.net.statistic.FlowStatisticStore; 39 import org.onosproject.net.statistic.FlowStatisticStore;
41 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 40 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
42 import org.onosproject.store.serializers.KryoNamespaces; 41 import org.onosproject.store.serializers.KryoNamespaces;
43 -import org.onosproject.store.serializers.KryoSerializer; 42 +import org.onosproject.store.serializers.StoreSerializer;
44 import org.osgi.service.component.ComponentContext; 43 import org.osgi.service.component.ComponentContext;
45 import org.slf4j.Logger; 44 import org.slf4j.Logger;
46 45
...@@ -90,16 +89,7 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore { ...@@ -90,16 +89,7 @@ public class DistributedFlowStatisticStore implements FlowStatisticStore {
90 private Map<ConnectPoint, Set<FlowEntry>> current = 89 private Map<ConnectPoint, Set<FlowEntry>> current =
91 new ConcurrentHashMap<>(); 90 new ConcurrentHashMap<>();
92 91
93 - protected static final KryoSerializer SERIALIZER = new KryoSerializer() { 92 + protected static final StoreSerializer SERIALIZER = StoreSerializer.using(KryoNamespaces.API);
94 - @Override
95 - protected void setupKryoPool() {
96 - serializerPool = KryoNamespace.newBuilder()
97 - .register(KryoNamespaces.API)
98 - .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
99 - // register this store specific classes here
100 - .build();
101 - }
102 - };
103 93
104 private NodeId local; 94 private NodeId local;
105 private ExecutorService messageHandlingExecutor; 95 private ExecutorService messageHandlingExecutor;
......
...@@ -25,7 +25,6 @@ import org.apache.felix.scr.annotations.Property; ...@@ -25,7 +25,6 @@ import org.apache.felix.scr.annotations.Property;
25 import org.apache.felix.scr.annotations.Reference; 25 import org.apache.felix.scr.annotations.Reference;
26 import org.apache.felix.scr.annotations.ReferenceCardinality; 26 import org.apache.felix.scr.annotations.ReferenceCardinality;
27 import org.apache.felix.scr.annotations.Service; 27 import org.apache.felix.scr.annotations.Service;
28 -import org.onlab.util.KryoNamespace;
29 import org.onlab.util.Tools; 28 import org.onlab.util.Tools;
30 import org.onosproject.cluster.ClusterService; 29 import org.onosproject.cluster.ClusterService;
31 import org.onosproject.cluster.NodeId; 30 import org.onosproject.cluster.NodeId;
...@@ -40,7 +39,7 @@ import org.onosproject.net.flow.instructions.Instructions; ...@@ -40,7 +39,7 @@ import org.onosproject.net.flow.instructions.Instructions;
40 import org.onosproject.net.statistic.StatisticStore; 39 import org.onosproject.net.statistic.StatisticStore;
41 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 40 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
42 import org.onosproject.store.serializers.KryoNamespaces; 41 import org.onosproject.store.serializers.KryoNamespaces;
43 -import org.onosproject.store.serializers.KryoSerializer; 42 +import org.onosproject.store.serializers.StoreSerializer;
44 import org.osgi.service.component.ComponentContext; 43 import org.osgi.service.component.ComponentContext;
45 import org.slf4j.Logger; 44 import org.slf4j.Logger;
46 45
...@@ -95,16 +94,7 @@ public class DistributedStatisticStore implements StatisticStore { ...@@ -95,16 +94,7 @@ public class DistributedStatisticStore implements StatisticStore {
95 private Map<ConnectPoint, Set<FlowEntry>> current = 94 private Map<ConnectPoint, Set<FlowEntry>> current =
96 new ConcurrentHashMap<>(); 95 new ConcurrentHashMap<>();
97 96
98 - protected static final KryoSerializer SERIALIZER = new KryoSerializer() { 97 + protected static final StoreSerializer SERIALIZER = StoreSerializer.using(KryoNamespaces.API);
99 - @Override
100 - protected void setupKryoPool() {
101 - serializerPool = KryoNamespace.newBuilder()
102 - .register(KryoNamespaces.API)
103 - .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
104 - // register this store specific classes here
105 - .build();
106 - }
107 - };
108 98
109 private ExecutorService messageHandlingExecutor; 99 private ExecutorService messageHandlingExecutor;
110 100
......
...@@ -54,7 +54,7 @@ import org.onosproject.store.Timestamp; ...@@ -54,7 +54,7 @@ import org.onosproject.store.Timestamp;
54 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 54 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
55 import org.onosproject.store.cluster.messaging.MessageSubject; 55 import org.onosproject.store.cluster.messaging.MessageSubject;
56 import org.onosproject.store.serializers.KryoNamespaces; 56 import org.onosproject.store.serializers.KryoNamespaces;
57 -import org.onosproject.store.serializers.KryoSerializer; 57 +import org.onosproject.store.serializers.StoreSerializer;
58 import org.onosproject.store.service.EventuallyConsistentMap; 58 import org.onosproject.store.service.EventuallyConsistentMap;
59 import org.onosproject.store.service.EventuallyConsistentMapEvent; 59 import org.onosproject.store.service.EventuallyConsistentMapEvent;
60 import org.onosproject.store.service.EventuallyConsistentMapListener; 60 import org.onosproject.store.service.EventuallyConsistentMapListener;
...@@ -83,7 +83,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -83,7 +83,7 @@ public class EventuallyConsistentMapImpl<K, V>
83 83
84 private final ClusterService clusterService; 84 private final ClusterService clusterService;
85 private final ClusterCommunicationService clusterCommunicator; 85 private final ClusterCommunicationService clusterCommunicator;
86 - private final KryoSerializer serializer; 86 + private final StoreSerializer serializer;
87 private final NodeId localNodeId; 87 private final NodeId localNodeId;
88 private final PersistenceService persistenceService; 88 private final PersistenceService persistenceService;
89 89
...@@ -268,12 +268,8 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -268,12 +268,8 @@ public class EventuallyConsistentMapImpl<K, V>
268 this.lightweightAntiEntropy = !convergeFaster; 268 this.lightweightAntiEntropy = !convergeFaster;
269 } 269 }
270 270
271 - private KryoSerializer createSerializer(KryoNamespace.Builder builder) { 271 + private StoreSerializer createSerializer(KryoNamespace.Builder builder) {
272 - return new KryoSerializer() { 272 + return StoreSerializer.using(builder
273 - @Override
274 - protected void setupKryoPool() {
275 - // Add the map's internal helper classes to the user-supplied serializer
276 - serializerPool = builder
277 .register(KryoNamespaces.BASIC) 273 .register(KryoNamespaces.BASIC)
278 .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID) 274 .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
279 .register(LogicalTimestamp.class) 275 .register(LogicalTimestamp.class)
...@@ -283,9 +279,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -283,9 +279,7 @@ public class EventuallyConsistentMapImpl<K, V>
283 .register(UpdateEntry.class) 279 .register(UpdateEntry.class)
284 .register(MapValue.class) 280 .register(MapValue.class)
285 .register(MapValue.Digest.class) 281 .register(MapValue.Digest.class)
286 - .build(); 282 + .build(name()));
287 - }
288 - };
289 } 283 }
290 284
291 @Override 285 @Override
...@@ -340,7 +334,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -340,7 +334,7 @@ public class EventuallyConsistentMapImpl<K, V>
340 334
341 MapValue<V> newValue = new MapValue<>(value, timestampProvider.apply(key, value)); 335 MapValue<V> newValue = new MapValue<>(value, timestampProvider.apply(key, value));
342 if (putInternal(key, newValue)) { 336 if (putInternal(key, newValue)) {
343 - notifyPeers(new UpdateEntry<K, V>(key, newValue), peerUpdateFunction.apply(key, value)); 337 + notifyPeers(new UpdateEntry<>(key, newValue), peerUpdateFunction.apply(key, value));
344 notifyListeners(new EventuallyConsistentMapEvent<>(mapName, PUT, key, value)); 338 notifyListeners(new EventuallyConsistentMapEvent<>(mapName, PUT, key, value));
345 } 339 }
346 } 340 }
...@@ -595,7 +589,7 @@ public class EventuallyConsistentMapImpl<K, V> ...@@ -595,7 +589,7 @@ public class EventuallyConsistentMapImpl<K, V>
595 } 589 }
596 590
597 private AntiEntropyAdvertisement<K> createAdvertisement() { 591 private AntiEntropyAdvertisement<K> createAdvertisement() {
598 - return new AntiEntropyAdvertisement<K>(localNodeId, 592 + return new AntiEntropyAdvertisement<>(localNodeId,
599 ImmutableMap.copyOf(Maps.transformValues(items, MapValue::digest))); 593 ImmutableMap.copyOf(Maps.transformValues(items, MapValue::digest)));
600 } 594 }
601 595
......
...@@ -37,7 +37,6 @@ import java.util.HashSet; ...@@ -37,7 +37,6 @@ import java.util.HashSet;
37 import java.util.List; 37 import java.util.List;
38 import java.util.Map; 38 import java.util.Map;
39 import java.util.Objects; 39 import java.util.Objects;
40 -import java.util.Optional;
41 import java.util.Set; 40 import java.util.Set;
42 import java.util.concurrent.CompletableFuture; 41 import java.util.concurrent.CompletableFuture;
43 import java.util.concurrent.CountDownLatch; 42 import java.util.concurrent.CountDownLatch;
...@@ -58,19 +57,15 @@ import org.onosproject.cluster.DefaultControllerNode; ...@@ -58,19 +57,15 @@ import org.onosproject.cluster.DefaultControllerNode;
58 import org.onosproject.cluster.NodeId; 57 import org.onosproject.cluster.NodeId;
59 import org.onosproject.event.AbstractEvent; 58 import org.onosproject.event.AbstractEvent;
60 import org.onosproject.persistence.PersistenceService; 59 import org.onosproject.persistence.PersistenceService;
61 -import org.onosproject.store.LogicalTimestamp;
62 import org.onosproject.store.Timestamp; 60 import org.onosproject.store.Timestamp;
63 import org.onosproject.store.cluster.messaging.ClusterCommunicationService; 61 import org.onosproject.store.cluster.messaging.ClusterCommunicationService;
64 import org.onosproject.store.cluster.messaging.ClusterCommunicationServiceAdapter; 62 import org.onosproject.store.cluster.messaging.ClusterCommunicationServiceAdapter;
65 import org.onosproject.store.cluster.messaging.MessageSubject; 63 import org.onosproject.store.cluster.messaging.MessageSubject;
66 import org.onosproject.store.persistence.TestPersistenceService; 64 import org.onosproject.store.persistence.TestPersistenceService;
67 import org.onosproject.store.serializers.KryoNamespaces; 65 import org.onosproject.store.serializers.KryoNamespaces;
68 -import org.onosproject.store.serializers.KryoSerializer;
69 import org.onosproject.store.service.EventuallyConsistentMap; 66 import org.onosproject.store.service.EventuallyConsistentMap;
70 import org.onosproject.store.service.EventuallyConsistentMapEvent; 67 import org.onosproject.store.service.EventuallyConsistentMapEvent;
71 import org.onosproject.store.service.EventuallyConsistentMapListener; 68 import org.onosproject.store.service.EventuallyConsistentMapListener;
72 -import org.onosproject.store.service.WallClockTimestamp;
73 -
74 import com.google.common.collect.ComparisonChain; 69 import com.google.common.collect.ComparisonChain;
75 import com.google.common.collect.ImmutableList; 70 import com.google.common.collect.ImmutableList;
76 import com.google.common.collect.ImmutableSet; 71 import com.google.common.collect.ImmutableSet;
...@@ -105,31 +100,6 @@ public class EventuallyConsistentMapImplTest { ...@@ -105,31 +100,6 @@ public class EventuallyConsistentMapImplTest {
105 private Consumer<Collection<UpdateEntry<String, String>>> updateHandler; 100 private Consumer<Collection<UpdateEntry<String, String>>> updateHandler;
106 private Function<AntiEntropyAdvertisement<String>, AntiEntropyResponse> antiEntropyHandler; 101 private Function<AntiEntropyAdvertisement<String>, AntiEntropyResponse> antiEntropyHandler;
107 102
108 - /*
109 - * Serialization is a bit tricky here. We need to serialize in the tests
110 - * to set the expectations, which will use this serializer here, but the
111 - * EventuallyConsistentMap will use its own internal serializer. This means
112 - * this serializer must be set up exactly the same as map's internal
113 - * serializer.
114 - */
115 - private static final KryoSerializer SERIALIZER = new KryoSerializer() {
116 - @Override
117 - protected void setupKryoPool() {
118 - serializerPool = KryoNamespace.newBuilder()
119 - // Classes we give to the map
120 - .register(KryoNamespaces.API)
121 - .register(TestTimestamp.class)
122 - // Below is the classes that the map internally registers
123 - .register(LogicalTimestamp.class)
124 - .register(WallClockTimestamp.class)
125 - .register(ArrayList.class)
126 - .register(AntiEntropyAdvertisement.class)
127 - .register(HashMap.class)
128 - .register(Optional.class)
129 - .build();
130 - }
131 - };
132 -
133 @Before 103 @Before
134 public void setUp() throws Exception { 104 public void setUp() throws Exception {
135 clusterService = createMock(ClusterService.class); 105 clusterService = createMock(ClusterService.class);
......
...@@ -25,7 +25,10 @@ import com.google.common.base.MoreObjects; ...@@ -25,7 +25,10 @@ import com.google.common.base.MoreObjects;
25 25
26 /** 26 /**
27 * StoreSerializer implementation using Kryo. 27 * StoreSerializer implementation using Kryo.
28 + *
29 + * @deprecated in Goldeneye (1.6.0)
28 */ 30 */
31 +@Deprecated
29 public class KryoSerializer implements StoreSerializer { 32 public class KryoSerializer implements StoreSerializer {
30 33
31 protected KryoNamespace serializerPool; 34 protected KryoNamespace serializerPool;
......
...@@ -19,7 +19,8 @@ import java.io.InputStream; ...@@ -19,7 +19,8 @@ import java.io.InputStream;
19 import java.io.OutputStream; 19 import java.io.OutputStream;
20 import java.nio.ByteBuffer; 20 import java.nio.ByteBuffer;
21 21
22 -// TODO: To be replaced with SerializationService from IOLoop activity 22 +import org.onlab.util.KryoNamespace;
23 +
23 /** 24 /**
24 * Service to serialize Objects into byte array. 25 * Service to serialize Objects into byte array.
25 */ 26 */
...@@ -84,4 +85,50 @@ public interface StoreSerializer { ...@@ -84,4 +85,50 @@ public interface StoreSerializer {
84 * @param <T> object type 85 * @param <T> object type
85 */ 86 */
86 <T> T copy(final T object); 87 <T> T copy(final T object);
88 +
89 + /**
90 + * Creates a new StoreSerializer instance from a KryoNamespace.
91 + *
92 + * @param ns kryo namespace
93 + * @return StoreSerializer instance
94 + */
95 + static StoreSerializer using(KryoNamespace ns) {
96 + return new StoreSerializer() {
97 +
98 + @Override
99 + public void encode(Object obj, OutputStream stream) {
100 + ns.serialize(obj, stream);
101 + }
102 +
103 + @Override
104 + public void encode(Object obj, ByteBuffer buffer) {
105 + ns.serialize(obj, buffer);
106 + }
107 +
108 + @Override
109 + public byte[] encode(Object obj) {
110 + return ns.serialize(obj);
111 + }
112 +
113 + @Override
114 + public <T> T decode(InputStream stream) {
115 + return ns.deserialize(stream);
116 + }
117 +
118 + @Override
119 + public <T> T decode(ByteBuffer buffer) {
120 + return ns.deserialize(buffer);
121 + }
122 +
123 + @Override
124 + public <T> T decode(byte[] bytes) {
125 + return ns.deserialize(bytes);
126 + }
127 +
128 + @Override
129 + public <T> T copy(T object) {
130 + return ns.run(kryo -> kryo.copy(object));
131 + }
132 + };
133 + }
87 } 134 }
......
...@@ -84,7 +84,6 @@ import org.onlab.packet.IpPrefix; ...@@ -84,7 +84,6 @@ import org.onlab.packet.IpPrefix;
84 import org.onlab.packet.Ip4Prefix; 84 import org.onlab.packet.Ip4Prefix;
85 import org.onlab.packet.Ip6Prefix; 85 import org.onlab.packet.Ip6Prefix;
86 import org.onlab.packet.MacAddress; 86 import org.onlab.packet.MacAddress;
87 -import org.onlab.util.KryoNamespace;
88 import org.onosproject.net.resource.VlanCodec; 87 import org.onosproject.net.resource.VlanCodec;
89 88
90 import java.nio.ByteBuffer; 89 import java.nio.ByteBuffer;
...@@ -130,7 +129,7 @@ public class KryoSerializerTest { ...@@ -130,7 +129,7 @@ public class KryoSerializerTest {
130 GridType.DWDM, ChannelSpacing.CHL_100GHZ, -8, 4); 129 GridType.DWDM, ChannelSpacing.CHL_100GHZ, -8, 4);
131 private static final VlanId VLAN1 = VlanId.vlanId((short) 100); 130 private static final VlanId VLAN1 = VlanId.vlanId((short) 100);
132 131
133 - private KryoSerializer serializer; 132 + private StoreSerializer serializer;
134 133
135 @BeforeClass 134 @BeforeClass
136 public static void setUpBeforeClass() throws Exception { 135 public static void setUpBeforeClass() throws Exception {
...@@ -138,16 +137,7 @@ public class KryoSerializerTest { ...@@ -138,16 +137,7 @@ public class KryoSerializerTest {
138 137
139 @Before 138 @Before
140 public void setUp() throws Exception { 139 public void setUp() throws Exception {
141 - serializer = new KryoSerializer() { 140 + serializer = StoreSerializer.using(KryoNamespaces.API);
142 -
143 - @Override
144 - protected void setupKryoPool() {
145 - serializerPool = KryoNamespace.newBuilder()
146 - .register(KryoNamespaces.API)
147 - .nextId(KryoNamespaces.BEGIN_USER_CUSTOM_ID)
148 - .build();
149 - }
150 - };
151 } 141 }
152 142
153 @After 143 @After
......