blob: b229063ac0611eadfa9fd207bf1d517557677326 [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;
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070020import org.onlab.onos.net.HostId;
21import org.onlab.onos.net.HostLocation;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070022import org.onlab.onos.net.Link;
23import org.onlab.onos.net.LinkKey;
Yuta HIGUCHId40483d2014-10-09 15:20:30 -070024import org.onlab.onos.net.MastershipRole;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070025import org.onlab.onos.net.Port;
26import org.onlab.onos.net.PortNumber;
Madan Jampani53e44e62014-10-07 12:39:51 -070027import org.onlab.onos.net.device.DefaultDeviceDescription;
28import org.onlab.onos.net.device.DefaultPortDescription;
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070029import org.onlab.onos.net.host.DefaultHostDescription;
30import org.onlab.onos.net.host.HostDescription;
Madan Jampani2ff05592014-10-10 15:42:47 -070031import org.onlab.onos.net.link.DefaultLinkDescription;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070032import org.onlab.onos.net.provider.ProviderId;
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070033import org.onlab.onos.store.Timestamp;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070034import org.onlab.packet.IpAddress;
35import org.onlab.packet.IpPrefix;
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070036import org.onlab.packet.MacAddress;
37import org.onlab.packet.VlanId;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070038import org.onlab.util.KryoPool;
39
Yuta HIGUCHI47c40882014-10-10 18:44:37 -070040import com.google.common.collect.ImmutableList;
41import com.google.common.collect.ImmutableMap;
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070042import com.google.common.collect.ImmutableSet;
Yuta HIGUCHI47c40882014-10-10 18:44:37 -070043
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070044public final class KryoPoolUtil {
45
46 /**
47 * KryoPool which can serialize ON.lab misc classes.
48 */
49 public static final KryoPool MISC = KryoPool.newBuilder()
50 .register(IpPrefix.class, new IpPrefixSerializer())
51 .register(IpAddress.class, new IpAddressSerializer())
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070052 .register(MacAddress.class, new MacAddressSerializer())
53 .register(VlanId.class)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070054 .build();
55
56 // TODO: Populate other classes
57 /**
58 * KryoPool which can serialize API bundle classes.
59 */
60 public static final KryoPool API = KryoPool.newBuilder()
61 .register(MISC)
Yuta HIGUCHI47c40882014-10-10 18:44:37 -070062 .register(ImmutableMap.class, new ImmutableMapSerializer())
63 .register(ImmutableList.class, new ImmutableListSerializer())
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070064 .register(ImmutableSet.class, new ImmutableSetSerializer())
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070065 .register(
66 //
67 ArrayList.class,
Madan Jampani53e44e62014-10-07 12:39:51 -070068 Arrays.asList().getClass(),
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070069 HashMap.class,
70 //
Yuta HIGUCHI47c40882014-10-10 18:44:37 -070071 //
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070072 ControllerNode.State.class,
73 Device.Type.class,
74 DefaultAnnotations.class,
75 DefaultControllerNode.class,
76 DefaultDevice.class,
Madan Jampani53e44e62014-10-07 12:39:51 -070077 DefaultDeviceDescription.class,
Madan Jampani2ff05592014-10-10 15:42:47 -070078 DefaultLinkDescription.class,
Yuta HIGUCHId40483d2014-10-09 15:20:30 -070079 MastershipRole.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070080 Port.class,
Madan Jampani53e44e62014-10-07 12:39:51 -070081 DefaultPortDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070082 Element.class,
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070083 Link.Type.class,
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -070084 Timestamp.class,
85 HostId.class,
86 HostDescription.class,
87 DefaultHostDescription.class
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070088 )
89 .register(URI.class, new URISerializer())
90 .register(NodeId.class, new NodeIdSerializer())
91 .register(ProviderId.class, new ProviderIdSerializer())
92 .register(DeviceId.class, new DeviceIdSerializer())
93 .register(PortNumber.class, new PortNumberSerializer())
94 .register(DefaultPort.class, new DefaultPortSerializer())
95 .register(LinkKey.class, new LinkKeySerializer())
96 .register(ConnectPoint.class, new ConnectPointSerializer())
97 .register(DefaultLink.class, new DefaultLinkSerializer())
Yuta HIGUCHIfa891c92014-10-09 15:21:40 -070098 .register(MastershipTerm.class, new MastershipTermSerializer())
Yuta HIGUCHId40483d2014-10-09 15:20:30 -070099 .register(MastershipRole.class, new MastershipRoleSerializer())
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700100 .register(HostLocation.class, new HostLocationSerializer())
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700101
102 .build();
103
104
105 // not to be instantiated
106 private KryoPoolUtil() {}
107}