blob: 56961cf6bdc5e5c9bea66a7da5c900cc8d91eb69 [file] [log] [blame]
alshabibab984662014-12-04 18:56:18 -08001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.store.service.impl;
Yuta HIGUCHI5027b6b2014-11-05 16:23:26 -080017
18import java.util.Collection;
19
20import net.kuujo.copycat.cluster.TcpClusterConfig;
21import net.kuujo.copycat.cluster.TcpMember;
22
23import com.esotericsoftware.kryo.Kryo;
24import com.esotericsoftware.kryo.Serializer;
25import com.esotericsoftware.kryo.io.Input;
26import com.esotericsoftware.kryo.io.Output;
27
28public class TcpClusterConfigSerializer extends Serializer<TcpClusterConfig> {
29
30 @Override
31 public void write(Kryo kryo, Output output, TcpClusterConfig object) {
32 kryo.writeClassAndObject(output, object.getLocalMember());
33 kryo.writeClassAndObject(output, object.getRemoteMembers());
34 }
35
36 @Override
37 public TcpClusterConfig read(Kryo kryo, Input input,
38 Class<TcpClusterConfig> type) {
39 TcpMember localMember = (TcpMember) kryo.readClassAndObject(input);
40 @SuppressWarnings("unchecked")
41 Collection<TcpMember> remoteMembers = (Collection<TcpMember>) kryo.readClassAndObject(input);
42 return new TcpClusterConfig(localMember, remoteMembers);
43 }
44
45}