Yuta HIGUCHI

minor Kryo related cleanup

Change-Id: I772fc1f776563d30f1a4081c6fddd5739d985263
Showing 18 changed files with 173 additions and 150 deletions
1 package org.onlab.onos.store.cluster.impl; 1 package org.onlab.onos.store.cluster.impl;
2 2
3 -import de.javakaffee.kryoserializers.URISerializer;
4 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
5 import org.apache.felix.scr.annotations.Component; 4 import org.apache.felix.scr.annotations.Component;
6 import org.apache.felix.scr.annotations.Deactivate; 5 import org.apache.felix.scr.annotations.Deactivate;
7 import org.apache.felix.scr.annotations.Service; 6 import org.apache.felix.scr.annotations.Service;
8 -import org.onlab.onos.cluster.ControllerNode;
9 -import org.onlab.onos.cluster.DefaultControllerNode;
10 -import org.onlab.onos.cluster.NodeId;
11 -import org.onlab.onos.net.ConnectPoint;
12 -import org.onlab.onos.net.DefaultDevice;
13 -import org.onlab.onos.net.DefaultLink;
14 -import org.onlab.onos.net.DefaultPort;
15 -import org.onlab.onos.net.Device;
16 -import org.onlab.onos.net.DeviceId;
17 -import org.onlab.onos.net.Element;
18 -import org.onlab.onos.net.Link;
19 -import org.onlab.onos.net.LinkKey;
20 -import org.onlab.onos.net.MastershipRole;
21 -import org.onlab.onos.net.Port;
22 -import org.onlab.onos.net.PortNumber;
23 -import org.onlab.onos.net.provider.ProviderId;
24 import org.onlab.onos.store.cluster.messaging.MessageSubject; 7 import org.onlab.onos.store.cluster.messaging.MessageSubject;
25 import org.onlab.onos.store.cluster.messaging.SerializationService; 8 import org.onlab.onos.store.cluster.messaging.SerializationService;
26 -import org.onlab.onos.store.serializers.ConnectPointSerializer; 9 +import org.onlab.onos.store.serializers.KryoPoolUtil;
27 -import org.onlab.onos.store.serializers.DefaultLinkSerializer;
28 -import org.onlab.onos.store.serializers.DefaultPortSerializer;
29 -import org.onlab.onos.store.serializers.DeviceIdSerializer;
30 -import org.onlab.onos.store.serializers.IpPrefixSerializer;
31 -import org.onlab.onos.store.serializers.LinkKeySerializer;
32 -import org.onlab.onos.store.serializers.NodeIdSerializer;
33 -import org.onlab.onos.store.serializers.PortNumberSerializer;
34 -import org.onlab.onos.store.serializers.ProviderIdSerializer;
35 -import org.onlab.packet.IpPrefix;
36 import org.onlab.util.KryoPool; 10 import org.onlab.util.KryoPool;
37 import org.slf4j.Logger; 11 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory; 12 import org.slf4j.LoggerFactory;
39 13
40 -import java.net.URI;
41 -import java.util.ArrayList;
42 -import java.util.HashMap;
43 -
44 /** 14 /**
45 * Factory for parsing messages sent between cluster members. 15 * Factory for parsing messages sent between cluster members.
46 */ 16 */
...@@ -72,34 +42,10 @@ public class MessageSerializer implements SerializationService { ...@@ -72,34 +42,10 @@ public class MessageSerializer implements SerializationService {
72 * Sets up the common serialzers pool. 42 * Sets up the common serialzers pool.
73 */ 43 */
74 protected void setupKryoPool() { 44 protected void setupKryoPool() {
75 - // FIXME Slice out types used in common to separate pool/namespace.
76 serializerPool = KryoPool.newBuilder() 45 serializerPool = KryoPool.newBuilder()
77 - .register(ArrayList.class, 46 + .register(KryoPoolUtil.API)
78 - HashMap.class, 47 + // TODO: Should MessageSubject be in API bundle?
79 - 48 + .register(MessageSubject.class)
80 - ControllerNode.State.class,
81 - Device.Type.class,
82 -
83 - DefaultControllerNode.class,
84 - DefaultDevice.class,
85 - MastershipRole.class,
86 - Port.class,
87 - Element.class,
88 -
89 - Link.Type.class,
90 -
91 - MessageSubject.class
92 - )
93 - .register(IpPrefix.class, new IpPrefixSerializer())
94 - .register(URI.class, new URISerializer())
95 - .register(NodeId.class, new NodeIdSerializer())
96 - .register(ProviderId.class, new ProviderIdSerializer())
97 - .register(DeviceId.class, new DeviceIdSerializer())
98 - .register(PortNumber.class, new PortNumberSerializer())
99 - .register(DefaultPort.class, new DefaultPortSerializer())
100 - .register(LinkKey.class, new LinkKeySerializer())
101 - .register(ConnectPoint.class, new ConnectPointSerializer())
102 - .register(DefaultLink.class, new DefaultLinkSerializer())
103 .build() 49 .build()
104 .populate(1); 50 .populate(1);
105 } 51 }
......
...@@ -3,7 +3,6 @@ package org.onlab.onos.store.serializers; ...@@ -3,7 +3,6 @@ package org.onlab.onos.store.serializers;
3 import org.onlab.onos.net.ConnectPoint; 3 import org.onlab.onos.net.ConnectPoint;
4 import org.onlab.onos.net.ElementId; 4 import org.onlab.onos.net.ElementId;
5 import org.onlab.onos.net.PortNumber; 5 import org.onlab.onos.net.PortNumber;
6 -
7 import com.esotericsoftware.kryo.Kryo; 6 import com.esotericsoftware.kryo.Kryo;
8 import com.esotericsoftware.kryo.Serializer; 7 import com.esotericsoftware.kryo.Serializer;
9 import com.esotericsoftware.kryo.io.Input; 8 import com.esotericsoftware.kryo.io.Input;
...@@ -15,7 +14,7 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -15,7 +14,7 @@ import com.esotericsoftware.kryo.io.Output;
15 public class ConnectPointSerializer extends Serializer<ConnectPoint> { 14 public class ConnectPointSerializer extends Serializer<ConnectPoint> {
16 15
17 /** 16 /**
18 - * Default constructor. 17 + * Creates {@link ConnectPointSerializer} serializer instance.
19 */ 18 */
20 public ConnectPointSerializer() { 19 public ConnectPointSerializer() {
21 // non-null, immutable 20 // non-null, immutable
......
...@@ -16,7 +16,7 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -16,7 +16,7 @@ import com.esotericsoftware.kryo.io.Output;
16 public class DefaultLinkSerializer extends Serializer<DefaultLink> { 16 public class DefaultLinkSerializer extends Serializer<DefaultLink> {
17 17
18 /** 18 /**
19 - * Default constructor. 19 + * Creates {@link DefaultLink} serializer instance.
20 */ 20 */
21 public DefaultLinkSerializer() { 21 public DefaultLinkSerializer() {
22 // non-null, immutable 22 // non-null, immutable
......
...@@ -16,7 +16,7 @@ public final class DefaultPortSerializer extends ...@@ -16,7 +16,7 @@ public final class DefaultPortSerializer extends
16 Serializer<DefaultPort> { 16 Serializer<DefaultPort> {
17 17
18 /** 18 /**
19 - * Default constructor. 19 + * Creates {@link DefaultPort} serializer instance.
20 */ 20 */
21 public DefaultPortSerializer() { 21 public DefaultPortSerializer() {
22 // non-null, immutable 22 // non-null, immutable
......
...@@ -14,6 +14,14 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -14,6 +14,14 @@ import com.esotericsoftware.kryo.io.Output;
14 */ 14 */
15 public final class DeviceIdSerializer extends Serializer<DeviceId> { 15 public final class DeviceIdSerializer extends Serializer<DeviceId> {
16 16
17 + /**
18 + * Creates {@link DeviceId} serializer instance.
19 + */
20 + public DeviceIdSerializer() {
21 + // non-null, immutable
22 + super(false, true);
23 + }
24 +
17 @Override 25 @Override
18 public void write(Kryo kryo, Output output, DeviceId object) { 26 public void write(Kryo kryo, Output output, DeviceId object) {
19 kryo.writeObject(output, object.uri()); 27 kryo.writeObject(output, object.uri());
......
...@@ -19,6 +19,9 @@ public class ImmutableMapSerializer extends FamilySerializer<ImmutableMap<?, ?>> ...@@ -19,6 +19,9 @@ public class ImmutableMapSerializer extends FamilySerializer<ImmutableMap<?, ?>>
19 19
20 private final MapSerializer mapSerializer = new MapSerializer(); 20 private final MapSerializer mapSerializer = new MapSerializer();
21 21
22 + /**
23 + * Creates {@link ImmutableMap} serializer instance.
24 + */
22 public ImmutableMapSerializer() { 25 public ImmutableMapSerializer() {
23 // non-null, immutable 26 // non-null, immutable
24 super(false, true); 27 super(false, true);
......
...@@ -18,6 +18,9 @@ public class ImmutableSetSerializer extends FamilySerializer<ImmutableSet<?>> { ...@@ -18,6 +18,9 @@ public class ImmutableSetSerializer extends FamilySerializer<ImmutableSet<?>> {
18 18
19 private final CollectionSerializer serializer = new CollectionSerializer(); 19 private final CollectionSerializer serializer = new CollectionSerializer();
20 20
21 + /**
22 + * Creates {@link ImmutableSet} serializer instance.
23 + */
21 public ImmutableSetSerializer() { 24 public ImmutableSetSerializer() {
22 // non-null, immutable 25 // non-null, immutable
23 super(false, true); 26 super(false, true);
......
1 +package org.onlab.onos.store.serializers;
2 +
3 +import org.onlab.packet.IpAddress;
4 +import com.esotericsoftware.kryo.Kryo;
5 +import com.esotericsoftware.kryo.Serializer;
6 +import com.esotericsoftware.kryo.io.Input;
7 +import com.esotericsoftware.kryo.io.Output;
8 +
9 +/**
10 + * Kryo Serializer for {@link IpAddress}.
11 + */
12 +public class IpAddressSerializer extends Serializer<IpAddress> {
13 +
14 + /**
15 + * Creates {@link IpAddress} serializer instance.
16 + */
17 + public IpAddressSerializer() {
18 + // non-null, immutable
19 + super(false, true);
20 + }
21 +
22 + @Override
23 + public void write(Kryo kryo, Output output,
24 + IpAddress object) {
25 + byte[] octs = object.toOctets();
26 + output.writeInt(octs.length);
27 + output.writeBytes(octs);
28 + output.writeInt(object.prefixLength());
29 + }
30 +
31 + @Override
32 + public IpAddress read(Kryo kryo, Input input,
33 + Class<IpAddress> type) {
34 + int octLen = input.readInt();
35 + byte[] octs = new byte[octLen];
36 + input.read(octs);
37 + int prefLen = input.readInt();
38 + return IpAddress.valueOf(octs, prefLen);
39 + }
40 +
41 +}
...@@ -13,7 +13,7 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -13,7 +13,7 @@ import com.esotericsoftware.kryo.io.Output;
13 public final class IpPrefixSerializer extends Serializer<IpPrefix> { 13 public final class IpPrefixSerializer extends Serializer<IpPrefix> {
14 14
15 /** 15 /**
16 - * Default constructor. 16 + * Creates {@link IpPrefix} serializer instance.
17 */ 17 */
18 public IpPrefixSerializer() { 18 public IpPrefixSerializer() {
19 // non-null, immutable 19 // non-null, immutable
......
1 +package org.onlab.onos.store.serializers;
2 +
3 +import java.net.URI;
4 +import java.util.ArrayList;
5 +import java.util.HashMap;
6 +
7 +import org.onlab.onos.cluster.ControllerNode;
8 +import org.onlab.onos.cluster.DefaultControllerNode;
9 +import org.onlab.onos.cluster.MastershipTerm;
10 +import org.onlab.onos.cluster.NodeId;
11 +import org.onlab.onos.net.ConnectPoint;
12 +import org.onlab.onos.net.DefaultAnnotations;
13 +import org.onlab.onos.net.DefaultDevice;
14 +import org.onlab.onos.net.DefaultLink;
15 +import org.onlab.onos.net.DefaultPort;
16 +import org.onlab.onos.net.Device;
17 +import org.onlab.onos.net.DeviceId;
18 +import org.onlab.onos.net.Element;
19 +import org.onlab.onos.net.Link;
20 +import org.onlab.onos.net.LinkKey;
21 +import org.onlab.onos.net.MastershipRole;
22 +import org.onlab.onos.net.Port;
23 +import org.onlab.onos.net.PortNumber;
24 +import org.onlab.onos.net.provider.ProviderId;
25 +import org.onlab.packet.IpAddress;
26 +import org.onlab.packet.IpPrefix;
27 +import org.onlab.util.KryoPool;
28 +
29 +import de.javakaffee.kryoserializers.URISerializer;
30 +
31 +public final class KryoPoolUtil {
32 +
33 + /**
34 + * KryoPool which can serialize ON.lab misc classes.
35 + */
36 + public static final KryoPool MISC = KryoPool.newBuilder()
37 + .register(IpPrefix.class, new IpPrefixSerializer())
38 + .register(IpAddress.class, new IpAddressSerializer())
39 + .build();
40 +
41 + // TODO: Populate other classes
42 + /**
43 + * KryoPool which can serialize API bundle classes.
44 + */
45 + public static final KryoPool API = KryoPool.newBuilder()
46 + .register(MISC)
47 + .register(
48 + //
49 + ArrayList.class,
50 + HashMap.class,
51 + //
52 + ControllerNode.State.class,
53 + Device.Type.class,
54 + DefaultAnnotations.class,
55 + DefaultControllerNode.class,
56 + DefaultDevice.class,
57 + MastershipRole.class,
58 + Port.class,
59 + Element.class,
60 + Link.Type.class
61 + )
62 + .register(URI.class, new URISerializer())
63 + .register(NodeId.class, new NodeIdSerializer())
64 + .register(ProviderId.class, new ProviderIdSerializer())
65 + .register(DeviceId.class, new DeviceIdSerializer())
66 + .register(PortNumber.class, new PortNumberSerializer())
67 + .register(DefaultPort.class, new DefaultPortSerializer())
68 + .register(LinkKey.class, new LinkKeySerializer())
69 + .register(ConnectPoint.class, new ConnectPointSerializer())
70 + .register(DefaultLink.class, new DefaultLinkSerializer())
71 + .register(MastershipTerm.class, new MastershipTermSerializer())
72 + .register(MastershipRole.class, new MastershipRoleSerializer())
73 +
74 + .build();
75 +
76 +
77 + // not to be instantiated
78 + private KryoPoolUtil() {}
79 +}
1 package org.onlab.onos.store.serializers; 1 package org.onlab.onos.store.serializers;
2 2
3 -import de.javakaffee.kryoserializers.URISerializer;
4 import org.apache.felix.scr.annotations.Activate; 3 import org.apache.felix.scr.annotations.Activate;
5 import org.apache.felix.scr.annotations.Component; 4 import org.apache.felix.scr.annotations.Component;
6 import org.apache.felix.scr.annotations.Deactivate; 5 import org.apache.felix.scr.annotations.Deactivate;
7 import org.apache.felix.scr.annotations.Service; 6 import org.apache.felix.scr.annotations.Service;
8 -import org.onlab.onos.cluster.ControllerNode;
9 -import org.onlab.onos.cluster.DefaultControllerNode;
10 -import org.onlab.onos.cluster.NodeId;
11 -import org.onlab.onos.net.ConnectPoint;
12 -import org.onlab.onos.net.DefaultAnnotations;
13 -import org.onlab.onos.net.DefaultDevice;
14 -import org.onlab.onos.net.DefaultLink;
15 -import org.onlab.onos.net.DefaultPort;
16 -import org.onlab.onos.net.Device;
17 -import org.onlab.onos.net.DeviceId;
18 -import org.onlab.onos.net.Element;
19 -import org.onlab.onos.net.Link;
20 -import org.onlab.onos.net.LinkKey;
21 -import org.onlab.onos.net.MastershipRole;
22 -import org.onlab.onos.net.Port;
23 -import org.onlab.onos.net.PortNumber;
24 -import org.onlab.onos.net.provider.ProviderId;
25 -import org.onlab.packet.IpPrefix;
26 import org.onlab.util.KryoPool; 7 import org.onlab.util.KryoPool;
27 import org.slf4j.Logger; 8 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory; 9 import org.slf4j.LoggerFactory;
29 10
30 -import java.net.URI;
31 import java.nio.ByteBuffer; 11 import java.nio.ByteBuffer;
32 -import java.util.ArrayList;
33 -import java.util.HashMap;
34 12
35 /** 13 /**
36 * Serialization service using Kryo. 14 * Serialization service using Kryo.
...@@ -58,33 +36,8 @@ public class KryoSerializationManager implements KryoSerializationService { ...@@ -58,33 +36,8 @@ public class KryoSerializationManager implements KryoSerializationService {
58 * Sets up the common serialzers pool. 36 * Sets up the common serialzers pool.
59 */ 37 */
60 protected void setupKryoPool() { 38 protected void setupKryoPool() {
61 - // FIXME Slice out types used in common to separate pool/namespace.
62 serializerPool = KryoPool.newBuilder() 39 serializerPool = KryoPool.newBuilder()
63 - .register(ArrayList.class, 40 + .register(KryoPoolUtil.API)
64 - HashMap.class,
65 -
66 - ControllerNode.State.class,
67 - Device.Type.class,
68 -
69 - DefaultAnnotations.class,
70 - DefaultControllerNode.class,
71 - DefaultDevice.class,
72 - MastershipRole.class,
73 - Port.class,
74 - Element.class,
75 -
76 - Link.Type.class
77 - )
78 - .register(IpPrefix.class, new IpPrefixSerializer())
79 - .register(URI.class, new URISerializer())
80 - .register(NodeId.class, new NodeIdSerializer())
81 - .register(ProviderId.class, new ProviderIdSerializer())
82 - .register(DeviceId.class, new DeviceIdSerializer())
83 - .register(PortNumber.class, new PortNumberSerializer())
84 - .register(DefaultPort.class, new DefaultPortSerializer())
85 - .register(LinkKey.class, new LinkKeySerializer())
86 - .register(ConnectPoint.class, new ConnectPointSerializer())
87 - .register(DefaultLink.class, new DefaultLinkSerializer())
88 .build() 41 .build()
89 .populate(1); 42 .populate(1);
90 } 43 }
......
...@@ -2,6 +2,7 @@ package org.onlab.onos.store.serializers; ...@@ -2,6 +2,7 @@ package org.onlab.onos.store.serializers;
2 2
3 import org.onlab.onos.net.ConnectPoint; 3 import org.onlab.onos.net.ConnectPoint;
4 import org.onlab.onos.net.LinkKey; 4 import org.onlab.onos.net.LinkKey;
5 +
5 import com.esotericsoftware.kryo.Kryo; 6 import com.esotericsoftware.kryo.Kryo;
6 import com.esotericsoftware.kryo.Serializer; 7 import com.esotericsoftware.kryo.Serializer;
7 import com.esotericsoftware.kryo.io.Input; 8 import com.esotericsoftware.kryo.io.Input;
...@@ -13,7 +14,7 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -13,7 +14,7 @@ import com.esotericsoftware.kryo.io.Output;
13 public class LinkKeySerializer extends Serializer<LinkKey> { 14 public class LinkKeySerializer extends Serializer<LinkKey> {
14 15
15 /** 16 /**
16 - * Default constructor. 17 + * Creates {@link LinkKey} serializer instance.
17 */ 18 */
18 public LinkKeySerializer() { 19 public LinkKeySerializer() {
19 // non-null, immutable 20 // non-null, immutable
......
...@@ -12,6 +12,14 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -12,6 +12,14 @@ import com.esotericsoftware.kryo.io.Output;
12 */ 12 */
13 public class MastershipRoleSerializer extends Serializer<MastershipRole> { 13 public class MastershipRoleSerializer extends Serializer<MastershipRole> {
14 14
15 + /**
16 + * Creates {@link MastershipRole} serializer instance.
17 + */
18 + public MastershipRoleSerializer() {
19 + // non-null, immutable
20 + super(false, true);
21 + }
22 +
15 @Override 23 @Override
16 public MastershipRole read(Kryo kryo, Input input, Class<MastershipRole> type) { 24 public MastershipRole read(Kryo kryo, Input input, Class<MastershipRole> type) {
17 final String role = kryo.readObject(input, String.class); 25 final String role = kryo.readObject(input, String.class);
......
...@@ -2,7 +2,6 @@ package org.onlab.onos.store.serializers; ...@@ -2,7 +2,6 @@ package org.onlab.onos.store.serializers;
2 2
3 import org.onlab.onos.cluster.MastershipTerm; 3 import org.onlab.onos.cluster.MastershipTerm;
4 import org.onlab.onos.cluster.NodeId; 4 import org.onlab.onos.cluster.NodeId;
5 -
6 import com.esotericsoftware.kryo.Kryo; 5 import com.esotericsoftware.kryo.Kryo;
7 import com.esotericsoftware.kryo.Serializer; 6 import com.esotericsoftware.kryo.Serializer;
8 import com.esotericsoftware.kryo.io.Input; 7 import com.esotericsoftware.kryo.io.Input;
...@@ -13,6 +12,14 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -13,6 +12,14 @@ import com.esotericsoftware.kryo.io.Output;
13 */ 12 */
14 public class MastershipTermSerializer extends Serializer<MastershipTerm> { 13 public class MastershipTermSerializer extends Serializer<MastershipTerm> {
15 14
15 + /**
16 + * Creates {@link MastershipTerm} serializer instance.
17 + */
18 + public MastershipTermSerializer() {
19 + // non-null, immutable
20 + super(false, true);
21 + }
22 +
16 @Override 23 @Override
17 public MastershipTerm read(Kryo kryo, Input input, Class<MastershipTerm> type) { 24 public MastershipTerm read(Kryo kryo, Input input, Class<MastershipTerm> type) {
18 final NodeId node = new NodeId(kryo.readObject(input, String.class)); 25 final NodeId node = new NodeId(kryo.readObject(input, String.class));
......
...@@ -4,6 +4,7 @@ import com.esotericsoftware.kryo.Kryo; ...@@ -4,6 +4,7 @@ import com.esotericsoftware.kryo.Kryo;
4 import com.esotericsoftware.kryo.Serializer; 4 import com.esotericsoftware.kryo.Serializer;
5 import com.esotericsoftware.kryo.io.Input; 5 import com.esotericsoftware.kryo.io.Input;
6 import com.esotericsoftware.kryo.io.Output; 6 import com.esotericsoftware.kryo.io.Output;
7 +
7 import org.onlab.onos.cluster.NodeId; 8 import org.onlab.onos.cluster.NodeId;
8 9
9 /** 10 /**
...@@ -11,6 +12,14 @@ import org.onlab.onos.cluster.NodeId; ...@@ -11,6 +12,14 @@ import org.onlab.onos.cluster.NodeId;
11 */ 12 */
12 public final class NodeIdSerializer extends Serializer<NodeId> { 13 public final class NodeIdSerializer extends Serializer<NodeId> {
13 14
15 + /**
16 + * Creates {@link NodeId} serializer instance.
17 + */
18 + public NodeIdSerializer() {
19 + // non-null, immutable
20 + super(false, true);
21 + }
22 +
14 @Override 23 @Override
15 public void write(Kryo kryo, Output output, NodeId object) { 24 public void write(Kryo kryo, Output output, NodeId object) {
16 kryo.writeObject(output, object.toString()); 25 kryo.writeObject(output, object.toString());
......
...@@ -14,7 +14,7 @@ public final class PortNumberSerializer extends ...@@ -14,7 +14,7 @@ public final class PortNumberSerializer extends
14 Serializer<PortNumber> { 14 Serializer<PortNumber> {
15 15
16 /** 16 /**
17 - * Default constructor. 17 + * Creates {@link PortNumber} serializer instance.
18 */ 18 */
19 public PortNumberSerializer() { 19 public PortNumberSerializer() {
20 // non-null, immutable 20 // non-null, immutable
......
...@@ -13,7 +13,7 @@ import com.esotericsoftware.kryo.io.Output; ...@@ -13,7 +13,7 @@ import com.esotericsoftware.kryo.io.Output;
13 public class ProviderIdSerializer extends Serializer<ProviderId> { 13 public class ProviderIdSerializer extends Serializer<ProviderId> {
14 14
15 /** 15 /**
16 - * Default constructor. 16 + * Creates {@link ProviderId} serializer instance.
17 */ 17 */
18 public ProviderIdSerializer() { 18 public ProviderIdSerializer() {
19 // non-null, immutable 19 // non-null, immutable
......
...@@ -3,16 +3,11 @@ package org.onlab.onos.store.serializers; ...@@ -3,16 +3,11 @@ package org.onlab.onos.store.serializers;
3 import static org.onlab.onos.net.DeviceId.deviceId; 3 import static org.onlab.onos.net.DeviceId.deviceId;
4 import static org.onlab.onos.net.PortNumber.portNumber; 4 import static org.onlab.onos.net.PortNumber.portNumber;
5 5
6 -import java.net.URI;
7 import java.nio.ByteBuffer; 6 import java.nio.ByteBuffer;
8 -import java.util.ArrayList;
9 -import java.util.HashMap;
10 -
11 import org.junit.After; 7 import org.junit.After;
12 import org.junit.Before; 8 import org.junit.Before;
13 import org.junit.BeforeClass; 9 import org.junit.BeforeClass;
14 import org.junit.Test; 10 import org.junit.Test;
15 -import org.onlab.onos.cluster.MastershipTerm;
16 import org.onlab.onos.cluster.NodeId; 11 import org.onlab.onos.cluster.NodeId;
17 import org.onlab.onos.net.ConnectPoint; 12 import org.onlab.onos.net.ConnectPoint;
18 import org.onlab.onos.net.DefaultDevice; 13 import org.onlab.onos.net.DefaultDevice;
...@@ -22,7 +17,6 @@ import org.onlab.onos.net.Device; ...@@ -22,7 +17,6 @@ import org.onlab.onos.net.Device;
22 import org.onlab.onos.net.DeviceId; 17 import org.onlab.onos.net.DeviceId;
23 import org.onlab.onos.net.Link; 18 import org.onlab.onos.net.Link;
24 import org.onlab.onos.net.LinkKey; 19 import org.onlab.onos.net.LinkKey;
25 -import org.onlab.onos.net.MastershipRole;
26 import org.onlab.onos.net.PortNumber; 20 import org.onlab.onos.net.PortNumber;
27 import org.onlab.onos.net.provider.ProviderId; 21 import org.onlab.onos.net.provider.ProviderId;
28 import org.onlab.packet.IpPrefix; 22 import org.onlab.packet.IpPrefix;
...@@ -32,8 +26,6 @@ import com.google.common.collect.ImmutableMap; ...@@ -32,8 +26,6 @@ import com.google.common.collect.ImmutableMap;
32 import com.google.common.collect.ImmutableSet; 26 import com.google.common.collect.ImmutableSet;
33 import com.google.common.testing.EqualsTester; 27 import com.google.common.testing.EqualsTester;
34 28
35 -import de.javakaffee.kryoserializers.URISerializer;
36 -
37 public class KryoSerializerTests { 29 public class KryoSerializerTests {
38 private static final ProviderId PID = new ProviderId("of", "foo"); 30 private static final ProviderId PID = new ProviderId("of", "foo");
39 private static final DeviceId DID1 = deviceId("of:foo"); 31 private static final DeviceId DID1 = deviceId("of:foo");
...@@ -54,38 +46,12 @@ public class KryoSerializerTests { ...@@ -54,38 +46,12 @@ public class KryoSerializerTests {
54 @BeforeClass 46 @BeforeClass
55 public static void setUpBeforeClass() throws Exception { 47 public static void setUpBeforeClass() throws Exception {
56 kryos = KryoPool.newBuilder() 48 kryos = KryoPool.newBuilder()
57 - .register( 49 + .register(KryoPoolUtil.API)
58 - ArrayList.class,
59 - HashMap.class
60 - )
61 - .register(
62 - Device.Type.class,
63 - Link.Type.class
64 -
65 -// ControllerNode.State.class,
66 -// DefaultControllerNode.class,
67 -// MastershipRole.class,
68 -// Port.class,
69 -// Element.class,
70 - )
71 - .register(ConnectPoint.class, new ConnectPointSerializer())
72 - .register(DefaultLink.class, new DefaultLinkSerializer())
73 - .register(DefaultPort.class, new DefaultPortSerializer())
74 - .register(DeviceId.class, new DeviceIdSerializer())
75 .register(ImmutableMap.class, new ImmutableMapSerializer()) 50 .register(ImmutableMap.class, new ImmutableMapSerializer())
76 .register(ImmutableSet.class, new ImmutableSetSerializer()) 51 .register(ImmutableSet.class, new ImmutableSetSerializer())
77 - .register(IpPrefix.class, new IpPrefixSerializer())
78 - .register(LinkKey.class, new LinkKeySerializer())
79 - .register(NodeId.class, new NodeIdSerializer())
80 - .register(PortNumber.class, new PortNumberSerializer())
81 - .register(ProviderId.class, new ProviderIdSerializer())
82 52
83 - .register(DefaultDevice.class)
84 53
85 - .register(URI.class, new URISerializer())
86 54
87 - .register(MastershipRole.class, new MastershipRoleSerializer())
88 - .register(MastershipTerm.class, new MastershipTermSerializer())
89 .build(); 55 .build();
90 } 56 }
91 57
......