blob: 1d9d8dcf826134f1c2fc532b5f2b910b416a25d9 [file] [log] [blame]
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -07001package org.onlab.onos.store.serializers;
2
3import java.net.URI;
4import java.util.ArrayList;
Madan Jampani53e44e62014-10-07 12:39:51 -07005import java.util.Arrays;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -07006import java.util.HashMap;
7
8import org.onlab.onos.cluster.ControllerNode;
9import org.onlab.onos.cluster.DefaultControllerNode;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070010import org.onlab.onos.cluster.NodeId;
Yuta HIGUCHI80912e62014-10-12 00:15:47 -070011import org.onlab.onos.mastership.MastershipTerm;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070012import org.onlab.onos.net.ConnectPoint;
13import org.onlab.onos.net.DefaultAnnotations;
14import org.onlab.onos.net.DefaultDevice;
15import org.onlab.onos.net.DefaultLink;
16import org.onlab.onos.net.DefaultPort;
17import org.onlab.onos.net.Device;
18import org.onlab.onos.net.DeviceId;
19import org.onlab.onos.net.Element;
20import org.onlab.onos.net.Link;
21import org.onlab.onos.net.LinkKey;
Yuta HIGUCHId40483d2014-10-09 15:20:30 -070022import org.onlab.onos.net.MastershipRole;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070023import org.onlab.onos.net.Port;
24import org.onlab.onos.net.PortNumber;
Madan Jampani53e44e62014-10-07 12:39:51 -070025import org.onlab.onos.net.device.DefaultDeviceDescription;
26import org.onlab.onos.net.device.DefaultPortDescription;
Madan Jampani2ff05592014-10-10 15:42:47 -070027import org.onlab.onos.net.link.DefaultLinkDescription;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070028import org.onlab.onos.net.provider.ProviderId;
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070029import org.onlab.onos.store.Timestamp;
alshabib7911a052014-10-16 17:49:37 -070030import org.onlab.packet.ChassisId;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070031import org.onlab.packet.IpAddress;
32import org.onlab.packet.IpPrefix;
33import org.onlab.util.KryoPool;
34
Yuta HIGUCHI47c40882014-10-10 18:44:37 -070035import com.google.common.collect.ImmutableList;
36import com.google.common.collect.ImmutableMap;
37
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070038public final class KryoPoolUtil {
39
40 /**
41 * KryoPool which can serialize ON.lab misc classes.
42 */
43 public static final KryoPool MISC = KryoPool.newBuilder()
44 .register(IpPrefix.class, new IpPrefixSerializer())
45 .register(IpAddress.class, new IpAddressSerializer())
46 .build();
47
48 // TODO: Populate other classes
49 /**
50 * KryoPool which can serialize API bundle classes.
51 */
52 public static final KryoPool API = KryoPool.newBuilder()
53 .register(MISC)
Yuta HIGUCHI47c40882014-10-10 18:44:37 -070054 .register(ImmutableMap.class, new ImmutableMapSerializer())
55 .register(ImmutableList.class, new ImmutableListSerializer())
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070056 .register(
57 //
58 ArrayList.class,
Madan Jampani53e44e62014-10-07 12:39:51 -070059 Arrays.asList().getClass(),
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070060 HashMap.class,
61 //
Yuta HIGUCHI47c40882014-10-10 18:44:37 -070062 //
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070063 ControllerNode.State.class,
64 Device.Type.class,
alshabib7911a052014-10-16 17:49:37 -070065 ChassisId.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070066 DefaultAnnotations.class,
67 DefaultControllerNode.class,
68 DefaultDevice.class,
Madan Jampani53e44e62014-10-07 12:39:51 -070069 DefaultDeviceDescription.class,
Madan Jampani2ff05592014-10-10 15:42:47 -070070 DefaultLinkDescription.class,
Yuta HIGUCHId40483d2014-10-09 15:20:30 -070071 MastershipRole.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070072 Port.class,
Madan Jampani53e44e62014-10-07 12:39:51 -070073 DefaultPortDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070074 Element.class,
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070075 Link.Type.class,
76 Timestamp.class
77
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070078 )
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())
Yuta HIGUCHIfa891c92014-10-09 15:21:40 -070088 .register(MastershipTerm.class, new MastershipTermSerializer())
Yuta HIGUCHId40483d2014-10-09 15:20:30 -070089 .register(MastershipRole.class, new MastershipRoleSerializer())
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070090
91 .build();
92
93
94 // not to be instantiated
95 private KryoPoolUtil() {}
96}