Showing
4 changed files
with
134 additions
and
4 deletions
... | @@ -42,6 +42,7 @@ import org.onlab.onos.store.common.impl.MastershipBasedTimestamp; | ... | @@ -42,6 +42,7 @@ import org.onlab.onos.store.common.impl.MastershipBasedTimestamp; |
42 | import org.onlab.onos.store.common.impl.Timestamped; | 42 | import org.onlab.onos.store.common.impl.Timestamped; |
43 | import org.onlab.onos.store.serializers.KryoPoolUtil; | 43 | import org.onlab.onos.store.serializers.KryoPoolUtil; |
44 | import org.onlab.onos.store.serializers.KryoSerializer; | 44 | import org.onlab.onos.store.serializers.KryoSerializer; |
45 | +import org.onlab.onos.store.serializers.MastershipBasedTimestampSerializer; | ||
45 | import org.onlab.util.KryoPool; | 46 | import org.onlab.util.KryoPool; |
46 | import org.onlab.util.NewConcurrentHashMap; | 47 | import org.onlab.util.NewConcurrentHashMap; |
47 | import org.slf4j.Logger; | 48 | import org.slf4j.Logger; |
... | @@ -117,11 +118,11 @@ public class GossipDeviceStore | ... | @@ -117,11 +118,11 @@ public class GossipDeviceStore |
117 | protected void setupKryoPool() { | 118 | protected void setupKryoPool() { |
118 | serializerPool = KryoPool.newBuilder() | 119 | serializerPool = KryoPool.newBuilder() |
119 | .register(KryoPoolUtil.API) | 120 | .register(KryoPoolUtil.API) |
120 | - .register(InternalDeviceEvent.class) | 121 | + .register(InternalDeviceEvent.class, new InternalDeviceEventSerializer()) |
121 | - .register(InternalPortEvent.class) | 122 | + .register(InternalPortEvent.class, new InternalPortEventSerializer()) |
122 | - .register(InternalPortStatusEvent.class) | 123 | + .register(InternalPortStatusEvent.class, new InternalPortStatusEventSerializer()) |
123 | .register(Timestamped.class) | 124 | .register(Timestamped.class) |
124 | - .register(MastershipBasedTimestamp.class) | 125 | + .register(MastershipBasedTimestamp.class, new MastershipBasedTimestampSerializer()) |
125 | .build() | 126 | .build() |
126 | .populate(1); | 127 | .populate(1); |
127 | } | 128 | } | ... | ... |
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalDeviceEventSerializer.java
0 → 100644
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import org.onlab.onos.net.DeviceId; | ||
4 | +import org.onlab.onos.net.device.DeviceDescription; | ||
5 | +import org.onlab.onos.net.provider.ProviderId; | ||
6 | +import org.onlab.onos.store.common.impl.Timestamped; | ||
7 | + | ||
8 | +import com.esotericsoftware.kryo.Kryo; | ||
9 | +import com.esotericsoftware.kryo.Serializer; | ||
10 | +import com.esotericsoftware.kryo.io.Input; | ||
11 | +import com.esotericsoftware.kryo.io.Output; | ||
12 | + | ||
13 | +/** | ||
14 | + * Kryo Serializer for {@link InternalDeviceEvent}. | ||
15 | + */ | ||
16 | +public class InternalDeviceEventSerializer extends Serializer<InternalDeviceEvent> { | ||
17 | + | ||
18 | + /** | ||
19 | + * Creates a serializer for {@link InternalDeviceEvent}. | ||
20 | + */ | ||
21 | + public InternalDeviceEventSerializer() { | ||
22 | + // does not accept null | ||
23 | + super(false); | ||
24 | + } | ||
25 | + | ||
26 | + @Override | ||
27 | + public void write(Kryo kryo, Output output, InternalDeviceEvent event) { | ||
28 | + kryo.writeClassAndObject(output, event.providerId()); | ||
29 | + kryo.writeClassAndObject(output, event.deviceId()); | ||
30 | + kryo.writeClassAndObject(output, event.deviceDescription()); | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public InternalDeviceEvent read(Kryo kryo, Input input, | ||
35 | + Class<InternalDeviceEvent> type) { | ||
36 | + ProviderId providerId = (ProviderId) kryo.readClassAndObject(input); | ||
37 | + DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | ||
38 | + Timestamped<DeviceDescription> deviceDescription = (Timestamped<DeviceDescription>) kryo.readClassAndObject(input); | ||
39 | + | ||
40 | + return new InternalDeviceEvent(providerId, deviceId, deviceDescription); | ||
41 | + } | ||
42 | +} |
core/store/dist/src/main/java/org/onlab/onos/store/device/impl/InternalPortEventSerializer.java
0 → 100644
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import java.util.List; | ||
4 | + | ||
5 | +import org.onlab.onos.net.DeviceId; | ||
6 | +import org.onlab.onos.net.device.DeviceDescription; | ||
7 | +import org.onlab.onos.net.device.PortDescription; | ||
8 | +import org.onlab.onos.net.provider.ProviderId; | ||
9 | +import org.onlab.onos.store.common.impl.Timestamped; | ||
10 | + | ||
11 | +import com.esotericsoftware.kryo.Kryo; | ||
12 | +import com.esotericsoftware.kryo.Serializer; | ||
13 | +import com.esotericsoftware.kryo.io.Input; | ||
14 | +import com.esotericsoftware.kryo.io.Output; | ||
15 | + | ||
16 | +/** | ||
17 | + * Kryo Serializer for {@link InternalPortEvent}. | ||
18 | + */ | ||
19 | +public class InternalPortEventSerializer extends Serializer<InternalPortEvent> { | ||
20 | + | ||
21 | + /** | ||
22 | + * Creates a serializer for {@link InternalPortEvent}. | ||
23 | + */ | ||
24 | + public InternalPortEventSerializer() { | ||
25 | + // does not accept null | ||
26 | + super(false); | ||
27 | + } | ||
28 | + | ||
29 | + @Override | ||
30 | + public void write(Kryo kryo, Output output, InternalPortEvent event) { | ||
31 | + kryo.writeClassAndObject(output, event.providerId()); | ||
32 | + kryo.writeClassAndObject(output, event.deviceId()); | ||
33 | + kryo.writeClassAndObject(output, event.portDescriptions()); | ||
34 | + } | ||
35 | + | ||
36 | + @Override | ||
37 | + public InternalPortEvent read(Kryo kryo, Input input, | ||
38 | + Class<InternalPortEvent> type) { | ||
39 | + ProviderId providerId = (ProviderId) kryo.readClassAndObject(input); | ||
40 | + DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | ||
41 | + Timestamped<List<PortDescription>> portDescriptions = (Timestamped<List<PortDescription>>) kryo.readClassAndObject(input); | ||
42 | + | ||
43 | + return new InternalPortEvent(providerId, deviceId, portDescriptions); | ||
44 | + } | ||
45 | +} |
1 | +package org.onlab.onos.store.device.impl; | ||
2 | + | ||
3 | +import org.onlab.onos.net.DeviceId; | ||
4 | +import org.onlab.onos.net.device.PortDescription; | ||
5 | +import org.onlab.onos.net.provider.ProviderId; | ||
6 | +import org.onlab.onos.store.common.impl.Timestamped; | ||
7 | + | ||
8 | +import com.esotericsoftware.kryo.Kryo; | ||
9 | +import com.esotericsoftware.kryo.Serializer; | ||
10 | +import com.esotericsoftware.kryo.io.Input; | ||
11 | +import com.esotericsoftware.kryo.io.Output; | ||
12 | + | ||
13 | +/** | ||
14 | + * Kryo Serializer for {@link InternalPortStatusEvent}. | ||
15 | + */ | ||
16 | +public class InternalPortStatusEventSerializer extends Serializer<InternalPortStatusEvent> { | ||
17 | + | ||
18 | + /** | ||
19 | + * Creates a serializer for {@link InternalPortStatusEvent}. | ||
20 | + */ | ||
21 | + public InternalPortStatusEventSerializer() { | ||
22 | + // does not accept null | ||
23 | + super(false); | ||
24 | + } | ||
25 | + | ||
26 | + @Override | ||
27 | + public void write(Kryo kryo, Output output, InternalPortStatusEvent event) { | ||
28 | + kryo.writeClassAndObject(output, event.providerId()); | ||
29 | + kryo.writeClassAndObject(output, event.deviceId()); | ||
30 | + kryo.writeClassAndObject(output, event.portDescription()); | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public InternalPortStatusEvent read(Kryo kryo, Input input, | ||
35 | + Class<InternalPortStatusEvent> type) { | ||
36 | + ProviderId providerId = (ProviderId) kryo.readClassAndObject(input); | ||
37 | + DeviceId deviceId = (DeviceId) kryo.readClassAndObject(input); | ||
38 | + Timestamped<PortDescription> portDescription = (Timestamped<PortDescription>) kryo.readClassAndObject(input); | ||
39 | + | ||
40 | + return new InternalPortStatusEvent(providerId, deviceId, portDescription); | ||
41 | + } | ||
42 | +} |
-
Please register or login to post a comment