Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next
Showing
4 changed files
with
37 additions
and
3 deletions
... | @@ -29,6 +29,7 @@ import org.onlab.onos.store.cluster.messaging.MessageSubject; | ... | @@ -29,6 +29,7 @@ import org.onlab.onos.store.cluster.messaging.MessageSubject; |
29 | import org.onlab.onos.store.serializers.ClusterMessageSerializer; | 29 | import org.onlab.onos.store.serializers.ClusterMessageSerializer; |
30 | import org.onlab.onos.store.serializers.KryoPoolUtil; | 30 | import org.onlab.onos.store.serializers.KryoPoolUtil; |
31 | import org.onlab.onos.store.serializers.KryoSerializer; | 31 | import org.onlab.onos.store.serializers.KryoSerializer; |
32 | +import org.onlab.onos.store.serializers.MessageSubjectSerializer; | ||
32 | import org.onlab.util.KryoPool; | 33 | import org.onlab.util.KryoPool; |
33 | import org.onlab.netty.Endpoint; | 34 | import org.onlab.netty.Endpoint; |
34 | import org.onlab.netty.Message; | 35 | import org.onlab.netty.Message; |
... | @@ -66,7 +67,7 @@ public class ClusterCommunicationManager | ... | @@ -66,7 +67,7 @@ public class ClusterCommunicationManager |
66 | .register(ClusterMessage.class, new ClusterMessageSerializer()) | 67 | .register(ClusterMessage.class, new ClusterMessageSerializer()) |
67 | .register(ClusterMembershipEvent.class) | 68 | .register(ClusterMembershipEvent.class) |
68 | .register(byte[].class) | 69 | .register(byte[].class) |
69 | - .register(MessageSubject.class) | 70 | + .register(MessageSubject.class, new MessageSubjectSerializer()) |
70 | .build() | 71 | .build() |
71 | .populate(1); | 72 | .populate(1); |
72 | } | 73 | } | ... | ... |
... | @@ -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.cluster.NodeId; | 3 | import org.onlab.onos.cluster.NodeId; |
4 | import org.onlab.onos.store.cluster.messaging.ClusterMessage; | 4 | import org.onlab.onos.store.cluster.messaging.ClusterMessage; |
5 | import org.onlab.onos.store.cluster.messaging.MessageSubject; | 5 | import org.onlab.onos.store.cluster.messaging.MessageSubject; |
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; |
... | @@ -11,6 +10,9 @@ import com.esotericsoftware.kryo.io.Output; | ... | @@ -11,6 +10,9 @@ import com.esotericsoftware.kryo.io.Output; |
11 | 10 | ||
12 | public final class ClusterMessageSerializer extends Serializer<ClusterMessage> { | 11 | public final class ClusterMessageSerializer extends Serializer<ClusterMessage> { |
13 | 12 | ||
13 | + /** | ||
14 | + * Creates a serializer for {@link ClusterMessage}. | ||
15 | + */ | ||
14 | public ClusterMessageSerializer() { | 16 | public ClusterMessageSerializer() { |
15 | // does not accept null | 17 | // does not accept null |
16 | super(false); | 18 | super(false); | ... | ... |
... | @@ -14,7 +14,7 @@ import com.esotericsoftware.kryo.io.Output; | ... | @@ -14,7 +14,7 @@ import com.esotericsoftware.kryo.io.Output; |
14 | public class MastershipBasedTimestampSerializer extends Serializer<MastershipBasedTimestamp> { | 14 | public class MastershipBasedTimestampSerializer extends Serializer<MastershipBasedTimestamp> { |
15 | 15 | ||
16 | /** | 16 | /** |
17 | - * Default constructor. | 17 | + * Creates a serializer for {@link MastershipBasedTimestamp}. |
18 | */ | 18 | */ |
19 | public MastershipBasedTimestampSerializer() { | 19 | public MastershipBasedTimestampSerializer() { |
20 | // non-null, immutable | 20 | // non-null, immutable | ... | ... |
core/store/dist/src/main/java/org/onlab/onos/store/serializers/MessageSubjectSerializer.java
0 → 100644
1 | +package org.onlab.onos.store.serializers; | ||
2 | + | ||
3 | +import org.onlab.onos.store.cluster.messaging.MessageSubject; | ||
4 | + | ||
5 | +import com.esotericsoftware.kryo.Kryo; | ||
6 | +import com.esotericsoftware.kryo.Serializer; | ||
7 | +import com.esotericsoftware.kryo.io.Input; | ||
8 | +import com.esotericsoftware.kryo.io.Output; | ||
9 | + | ||
10 | +public final class MessageSubjectSerializer extends Serializer<MessageSubject> { | ||
11 | + | ||
12 | + /** | ||
13 | + * Creates a serializer for {@link MessageSubject}. | ||
14 | + */ | ||
15 | + public MessageSubjectSerializer() { | ||
16 | + // non-null, immutable | ||
17 | + super(false, true); | ||
18 | + } | ||
19 | + | ||
20 | + | ||
21 | + @Override | ||
22 | + public void write(Kryo kryo, Output output, MessageSubject object) { | ||
23 | + output.writeString(object.value()); | ||
24 | + } | ||
25 | + | ||
26 | + @Override | ||
27 | + public MessageSubject read(Kryo kryo, Input input, | ||
28 | + Class<MessageSubject> type) { | ||
29 | + return new MessageSubject(input.readString()); | ||
30 | + } | ||
31 | +} |
-
Please register or login to post a comment