Yuta HIGUCHI | 5027b6b | 2014-11-05 16:23:26 -0800 | [diff] [blame] | 1 | package org.onlab.onos.store.service.impl; |
| 2 | |
| 3 | import java.util.Collection; |
| 4 | |
| 5 | import net.kuujo.copycat.cluster.TcpClusterConfig; |
| 6 | import net.kuujo.copycat.cluster.TcpMember; |
| 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 | public class TcpClusterConfigSerializer extends Serializer<TcpClusterConfig> { |
| 14 | |
| 15 | @Override |
| 16 | public void write(Kryo kryo, Output output, TcpClusterConfig object) { |
| 17 | kryo.writeClassAndObject(output, object.getLocalMember()); |
| 18 | kryo.writeClassAndObject(output, object.getRemoteMembers()); |
| 19 | } |
| 20 | |
| 21 | @Override |
| 22 | public TcpClusterConfig read(Kryo kryo, Input input, |
| 23 | Class<TcpClusterConfig> type) { |
| 24 | TcpMember localMember = (TcpMember) kryo.readClassAndObject(input); |
| 25 | @SuppressWarnings("unchecked") |
| 26 | Collection<TcpMember> remoteMembers = (Collection<TcpMember>) kryo.readClassAndObject(input); |
| 27 | return new TcpClusterConfig(localMember, remoteMembers); |
| 28 | } |
| 29 | |
| 30 | } |