KryoSerializationService -> Serializer
- no longer a shared OSGi service. Change-Id: Ie2b2320e92685cd515b30ffc472e3a02149a5bbd
Showing
13 changed files
with
36 additions
and
79 deletions
... | @@ -36,8 +36,6 @@ import org.onlab.onos.store.common.StoreManager; | ... | @@ -36,8 +36,6 @@ import org.onlab.onos.store.common.StoreManager; |
36 | import org.onlab.onos.store.common.StoreService; | 36 | import org.onlab.onos.store.common.StoreService; |
37 | import org.onlab.onos.store.common.TestStoreManager; | 37 | import org.onlab.onos.store.common.TestStoreManager; |
38 | import org.onlab.onos.store.device.impl.DistributedDeviceStore; | 38 | import org.onlab.onos.store.device.impl.DistributedDeviceStore; |
39 | -import org.onlab.onos.store.serializers.KryoSerializationManager; | ||
40 | -import org.onlab.onos.store.serializers.KryoSerializationService; | ||
41 | import org.onlab.packet.IpPrefix; | 39 | import org.onlab.packet.IpPrefix; |
42 | 40 | ||
43 | import java.util.ArrayList; | 41 | import java.util.ArrayList; |
... | @@ -95,7 +93,6 @@ public class DistributedDeviceManagerTest { | ... | @@ -95,7 +93,6 @@ public class DistributedDeviceManagerTest { |
95 | private DistributedDeviceStore dstore; | 93 | private DistributedDeviceStore dstore; |
96 | private TestMastershipManager masterManager; | 94 | private TestMastershipManager masterManager; |
97 | private EventDeliveryService eventService; | 95 | private EventDeliveryService eventService; |
98 | - private KryoSerializationManager serializationMgr; | ||
99 | 96 | ||
100 | @Before | 97 | @Before |
101 | public void setUp() { | 98 | public void setUp() { |
... | @@ -111,10 +108,7 @@ public class DistributedDeviceManagerTest { | ... | @@ -111,10 +108,7 @@ public class DistributedDeviceManagerTest { |
111 | storeManager = new TestStoreManager(Hazelcast.newHazelcastInstance(config)); | 108 | storeManager = new TestStoreManager(Hazelcast.newHazelcastInstance(config)); |
112 | storeManager.activate(); | 109 | storeManager.activate(); |
113 | 110 | ||
114 | - serializationMgr = new KryoSerializationManager(); | 111 | + dstore = new TestDistributedDeviceStore(storeManager); |
115 | - serializationMgr.activate(); | ||
116 | - | ||
117 | - dstore = new TestDistributedDeviceStore(storeManager, serializationMgr); | ||
118 | dstore.activate(); | 112 | dstore.activate(); |
119 | 113 | ||
120 | mgr.store = dstore; | 114 | mgr.store = dstore; |
... | @@ -140,7 +134,6 @@ public class DistributedDeviceManagerTest { | ... | @@ -140,7 +134,6 @@ public class DistributedDeviceManagerTest { |
140 | mgr.deactivate(); | 134 | mgr.deactivate(); |
141 | 135 | ||
142 | dstore.deactivate(); | 136 | dstore.deactivate(); |
143 | - serializationMgr.deactivate(); | ||
144 | storeManager.deactivate(); | 137 | storeManager.deactivate(); |
145 | } | 138 | } |
146 | 139 | ||
... | @@ -306,10 +299,8 @@ public class DistributedDeviceManagerTest { | ... | @@ -306,10 +299,8 @@ public class DistributedDeviceManagerTest { |
306 | 299 | ||
307 | private class TestDistributedDeviceStore extends DistributedDeviceStore { | 300 | private class TestDistributedDeviceStore extends DistributedDeviceStore { |
308 | 301 | ||
309 | - public TestDistributedDeviceStore(StoreService storeService, | 302 | + public TestDistributedDeviceStore(StoreService storeService) { |
310 | - KryoSerializationService kryoSerializationService) { | ||
311 | this.storeService = storeService; | 303 | this.storeService = storeService; |
312 | - this.kryoSerializationService = kryoSerializationService; | ||
313 | } | 304 | } |
314 | } | 305 | } |
315 | 306 | ... | ... |
... | @@ -57,7 +57,7 @@ public class DistributedClusterStore | ... | @@ -57,7 +57,7 @@ public class DistributedClusterStore |
57 | 57 | ||
58 | rawNodes = theInstance.getMap("nodes"); | 58 | rawNodes = theInstance.getMap("nodes"); |
59 | OptionalCacheLoader<NodeId, DefaultControllerNode> nodeLoader | 59 | OptionalCacheLoader<NodeId, DefaultControllerNode> nodeLoader |
60 | - = new OptionalCacheLoader<>(kryoSerializationService, rawNodes); | 60 | + = new OptionalCacheLoader<>(serializer, rawNodes); |
61 | nodes = new AbsentInvalidatingLoadingCache<>(newBuilder().build(nodeLoader)); | 61 | nodes = new AbsentInvalidatingLoadingCache<>(newBuilder().build(nodeLoader)); |
62 | rawNodes.addEntryListener(new RemoteCacheEventHandler<>(nodes), true); | 62 | rawNodes.addEntryListener(new RemoteCacheEventHandler<>(nodes), true); |
63 | 63 | ... | ... |
... | @@ -52,7 +52,7 @@ implements MastershipStore { | ... | @@ -52,7 +52,7 @@ implements MastershipStore { |
52 | 52 | ||
53 | rawMasters = theInstance.getMap("masters"); | 53 | rawMasters = theInstance.getMap("masters"); |
54 | OptionalCacheLoader<DeviceId, NodeId> nodeLoader | 54 | OptionalCacheLoader<DeviceId, NodeId> nodeLoader |
55 | - = new OptionalCacheLoader<>(kryoSerializationService, rawMasters); | 55 | + = new OptionalCacheLoader<>(serializer, rawMasters); |
56 | masters = new AbsentInvalidatingLoadingCache<>(newBuilder().build(nodeLoader)); | 56 | masters = new AbsentInvalidatingLoadingCache<>(newBuilder().build(nodeLoader)); |
57 | rawMasters.addEntryListener(new RemoteMasterShipEventHandler(masters), true); | 57 | rawMasters.addEntryListener(new RemoteMasterShipEventHandler(masters), true); |
58 | 58 | ... | ... |
... | @@ -15,7 +15,8 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; | ... | @@ -15,7 +15,8 @@ import org.apache.felix.scr.annotations.ReferenceCardinality; |
15 | import org.onlab.onos.event.Event; | 15 | import org.onlab.onos.event.Event; |
16 | import org.onlab.onos.store.AbstractStore; | 16 | import org.onlab.onos.store.AbstractStore; |
17 | import org.onlab.onos.store.StoreDelegate; | 17 | import org.onlab.onos.store.StoreDelegate; |
18 | -import org.onlab.onos.store.serializers.KryoSerializationService; | 18 | +import org.onlab.onos.store.serializers.KryoSerializer; |
19 | +import org.onlab.onos.store.serializers.Serializer; | ||
19 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
20 | 21 | ||
21 | import static com.google.common.base.Preconditions.checkNotNull; | 22 | import static com.google.common.base.Preconditions.checkNotNull; |
... | @@ -24,7 +25,7 @@ import static org.slf4j.LoggerFactory.getLogger; | ... | @@ -24,7 +25,7 @@ import static org.slf4j.LoggerFactory.getLogger; |
24 | /** | 25 | /** |
25 | * Abstraction of a distributed store based on Hazelcast. | 26 | * Abstraction of a distributed store based on Hazelcast. |
26 | */ | 27 | */ |
27 | -@Component(componentAbstract = true) | 28 | +@Component |
28 | public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDelegate<E>> | 29 | public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDelegate<E>> |
29 | extends AbstractStore<E, D> { | 30 | extends AbstractStore<E, D> { |
30 | 31 | ||
... | @@ -33,13 +34,13 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel | ... | @@ -33,13 +34,13 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel |
33 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 34 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
34 | protected StoreService storeService; | 35 | protected StoreService storeService; |
35 | 36 | ||
36 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 37 | + protected Serializer serializer; |
37 | - protected KryoSerializationService kryoSerializationService; | ||
38 | 38 | ||
39 | protected HazelcastInstance theInstance; | 39 | protected HazelcastInstance theInstance; |
40 | 40 | ||
41 | @Activate | 41 | @Activate |
42 | public void activate() { | 42 | public void activate() { |
43 | + serializer = new KryoSerializer(); | ||
43 | theInstance = storeService.getHazelcastInstance(); | 44 | theInstance = storeService.getHazelcastInstance(); |
44 | } | 45 | } |
45 | 46 | ||
... | @@ -50,7 +51,7 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel | ... | @@ -50,7 +51,7 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel |
50 | * @return serialized object | 51 | * @return serialized object |
51 | */ | 52 | */ |
52 | protected byte[] serialize(Object obj) { | 53 | protected byte[] serialize(Object obj) { |
53 | - return kryoSerializationService.encode(obj); | 54 | + return serializer.encode(obj); |
54 | } | 55 | } |
55 | 56 | ||
56 | /** | 57 | /** |
... | @@ -61,7 +62,7 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel | ... | @@ -61,7 +62,7 @@ public abstract class AbstractHazelcastStore<E extends Event, D extends StoreDel |
61 | * @return deserialized object | 62 | * @return deserialized object |
62 | */ | 63 | */ |
63 | protected <T> T deserialize(byte[] bytes) { | 64 | protected <T> T deserialize(byte[] bytes) { |
64 | - return kryoSerializationService.decode(bytes); | 65 | + return serializer.decode(bytes); |
65 | } | 66 | } |
66 | 67 | ||
67 | 68 | ... | ... |
... | @@ -2,7 +2,7 @@ package org.onlab.onos.store.common; | ... | @@ -2,7 +2,7 @@ package org.onlab.onos.store.common; |
2 | 2 | ||
3 | import static com.google.common.base.Preconditions.checkNotNull; | 3 | import static com.google.common.base.Preconditions.checkNotNull; |
4 | 4 | ||
5 | -import org.onlab.onos.store.serializers.KryoSerializationService; | 5 | +import org.onlab.onos.store.serializers.Serializer; |
6 | 6 | ||
7 | import com.google.common.base.Optional; | 7 | import com.google.common.base.Optional; |
8 | import com.google.common.cache.CacheLoader; | 8 | import com.google.common.cache.CacheLoader; |
... | @@ -18,28 +18,28 @@ import com.hazelcast.core.IMap; | ... | @@ -18,28 +18,28 @@ import com.hazelcast.core.IMap; |
18 | public final class OptionalCacheLoader<K, V> extends | 18 | public final class OptionalCacheLoader<K, V> extends |
19 | CacheLoader<K, Optional<V>> { | 19 | CacheLoader<K, Optional<V>> { |
20 | 20 | ||
21 | - private final KryoSerializationService kryoSerializationService; | 21 | + private final Serializer serializer; |
22 | private IMap<byte[], byte[]> rawMap; | 22 | private IMap<byte[], byte[]> rawMap; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * Constructor. | 25 | * Constructor. |
26 | * | 26 | * |
27 | - * @param kryoSerializationService to use for serialization | 27 | + * @param serializer to use for serialization |
28 | * @param rawMap underlying IMap | 28 | * @param rawMap underlying IMap |
29 | */ | 29 | */ |
30 | - public OptionalCacheLoader(KryoSerializationService kryoSerializationService, IMap<byte[], byte[]> rawMap) { | 30 | + public OptionalCacheLoader(Serializer serializer, IMap<byte[], byte[]> rawMap) { |
31 | - this.kryoSerializationService = checkNotNull(kryoSerializationService); | 31 | + this.serializer = checkNotNull(serializer); |
32 | this.rawMap = checkNotNull(rawMap); | 32 | this.rawMap = checkNotNull(rawMap); |
33 | } | 33 | } |
34 | 34 | ||
35 | @Override | 35 | @Override |
36 | public Optional<V> load(K key) throws Exception { | 36 | public Optional<V> load(K key) throws Exception { |
37 | - byte[] keyBytes = kryoSerializationService.encode(key); | 37 | + byte[] keyBytes = serializer.encode(key); |
38 | byte[] valBytes = rawMap.get(keyBytes); | 38 | byte[] valBytes = rawMap.get(keyBytes); |
39 | if (valBytes == null) { | 39 | if (valBytes == null) { |
40 | return Optional.absent(); | 40 | return Optional.absent(); |
41 | } | 41 | } |
42 | - V dev = kryoSerializationService.decode(valBytes); | 42 | + V dev = serializer.decode(valBytes); |
43 | return Optional.of(dev); | 43 | return Optional.of(dev); |
44 | } | 44 | } |
45 | } | 45 | } | ... | ... |
... | @@ -88,7 +88,7 @@ public class DistributedDeviceStore | ... | @@ -88,7 +88,7 @@ public class DistributedDeviceStore |
88 | // TODO decide on Map name scheme to avoid collision | 88 | // TODO decide on Map name scheme to avoid collision |
89 | rawDevices = theInstance.getMap("devices"); | 89 | rawDevices = theInstance.getMap("devices"); |
90 | final OptionalCacheLoader<DeviceId, DefaultDevice> deviceLoader | 90 | final OptionalCacheLoader<DeviceId, DefaultDevice> deviceLoader |
91 | - = new OptionalCacheLoader<>(kryoSerializationService, rawDevices); | 91 | + = new OptionalCacheLoader<>(serializer, rawDevices); |
92 | devices = new AbsentInvalidatingLoadingCache<>(newBuilder().build(deviceLoader)); | 92 | devices = new AbsentInvalidatingLoadingCache<>(newBuilder().build(deviceLoader)); |
93 | // refresh/populate cache based on notification from other instance | 93 | // refresh/populate cache based on notification from other instance |
94 | devicesListener = rawDevices.addEntryListener(new RemoteDeviceEventHandler(devices), includeValue); | 94 | devicesListener = rawDevices.addEntryListener(new RemoteDeviceEventHandler(devices), includeValue); |
... | @@ -98,7 +98,7 @@ public class DistributedDeviceStore | ... | @@ -98,7 +98,7 @@ public class DistributedDeviceStore |
98 | 98 | ||
99 | rawDevicePorts = theInstance.getMap("devicePorts"); | 99 | rawDevicePorts = theInstance.getMap("devicePorts"); |
100 | final OptionalCacheLoader<DeviceId, Map<PortNumber, Port>> devicePortLoader | 100 | final OptionalCacheLoader<DeviceId, Map<PortNumber, Port>> devicePortLoader |
101 | - = new OptionalCacheLoader<>(kryoSerializationService, rawDevicePorts); | 101 | + = new OptionalCacheLoader<>(serializer, rawDevicePorts); |
102 | devicePorts = new AbsentInvalidatingLoadingCache<>(newBuilder().build(devicePortLoader)); | 102 | devicePorts = new AbsentInvalidatingLoadingCache<>(newBuilder().build(devicePortLoader)); |
103 | // refresh/populate cache based on notification from other instance | 103 | // refresh/populate cache based on notification from other instance |
104 | portsListener = rawDevicePorts.addEntryListener(new RemotePortEventHandler(devicePorts), includeValue); | 104 | portsListener = rawDevicePorts.addEntryListener(new RemotePortEventHandler(devicePorts), includeValue); | ... | ... |
... | @@ -71,7 +71,7 @@ public class DistributedLinkStore | ... | @@ -71,7 +71,7 @@ public class DistributedLinkStore |
71 | // TODO decide on Map name scheme to avoid collision | 71 | // TODO decide on Map name scheme to avoid collision |
72 | rawLinks = theInstance.getMap("links"); | 72 | rawLinks = theInstance.getMap("links"); |
73 | final OptionalCacheLoader<LinkKey, DefaultLink> linkLoader | 73 | final OptionalCacheLoader<LinkKey, DefaultLink> linkLoader |
74 | - = new OptionalCacheLoader<>(kryoSerializationService, rawLinks); | 74 | + = new OptionalCacheLoader<>(serializer, rawLinks); |
75 | links = new AbsentInvalidatingLoadingCache<>(newBuilder().build(linkLoader)); | 75 | links = new AbsentInvalidatingLoadingCache<>(newBuilder().build(linkLoader)); |
76 | // refresh/populate cache based on notification from other instance | 76 | // refresh/populate cache based on notification from other instance |
77 | linksListener = rawLinks.addEntryListener(new RemoteLinkEventHandler(links), includeValue); | 77 | linksListener = rawLinks.addEntryListener(new RemoteLinkEventHandler(links), includeValue); | ... | ... |
... | @@ -36,9 +36,6 @@ import org.onlab.onos.net.provider.ProviderId; | ... | @@ -36,9 +36,6 @@ import org.onlab.onos.net.provider.ProviderId; |
36 | import org.onlab.onos.store.common.StoreManager; | 36 | import org.onlab.onos.store.common.StoreManager; |
37 | import org.onlab.onos.store.common.StoreService; | 37 | import org.onlab.onos.store.common.StoreService; |
38 | import org.onlab.onos.store.common.TestStoreManager; | 38 | import org.onlab.onos.store.common.TestStoreManager; |
39 | -import org.onlab.onos.store.serializers.KryoSerializationManager; | ||
40 | -import org.onlab.onos.store.serializers.KryoSerializationService; | ||
41 | - | ||
42 | import com.google.common.collect.Iterables; | 39 | import com.google.common.collect.Iterables; |
43 | import com.google.common.collect.Sets; | 40 | import com.google.common.collect.Sets; |
44 | import com.hazelcast.config.Config; | 41 | import com.hazelcast.config.Config; |
... | @@ -63,7 +60,6 @@ public class DistributedDeviceStoreTest { | ... | @@ -63,7 +60,6 @@ public class DistributedDeviceStoreTest { |
63 | private static final PortNumber P3 = PortNumber.portNumber(3); | 60 | private static final PortNumber P3 = PortNumber.portNumber(3); |
64 | 61 | ||
65 | private DistributedDeviceStore deviceStore; | 62 | private DistributedDeviceStore deviceStore; |
66 | - private KryoSerializationManager serializationMgr; | ||
67 | 63 | ||
68 | private StoreManager storeManager; | 64 | private StoreManager storeManager; |
69 | 65 | ||
... | @@ -85,10 +81,7 @@ public class DistributedDeviceStoreTest { | ... | @@ -85,10 +81,7 @@ public class DistributedDeviceStoreTest { |
85 | storeManager = new TestStoreManager(Hazelcast.newHazelcastInstance(config)); | 81 | storeManager = new TestStoreManager(Hazelcast.newHazelcastInstance(config)); |
86 | storeManager.activate(); | 82 | storeManager.activate(); |
87 | 83 | ||
88 | - serializationMgr = new KryoSerializationManager(); | 84 | + deviceStore = new TestDistributedDeviceStore(storeManager); |
89 | - serializationMgr.activate(); | ||
90 | - | ||
91 | - deviceStore = new TestDistributedDeviceStore(storeManager, serializationMgr); | ||
92 | deviceStore.activate(); | 85 | deviceStore.activate(); |
93 | } | 86 | } |
94 | 87 | ||
... | @@ -96,8 +89,6 @@ public class DistributedDeviceStoreTest { | ... | @@ -96,8 +89,6 @@ public class DistributedDeviceStoreTest { |
96 | public void tearDown() throws Exception { | 89 | public void tearDown() throws Exception { |
97 | deviceStore.deactivate(); | 90 | deviceStore.deactivate(); |
98 | 91 | ||
99 | - serializationMgr.deactivate(); | ||
100 | - | ||
101 | storeManager.deactivate(); | 92 | storeManager.deactivate(); |
102 | } | 93 | } |
103 | 94 | ||
... | @@ -392,10 +383,8 @@ public class DistributedDeviceStoreTest { | ... | @@ -392,10 +383,8 @@ public class DistributedDeviceStoreTest { |
392 | } | 383 | } |
393 | 384 | ||
394 | private class TestDistributedDeviceStore extends DistributedDeviceStore { | 385 | private class TestDistributedDeviceStore extends DistributedDeviceStore { |
395 | - public TestDistributedDeviceStore(StoreService storeService, | 386 | + public TestDistributedDeviceStore(StoreService storeService) { |
396 | - KryoSerializationService kryoSerializationService) { | ||
397 | this.storeService = storeService; | 387 | this.storeService = storeService; |
398 | - this.kryoSerializationService = kryoSerializationService; | ||
399 | } | 388 | } |
400 | } | 389 | } |
401 | } | 390 | } | ... | ... |
... | @@ -30,9 +30,6 @@ import org.onlab.onos.net.provider.ProviderId; | ... | @@ -30,9 +30,6 @@ import org.onlab.onos.net.provider.ProviderId; |
30 | import org.onlab.onos.store.common.StoreManager; | 30 | import org.onlab.onos.store.common.StoreManager; |
31 | import org.onlab.onos.store.common.StoreService; | 31 | import org.onlab.onos.store.common.StoreService; |
32 | import org.onlab.onos.store.common.TestStoreManager; | 32 | import org.onlab.onos.store.common.TestStoreManager; |
33 | -import org.onlab.onos.store.serializers.KryoSerializationManager; | ||
34 | -import org.onlab.onos.store.serializers.KryoSerializationService; | ||
35 | - | ||
36 | import com.google.common.collect.Iterables; | 33 | import com.google.common.collect.Iterables; |
37 | import com.hazelcast.config.Config; | 34 | import com.hazelcast.config.Config; |
38 | import com.hazelcast.core.Hazelcast; | 35 | import com.hazelcast.core.Hazelcast; |
... | @@ -51,7 +48,6 @@ public class DistributedLinkStoreTest { | ... | @@ -51,7 +48,6 @@ public class DistributedLinkStoreTest { |
51 | private static final PortNumber P3 = PortNumber.portNumber(3); | 48 | private static final PortNumber P3 = PortNumber.portNumber(3); |
52 | 49 | ||
53 | private StoreManager storeManager; | 50 | private StoreManager storeManager; |
54 | - private KryoSerializationManager serializationMgr; | ||
55 | 51 | ||
56 | private DistributedLinkStore linkStore; | 52 | private DistributedLinkStore linkStore; |
57 | 53 | ||
... | @@ -71,17 +67,13 @@ public class DistributedLinkStoreTest { | ... | @@ -71,17 +67,13 @@ public class DistributedLinkStoreTest { |
71 | storeManager = new TestStoreManager(Hazelcast.newHazelcastInstance(config)); | 67 | storeManager = new TestStoreManager(Hazelcast.newHazelcastInstance(config)); |
72 | storeManager.activate(); | 68 | storeManager.activate(); |
73 | 69 | ||
74 | - serializationMgr = new KryoSerializationManager(); | 70 | + linkStore = new TestDistributedLinkStore(storeManager); |
75 | - serializationMgr.activate(); | ||
76 | - | ||
77 | - linkStore = new TestDistributedLinkStore(storeManager, serializationMgr); | ||
78 | linkStore.activate(); | 71 | linkStore.activate(); |
79 | } | 72 | } |
80 | 73 | ||
81 | @After | 74 | @After |
82 | public void tearDown() throws Exception { | 75 | public void tearDown() throws Exception { |
83 | linkStore.deactivate(); | 76 | linkStore.deactivate(); |
84 | - serializationMgr.deactivate(); | ||
85 | storeManager.deactivate(); | 77 | storeManager.deactivate(); |
86 | } | 78 | } |
87 | 79 | ||
... | @@ -361,10 +353,8 @@ public class DistributedLinkStoreTest { | ... | @@ -361,10 +353,8 @@ public class DistributedLinkStoreTest { |
361 | 353 | ||
362 | 354 | ||
363 | class TestDistributedLinkStore extends DistributedLinkStore { | 355 | class TestDistributedLinkStore extends DistributedLinkStore { |
364 | - TestDistributedLinkStore(StoreService storeService, | 356 | + TestDistributedLinkStore(StoreService storeService) { |
365 | - KryoSerializationService kryoSerializationService) { | ||
366 | this.storeService = storeService; | 357 | this.storeService = storeService; |
367 | - this.kryoSerializationService = kryoSerializationService; | ||
368 | } | 358 | } |
369 | } | 359 | } |
370 | } | 360 | } | ... | ... |
1 | package org.onlab.onos.store.serializers; | 1 | package org.onlab.onos.store.serializers; |
2 | 2 | ||
3 | -import org.apache.felix.scr.annotations.Activate; | ||
4 | -import org.apache.felix.scr.annotations.Component; | ||
5 | -import org.apache.felix.scr.annotations.Deactivate; | ||
6 | -import org.apache.felix.scr.annotations.Service; | ||
7 | import org.onlab.util.KryoPool; | 3 | import org.onlab.util.KryoPool; |
8 | import org.slf4j.Logger; | 4 | import org.slf4j.Logger; |
9 | import org.slf4j.LoggerFactory; | 5 | import org.slf4j.LoggerFactory; |
... | @@ -11,25 +7,16 @@ import org.slf4j.LoggerFactory; | ... | @@ -11,25 +7,16 @@ import org.slf4j.LoggerFactory; |
11 | import java.nio.ByteBuffer; | 7 | import java.nio.ByteBuffer; |
12 | 8 | ||
13 | /** | 9 | /** |
14 | - * Serialization service using Kryo. | 10 | + * Serializer implementation using Kryo. |
15 | */ | 11 | */ |
16 | -@Component(immediate = true) | 12 | +public class KryoSerializer implements Serializer { |
17 | -@Service | ||
18 | -public class KryoSerializationManager implements KryoSerializationService { | ||
19 | 13 | ||
20 | private final Logger log = LoggerFactory.getLogger(getClass()); | 14 | private final Logger log = LoggerFactory.getLogger(getClass()); |
21 | private KryoPool serializerPool; | 15 | private KryoPool serializerPool; |
22 | 16 | ||
23 | 17 | ||
24 | - @Activate | 18 | + public KryoSerializer() { |
25 | - public void activate() { | ||
26 | setupKryoPool(); | 19 | setupKryoPool(); |
27 | - log.info("Started"); | ||
28 | - } | ||
29 | - | ||
30 | - @Deactivate | ||
31 | - public void deactivate() { | ||
32 | - log.info("Stopped"); | ||
33 | } | 20 | } |
34 | 21 | ||
35 | /** | 22 | /** | ... | ... |
... | @@ -6,11 +6,10 @@ import java.nio.ByteBuffer; | ... | @@ -6,11 +6,10 @@ import java.nio.ByteBuffer; |
6 | /** | 6 | /** |
7 | * Service to serialize Objects into byte array. | 7 | * Service to serialize Objects into byte array. |
8 | */ | 8 | */ |
9 | -public interface KryoSerializationService { | 9 | +public interface Serializer { |
10 | 10 | ||
11 | /** | 11 | /** |
12 | - * Serializes the specified object into bytes using one of the | 12 | + * Serializes the specified object into bytes. |
13 | - * pre-registered serializers. | ||
14 | * | 13 | * |
15 | * @param obj object to be serialized | 14 | * @param obj object to be serialized |
16 | * @return serialized bytes | 15 | * @return serialized bytes |
... | @@ -18,8 +17,7 @@ public interface KryoSerializationService { | ... | @@ -18,8 +17,7 @@ public interface KryoSerializationService { |
18 | public byte[] encode(final Object obj); | 17 | public byte[] encode(final Object obj); |
19 | 18 | ||
20 | /** | 19 | /** |
21 | - * Serializes the specified object into bytes using one of the | 20 | + * Serializes the specified object into bytes. |
22 | - * pre-registered serializers. | ||
23 | * | 21 | * |
24 | * @param obj object to be serialized | 22 | * @param obj object to be serialized |
25 | * @param buffer to write serialized bytes | 23 | * @param buffer to write serialized bytes |
... | @@ -27,8 +25,7 @@ public interface KryoSerializationService { | ... | @@ -27,8 +25,7 @@ public interface KryoSerializationService { |
27 | public void encode(final Object obj, ByteBuffer buffer); | 25 | public void encode(final Object obj, ByteBuffer buffer); |
28 | 26 | ||
29 | /** | 27 | /** |
30 | - * Deserializes the specified bytes into an object using one of the | 28 | + * Deserializes the specified bytes into an object. |
31 | - * pre-registered serializers. | ||
32 | * | 29 | * |
33 | * @param bytes bytes to be deserialized | 30 | * @param bytes bytes to be deserialized |
34 | * @return deserialized object | 31 | * @return deserialized object |
... | @@ -36,8 +33,7 @@ public interface KryoSerializationService { | ... | @@ -36,8 +33,7 @@ public interface KryoSerializationService { |
36 | public <T> T decode(final byte[] bytes); | 33 | public <T> T decode(final byte[] bytes); |
37 | 34 | ||
38 | /** | 35 | /** |
39 | - * Deserializes the specified bytes into an object using one of the | 36 | + * Deserializes the specified bytes into an object. |
40 | - * pre-registered serializers. | ||
41 | * | 37 | * |
42 | * @param buffer bytes to be deserialized | 38 | * @param buffer bytes to be deserialized |
43 | * @return deserialized object | 39 | * @return deserialized object | ... | ... |
... | @@ -53,6 +53,8 @@ | ... | @@ -53,6 +53,8 @@ |
53 | <feature>onos-api</feature> | 53 | <feature>onos-api</feature> |
54 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> | 54 | <bundle>mvn:org.onlab.onos/onos-core-net/1.0.0-SNAPSHOT</bundle> |
55 | <bundle>mvn:org.onlab.onos/onos-core-dist/1.0.0-SNAPSHOT</bundle> | 55 | <bundle>mvn:org.onlab.onos/onos-core-dist/1.0.0-SNAPSHOT</bundle> |
56 | + <bundle>mvn:org.onlab.onos/onos-core-serializers/1.0.0-SNAPSHOT</bundle> | ||
57 | + <bundle>mvn:org.onlab.onos/onlab-netty/1.0.0-SNAPSHOT</bundle> | ||
56 | </feature> | 58 | </feature> |
57 | 59 | ||
58 | <feature name="onos-core-hazelcast" version="1.0.0" | 60 | <feature name="onos-core-hazelcast" version="1.0.0" | ... | ... |
... | @@ -39,6 +39,7 @@ public interface MessagingService { | ... | @@ -39,6 +39,7 @@ public interface MessagingService { |
39 | */ | 39 | */ |
40 | public void unregisterHandler(String type); | 40 | public void unregisterHandler(String type); |
41 | 41 | ||
42 | + // FIXME: remove me and add PayloadSerializer to all other methods | ||
42 | /** | 43 | /** |
43 | * Specify the serializer to use for encoding/decoding payload. | 44 | * Specify the serializer to use for encoding/decoding payload. |
44 | * | 45 | * | ... | ... |
-
Please register or login to post a comment