blob: f843cc43ac32b1761f9f0028529ae0306157e47c [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
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.serializers;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070017
18import java.net.URI;
Sho SHIMIZU977cb602014-11-13 08:40:50 -080019import java.time.Duration;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070020import java.util.ArrayList;
Madan Jampani53e44e62014-10-07 12:39:51 -070021import java.util.Arrays;
Yuta HIGUCHI91768e32014-11-22 05:06:35 -080022import java.util.Collections;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070023import java.util.HashMap;
alshabib3d643ec2014-10-22 18:33:00 -070024import java.util.HashSet;
Yuta HIGUCHI9def0472014-10-23 15:51:10 -070025import java.util.LinkedList;
Sho SHIMIZU166e61e2015-01-21 18:07:12 -080026import java.util.Optional;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -070027
Brian O'Connorabafb502014-12-02 22:26:20 -080028import org.onosproject.cluster.ControllerNode;
29import org.onosproject.cluster.DefaultControllerNode;
30import org.onosproject.cluster.Leadership;
31import org.onosproject.cluster.LeadershipEvent;
32import org.onosproject.cluster.NodeId;
33import org.onosproject.cluster.RoleInfo;
34import org.onosproject.core.DefaultApplicationId;
35import org.onosproject.core.DefaultGroupId;
36import org.onosproject.mastership.MastershipTerm;
37import org.onosproject.net.ConnectPoint;
38import org.onosproject.net.DefaultAnnotations;
39import org.onosproject.net.DefaultDevice;
40import org.onosproject.net.DefaultEdgeLink;
41import org.onosproject.net.DefaultLink;
42import org.onosproject.net.DefaultPath;
43import org.onosproject.net.DefaultPort;
44import org.onosproject.net.Device;
45import org.onosproject.net.DeviceId;
46import org.onosproject.net.Element;
47import org.onosproject.net.HostId;
48import org.onosproject.net.HostLocation;
49import org.onosproject.net.Link;
50import org.onosproject.net.LinkKey;
51import org.onosproject.net.Port;
52import org.onosproject.net.PortNumber;
53import org.onosproject.net.device.DefaultDeviceDescription;
54import org.onosproject.net.device.DefaultPortDescription;
55import org.onosproject.net.flow.CompletedBatchOperation;
56import org.onosproject.net.flow.DefaultFlowEntry;
57import org.onosproject.net.flow.DefaultFlowRule;
58import org.onosproject.net.flow.DefaultTrafficSelector;
59import org.onosproject.net.flow.DefaultTrafficTreatment;
60import org.onosproject.net.flow.FlowEntry;
61import org.onosproject.net.flow.FlowId;
62import org.onosproject.net.flow.FlowRuleBatchEntry;
63import org.onosproject.net.flow.FlowRuleBatchOperation;
64import org.onosproject.net.flow.StoredFlowEntry;
65import org.onosproject.net.flow.criteria.Criteria;
66import org.onosproject.net.flow.criteria.Criterion;
67import org.onosproject.net.flow.instructions.Instructions;
68import org.onosproject.net.flow.instructions.L0ModificationInstruction;
69import org.onosproject.net.flow.instructions.L2ModificationInstruction;
70import org.onosproject.net.flow.instructions.L3ModificationInstruction;
71import org.onosproject.net.host.DefaultHostDescription;
72import org.onosproject.net.host.HostDescription;
73import org.onosproject.net.intent.ConnectivityIntent;
74import org.onosproject.net.intent.HostToHostIntent;
75import org.onosproject.net.intent.Intent;
76import org.onosproject.net.intent.IntentId;
77import org.onosproject.net.intent.IntentOperation;
78import org.onosproject.net.intent.IntentOperations;
79import org.onosproject.net.intent.IntentState;
80import org.onosproject.net.intent.LinkCollectionIntent;
81import org.onosproject.net.intent.MultiPointToSinglePointIntent;
82import org.onosproject.net.intent.OpticalConnectivityIntent;
83import org.onosproject.net.intent.OpticalPathIntent;
84import org.onosproject.net.intent.PathIntent;
85import org.onosproject.net.intent.PointToPointIntent;
86import org.onosproject.net.intent.constraint.AnnotationConstraint;
87import org.onosproject.net.intent.SinglePointToMultiPointIntent;
88import org.onosproject.net.intent.constraint.BandwidthConstraint;
89import org.onosproject.net.intent.constraint.BooleanConstraint;
90import org.onosproject.net.intent.constraint.LambdaConstraint;
91import org.onosproject.net.intent.constraint.LatencyConstraint;
92import org.onosproject.net.intent.constraint.LinkTypeConstraint;
93import org.onosproject.net.intent.constraint.ObstacleConstraint;
94import org.onosproject.net.intent.constraint.WaypointConstraint;
95import org.onosproject.net.link.DefaultLinkDescription;
96import org.onosproject.net.packet.DefaultOutboundPacket;
97import org.onosproject.net.provider.ProviderId;
98import org.onosproject.net.resource.Bandwidth;
99import org.onosproject.net.resource.BandwidthResourceAllocation;
100import org.onosproject.net.resource.BandwidthResourceRequest;
101import org.onosproject.net.resource.DefaultLinkResourceAllocations;
102import org.onosproject.net.resource.DefaultLinkResourceRequest;
103import org.onosproject.net.resource.Lambda;
104import org.onosproject.net.resource.LambdaResourceAllocation;
105import org.onosproject.net.resource.LambdaResourceRequest;
106import org.onosproject.net.resource.LinkResourceRequest;
107import org.onosproject.store.Timestamp;
108import org.onosproject.store.service.BatchReadRequest;
109import org.onosproject.store.service.BatchWriteRequest;
110import org.onosproject.store.service.ReadRequest;
111import org.onosproject.store.service.ReadResult;
112import org.onosproject.store.service.ReadStatus;
113import org.onosproject.store.service.VersionedValue;
114import org.onosproject.store.service.WriteRequest;
115import org.onosproject.store.service.WriteResult;
116import org.onosproject.store.service.WriteStatus;
alshabib7911a052014-10-16 17:49:37 -0700117import org.onlab.packet.ChassisId;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700118import org.onlab.packet.IpAddress;
Pavlin Radoslavov17378ef2014-11-05 16:13:47 -0800119import org.onlab.packet.Ip4Address;
120import org.onlab.packet.Ip6Address;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700121import org.onlab.packet.IpPrefix;
Pavlin Radoslavov17378ef2014-11-05 16:13:47 -0800122import org.onlab.packet.Ip4Prefix;
123import org.onlab.packet.Ip6Prefix;
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700124import org.onlab.packet.MacAddress;
125import org.onlab.packet.VlanId;
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700126import org.onlab.util.KryoNamespace;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700127
Yuta HIGUCHI47c40882014-10-10 18:44:37 -0700128import com.google.common.collect.ImmutableList;
129import com.google.common.collect.ImmutableMap;
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700130import com.google.common.collect.ImmutableSet;
Yuta HIGUCHI47c40882014-10-10 18:44:37 -0700131
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700132public final class KryoNamespaces {
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700133
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800134 public static final KryoNamespace BASIC = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800135 .nextId(KryoNamespace.FLOATING_ID)
136 .register(byte[].class)
137 .register(new ImmutableListSerializer(),
138 ImmutableList.class,
139 ImmutableList.of(1).getClass(),
140 ImmutableList.of(1, 2).getClass())
141 .register(new ImmutableSetSerializer(),
142 ImmutableSet.class,
143 ImmutableSet.of().getClass(),
144 ImmutableSet.of(1).getClass(),
145 ImmutableSet.of(1, 2).getClass())
146 .register(new ImmutableMapSerializer(),
147 ImmutableMap.class,
148 ImmutableMap.of().getClass(),
149 ImmutableMap.of("a", 1).getClass(),
150 ImmutableMap.of("R", 2, "D", 2).getClass())
151 .register(HashMap.class)
152 .register(ArrayList.class,
153 LinkedList.class,
154 HashSet.class
155 )
156 .register(new ArraysAsListSerializer(), Arrays.asList().getClass())
157 .register(Collections.singletonList(1).getClass())
158 .register(Duration.class)
Yuta HIGUCHIae1d2102014-11-25 19:26:01 -0800159 .register(Collections.emptySet().getClass())
Sho SHIMIZU166e61e2015-01-21 18:07:12 -0800160 .register(Optional.class)
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800161 .build();
162
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700163 /**
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700164 * KryoNamespace which can serialize ON.lab misc classes.
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700165 */
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700166 public static final KryoNamespace MISC = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800167 .nextId(KryoNamespace.FLOATING_ID)
168 .register(new IpPrefixSerializer(), IpPrefix.class)
169 .register(new Ip4PrefixSerializer(), Ip4Prefix.class)
170 .register(new Ip6PrefixSerializer(), Ip6Prefix.class)
171 .register(new IpAddressSerializer(), IpAddress.class)
172 .register(new Ip4AddressSerializer(), Ip4Address.class)
173 .register(new Ip6AddressSerializer(), Ip6Address.class)
174 .register(new MacAddressSerializer(), MacAddress.class)
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700175 .register(VlanId.class)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700176 .build();
177
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800178 /**
179 * Kryo registration Id for user custom registration.
180 */
181 public static final int BEGIN_USER_CUSTOM_ID = 300;
182
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700183 // TODO: Populate other classes
184 /**
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700185 * KryoNamespace which can serialize API bundle classes.
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700186 */
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700187 public static final KryoNamespace API = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800188 .nextId(KryoNamespace.INITIAL_ID)
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800189 .register(BASIC)
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800190 .nextId(KryoNamespace.INITIAL_ID + 30)
191 .register(MISC)
192 .nextId(KryoNamespace.INITIAL_ID + 30 + 10)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700193 .register(
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700194 ControllerNode.State.class,
195 Device.Type.class,
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700196 Port.Type.class,
alshabib7911a052014-10-16 17:49:37 -0700197 ChassisId.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700198 DefaultAnnotations.class,
199 DefaultControllerNode.class,
200 DefaultDevice.class,
Madan Jampani53e44e62014-10-07 12:39:51 -0700201 DefaultDeviceDescription.class,
Madan Jampani2ff05592014-10-10 15:42:47 -0700202 DefaultLinkDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700203 Port.class,
Madan Jampani53e44e62014-10-07 12:39:51 -0700204 DefaultPortDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700205 Element.class,
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -0700206 Link.Type.class,
Thomas Vachuska57126fe2014-11-11 17:13:24 -0800207 Link.State.class,
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700208 Timestamp.class,
Madan Jampani1ee91782014-11-20 20:24:24 -0800209 Leadership.class,
210 LeadershipEvent.class,
211 LeadershipEvent.Type.class,
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700212 HostId.class,
213 HostDescription.class,
Madan Jampani38b250d2014-10-17 11:02:38 -0700214 DefaultHostDescription.class,
Madan Jampani117aaae2014-10-23 10:04:05 -0700215 DefaultFlowEntry.class,
216 StoredFlowEntry.class,
Yuta HIGUCHI2fcfde92014-10-20 18:37:14 -0700217 DefaultFlowRule.class,
alshabib3d643ec2014-10-22 18:33:00 -0700218 DefaultFlowEntry.class,
alshabibf6c2ede2014-10-22 23:31:50 -0700219 FlowEntry.FlowEntryState.class,
Yuta HIGUCHI2809bf32014-10-20 22:44:12 -0700220 FlowId.class,
Yuta HIGUCHI85d58d12014-10-20 23:59:44 -0700221 DefaultTrafficSelector.class,
222 Criteria.PortCriterion.class,
223 Criteria.EthCriterion.class,
224 Criteria.EthTypeCriterion.class,
225 Criteria.IPCriterion.class,
226 Criteria.IPProtocolCriterion.class,
227 Criteria.VlanIdCriterion.class,
228 Criteria.VlanPcpCriterion.class,
229 Criteria.TcpPortCriterion.class,
Praseed Balakrishnandb8a9d22014-12-03 11:47:55 -0800230 Criteria.OpticalSignalTypeCriterion.class,
231 Criteria.LambdaCriterion.class,
232 Criteria.MplsCriterion.class,
Yuta HIGUCHI85d58d12014-10-20 23:59:44 -0700233 Criterion.class,
234 Criterion.Type.class,
235 DefaultTrafficTreatment.class,
236 Instructions.DropInstruction.class,
Yuta HIGUCHI40d01772014-10-21 00:08:44 -0700237 Instructions.OutputInstruction.class,
Jonathan Hart68fef9d2014-10-29 17:30:03 -0700238 L0ModificationInstruction.class,
239 L0ModificationInstruction.L0SubType.class,
240 L0ModificationInstruction.ModLambdaInstruction.class,
241 L2ModificationInstruction.class,
242 L2ModificationInstruction.L2SubType.class,
243 L2ModificationInstruction.ModEtherInstruction.class,
244 L2ModificationInstruction.ModVlanIdInstruction.class,
245 L2ModificationInstruction.ModVlanPcpInstruction.class,
246 L3ModificationInstruction.class,
247 L3ModificationInstruction.L3SubType.class,
248 L3ModificationInstruction.ModIPInstruction.class,
Yuta HIGUCHI9def0472014-10-23 15:51:10 -0700249 RoleInfo.class,
250 FlowRuleBatchOperation.class,
251 CompletedBatchOperation.class,
252 FlowRuleBatchEntry.class,
Yuta HIGUCHI087019b2014-10-28 21:07:56 -0700253 FlowRuleBatchEntry.FlowRuleOperation.class,
254 IntentId.class,
255 IntentState.class,
256 Intent.class,
257 ConnectivityIntent.class,
258 PathIntent.class,
259 DefaultPath.class,
260 DefaultEdgeLink.class,
261 HostToHostIntent.class,
262 PointToPointIntent.class,
Jonathan Hart68fef9d2014-10-29 17:30:03 -0700263 MultiPointToSinglePointIntent.class,
Michele Santuari4a338072014-11-05 18:38:55 +0100264 SinglePointToMultiPointIntent.class,
Brian O'Connor41718fc2014-10-30 16:57:21 -0700265 LinkCollectionIntent.class,
266 OpticalConnectivityIntent.class,
267 OpticalPathIntent.class,
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800268 LinkResourceRequest.class,
Yuta HIGUCHIadac04a2014-11-13 00:02:45 -0800269 DefaultLinkResourceRequest.class,
270 BandwidthResourceRequest.class,
271 LambdaResourceRequest.class,
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800272 Lambda.class,
273 Bandwidth.class,
Yuta HIGUCHIadac04a2014-11-13 00:02:45 -0800274 DefaultLinkResourceAllocations.class,
275 BandwidthResourceAllocation.class,
276 LambdaResourceAllocation.class,
Sho SHIMIZUcd4bac82014-11-11 17:07:25 -0800277 // Constraints
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800278 LambdaConstraint.class,
279 BandwidthConstraint.class,
280 LinkTypeConstraint.class,
Sho SHIMIZUcd4bac82014-11-11 17:07:25 -0800281 LatencyConstraint.class,
282 WaypointConstraint.class,
283 ObstacleConstraint.class,
284 AnnotationConstraint.class,
Brian O'Connor72a034c2014-11-26 18:24:23 -0800285 BooleanConstraint.class,
286 IntentOperation.class,
287 IntentOperations.class
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700288 )
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800289 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
290 .register(new URISerializer(), URI.class)
291 .register(new NodeIdSerializer(), NodeId.class)
292 .register(new ProviderIdSerializer(), ProviderId.class)
293 .register(new DeviceIdSerializer(), DeviceId.class)
294 .register(new PortNumberSerializer(), PortNumber.class)
295 .register(new DefaultPortSerializer(), DefaultPort.class)
296 .register(new LinkKeySerializer(), LinkKey.class)
297 .register(new ConnectPointSerializer(), ConnectPoint.class)
298 .register(new DefaultLinkSerializer(), DefaultLink.class)
299 .register(new MastershipTermSerializer(), MastershipTerm.class)
300 .register(new HostLocationSerializer(), HostLocation.class)
301 .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class)
302 .register(ReadRequest.class)
303 .register(WriteRequest.class)
304 .register(WriteRequest.Type.class)
305 .register(WriteResult.class)
306 .register(ReadResult.class)
307 .register(BatchReadRequest.class)
308 .register(BatchWriteRequest.class)
309 .register(ReadStatus.class)
310 .register(WriteStatus.class)
311 .register(VersionedValue.class)
Yuta HIGUCHIf6171232014-11-25 15:14:44 -0800312 .register(DefaultGroupId.class)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700313
314 .build();
315
316
317 // not to be instantiated
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700318 private KryoNamespaces() {}
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700319}