blob: 289efe37d400bfa691fb6f905e834a285a288d2f [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
Jonathan Hart45727852015-01-28 13:35:54 -080018import com.google.common.collect.ImmutableList;
19import com.google.common.collect.ImmutableMap;
20import com.google.common.collect.ImmutableSet;
21import org.onlab.packet.ChassisId;
22import org.onlab.packet.Ip4Address;
23import org.onlab.packet.Ip4Prefix;
24import org.onlab.packet.Ip6Address;
25import org.onlab.packet.Ip6Prefix;
26import org.onlab.packet.IpAddress;
27import org.onlab.packet.IpPrefix;
28import org.onlab.packet.MacAddress;
29import org.onlab.packet.VlanId;
30import org.onlab.util.KryoNamespace;
Thomas Vachuska90b453f2015-01-30 18:57:14 -080031import org.onosproject.app.ApplicationState;
Brian O'Connorabafb502014-12-02 22:26:20 -080032import org.onosproject.cluster.ControllerNode;
33import org.onosproject.cluster.DefaultControllerNode;
34import org.onosproject.cluster.Leadership;
35import org.onosproject.cluster.LeadershipEvent;
36import org.onosproject.cluster.NodeId;
37import org.onosproject.cluster.RoleInfo;
Thomas Vachuska90b453f2015-01-30 18:57:14 -080038import org.onosproject.core.DefaultApplication;
Brian O'Connorabafb502014-12-02 22:26:20 -080039import org.onosproject.core.DefaultApplicationId;
40import org.onosproject.core.DefaultGroupId;
Thomas Vachuska90b453f2015-01-30 18:57:14 -080041import org.onosproject.core.Version;
Brian O'Connorabafb502014-12-02 22:26:20 -080042import org.onosproject.mastership.MastershipTerm;
43import org.onosproject.net.ConnectPoint;
44import org.onosproject.net.DefaultAnnotations;
45import org.onosproject.net.DefaultDevice;
46import org.onosproject.net.DefaultEdgeLink;
47import org.onosproject.net.DefaultLink;
48import org.onosproject.net.DefaultPath;
49import org.onosproject.net.DefaultPort;
50import org.onosproject.net.Device;
51import org.onosproject.net.DeviceId;
52import org.onosproject.net.Element;
53import org.onosproject.net.HostId;
54import org.onosproject.net.HostLocation;
55import org.onosproject.net.Link;
56import org.onosproject.net.LinkKey;
57import org.onosproject.net.Port;
58import org.onosproject.net.PortNumber;
59import org.onosproject.net.device.DefaultDeviceDescription;
60import org.onosproject.net.device.DefaultPortDescription;
61import org.onosproject.net.flow.CompletedBatchOperation;
sangho11c30ac2015-01-22 14:30:55 -080062import org.onosproject.net.flow.FlowRule;
Brian O'Connorabafb502014-12-02 22:26:20 -080063import org.onosproject.net.flow.DefaultFlowEntry;
64import org.onosproject.net.flow.DefaultFlowRule;
65import org.onosproject.net.flow.DefaultTrafficSelector;
66import org.onosproject.net.flow.DefaultTrafficTreatment;
67import org.onosproject.net.flow.FlowEntry;
68import org.onosproject.net.flow.FlowId;
69import org.onosproject.net.flow.FlowRuleBatchEntry;
70import org.onosproject.net.flow.FlowRuleBatchOperation;
71import org.onosproject.net.flow.StoredFlowEntry;
72import org.onosproject.net.flow.criteria.Criteria;
73import org.onosproject.net.flow.criteria.Criterion;
74import org.onosproject.net.flow.instructions.Instructions;
75import org.onosproject.net.flow.instructions.L0ModificationInstruction;
76import org.onosproject.net.flow.instructions.L2ModificationInstruction;
77import org.onosproject.net.flow.instructions.L3ModificationInstruction;
78import org.onosproject.net.host.DefaultHostDescription;
79import org.onosproject.net.host.HostDescription;
80import org.onosproject.net.intent.ConnectivityIntent;
81import org.onosproject.net.intent.HostToHostIntent;
82import org.onosproject.net.intent.Intent;
83import org.onosproject.net.intent.IntentId;
84import org.onosproject.net.intent.IntentOperation;
85import org.onosproject.net.intent.IntentOperations;
86import org.onosproject.net.intent.IntentState;
87import org.onosproject.net.intent.LinkCollectionIntent;
88import org.onosproject.net.intent.MultiPointToSinglePointIntent;
89import org.onosproject.net.intent.OpticalConnectivityIntent;
90import org.onosproject.net.intent.OpticalPathIntent;
91import org.onosproject.net.intent.PathIntent;
92import org.onosproject.net.intent.PointToPointIntent;
Brian O'Connorabafb502014-12-02 22:26:20 -080093import org.onosproject.net.intent.SinglePointToMultiPointIntent;
Jonathan Hart45727852015-01-28 13:35:54 -080094import org.onosproject.net.intent.constraint.AnnotationConstraint;
Brian O'Connorabafb502014-12-02 22:26:20 -080095import org.onosproject.net.intent.constraint.BandwidthConstraint;
96import org.onosproject.net.intent.constraint.BooleanConstraint;
97import org.onosproject.net.intent.constraint.LambdaConstraint;
98import org.onosproject.net.intent.constraint.LatencyConstraint;
99import org.onosproject.net.intent.constraint.LinkTypeConstraint;
100import org.onosproject.net.intent.constraint.ObstacleConstraint;
101import org.onosproject.net.intent.constraint.WaypointConstraint;
102import org.onosproject.net.link.DefaultLinkDescription;
103import org.onosproject.net.packet.DefaultOutboundPacket;
104import org.onosproject.net.provider.ProviderId;
105import org.onosproject.net.resource.Bandwidth;
106import org.onosproject.net.resource.BandwidthResourceAllocation;
107import org.onosproject.net.resource.BandwidthResourceRequest;
108import org.onosproject.net.resource.DefaultLinkResourceAllocations;
109import org.onosproject.net.resource.DefaultLinkResourceRequest;
110import org.onosproject.net.resource.Lambda;
111import org.onosproject.net.resource.LambdaResourceAllocation;
112import org.onosproject.net.resource.LambdaResourceRequest;
113import org.onosproject.net.resource.LinkResourceRequest;
114import org.onosproject.store.Timestamp;
115import org.onosproject.store.service.BatchReadRequest;
116import org.onosproject.store.service.BatchWriteRequest;
117import org.onosproject.store.service.ReadRequest;
118import org.onosproject.store.service.ReadResult;
119import org.onosproject.store.service.ReadStatus;
120import org.onosproject.store.service.VersionedValue;
121import org.onosproject.store.service.WriteRequest;
122import org.onosproject.store.service.WriteResult;
123import org.onosproject.store.service.WriteStatus;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700124
Jonathan Hart45727852015-01-28 13:35:54 -0800125import java.net.URI;
126import java.time.Duration;
127import java.util.ArrayList;
128import java.util.Arrays;
129import java.util.Collections;
130import java.util.HashMap;
131import java.util.HashSet;
132import java.util.LinkedList;
133import java.util.Optional;
Yuta HIGUCHI47c40882014-10-10 18:44:37 -0700134
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700135public final class KryoNamespaces {
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700136
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800137 public static final KryoNamespace BASIC = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800138 .nextId(KryoNamespace.FLOATING_ID)
139 .register(byte[].class)
140 .register(new ImmutableListSerializer(),
141 ImmutableList.class,
142 ImmutableList.of(1).getClass(),
143 ImmutableList.of(1, 2).getClass())
144 .register(new ImmutableSetSerializer(),
145 ImmutableSet.class,
146 ImmutableSet.of().getClass(),
147 ImmutableSet.of(1).getClass(),
148 ImmutableSet.of(1, 2).getClass())
149 .register(new ImmutableMapSerializer(),
150 ImmutableMap.class,
151 ImmutableMap.of().getClass(),
152 ImmutableMap.of("a", 1).getClass(),
153 ImmutableMap.of("R", 2, "D", 2).getClass())
154 .register(HashMap.class)
155 .register(ArrayList.class,
156 LinkedList.class,
157 HashSet.class
158 )
159 .register(new ArraysAsListSerializer(), Arrays.asList().getClass())
160 .register(Collections.singletonList(1).getClass())
161 .register(Duration.class)
Yuta HIGUCHIae1d2102014-11-25 19:26:01 -0800162 .register(Collections.emptySet().getClass())
Sho SHIMIZU166e61e2015-01-21 18:07:12 -0800163 .register(Optional.class)
Jonathan Hart45727852015-01-28 13:35:54 -0800164 .register(Collections.emptyList().getClass())
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800165 .build();
166
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700167 /**
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700168 * KryoNamespace which can serialize ON.lab misc classes.
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700169 */
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700170 public static final KryoNamespace MISC = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800171 .nextId(KryoNamespace.FLOATING_ID)
172 .register(new IpPrefixSerializer(), IpPrefix.class)
173 .register(new Ip4PrefixSerializer(), Ip4Prefix.class)
174 .register(new Ip6PrefixSerializer(), Ip6Prefix.class)
175 .register(new IpAddressSerializer(), IpAddress.class)
176 .register(new Ip4AddressSerializer(), Ip4Address.class)
177 .register(new Ip6AddressSerializer(), Ip6Address.class)
178 .register(new MacAddressSerializer(), MacAddress.class)
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700179 .register(VlanId.class)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700180 .build();
181
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800182 /**
183 * Kryo registration Id for user custom registration.
184 */
185 public static final int BEGIN_USER_CUSTOM_ID = 300;
186
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700187 // TODO: Populate other classes
188 /**
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700189 * KryoNamespace which can serialize API bundle classes.
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700190 */
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700191 public static final KryoNamespace API = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800192 .nextId(KryoNamespace.INITIAL_ID)
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800193 .register(BASIC)
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800194 .nextId(KryoNamespace.INITIAL_ID + 30)
195 .register(MISC)
196 .nextId(KryoNamespace.INITIAL_ID + 30 + 10)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700197 .register(
Thomas Vachuska90b453f2015-01-30 18:57:14 -0800198 Version.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700199 ControllerNode.State.class,
Thomas Vachuska90b453f2015-01-30 18:57:14 -0800200 ApplicationState.class,
201 DefaultApplication.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700202 Device.Type.class,
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700203 Port.Type.class,
alshabib7911a052014-10-16 17:49:37 -0700204 ChassisId.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700205 DefaultAnnotations.class,
206 DefaultControllerNode.class,
207 DefaultDevice.class,
Madan Jampani53e44e62014-10-07 12:39:51 -0700208 DefaultDeviceDescription.class,
Madan Jampani2ff05592014-10-10 15:42:47 -0700209 DefaultLinkDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700210 Port.class,
Madan Jampani53e44e62014-10-07 12:39:51 -0700211 DefaultPortDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700212 Element.class,
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -0700213 Link.Type.class,
Thomas Vachuska57126fe2014-11-11 17:13:24 -0800214 Link.State.class,
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700215 Timestamp.class,
Madan Jampani1ee91782014-11-20 20:24:24 -0800216 Leadership.class,
217 LeadershipEvent.class,
218 LeadershipEvent.Type.class,
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700219 HostId.class,
220 HostDescription.class,
Madan Jampani38b250d2014-10-17 11:02:38 -0700221 DefaultHostDescription.class,
Madan Jampani117aaae2014-10-23 10:04:05 -0700222 DefaultFlowEntry.class,
223 StoredFlowEntry.class,
sangho11c30ac2015-01-22 14:30:55 -0800224 FlowRule.Type.class,
Yuta HIGUCHI2fcfde92014-10-20 18:37:14 -0700225 DefaultFlowRule.class,
alshabib3d643ec2014-10-22 18:33:00 -0700226 DefaultFlowEntry.class,
alshabibf6c2ede2014-10-22 23:31:50 -0700227 FlowEntry.FlowEntryState.class,
Yuta HIGUCHI2809bf32014-10-20 22:44:12 -0700228 FlowId.class,
Yuta HIGUCHI85d58d12014-10-20 23:59:44 -0700229 DefaultTrafficSelector.class,
230 Criteria.PortCriterion.class,
231 Criteria.EthCriterion.class,
232 Criteria.EthTypeCriterion.class,
233 Criteria.IPCriterion.class,
234 Criteria.IPProtocolCriterion.class,
235 Criteria.VlanIdCriterion.class,
236 Criteria.VlanPcpCriterion.class,
237 Criteria.TcpPortCriterion.class,
Praseed Balakrishnandb8a9d22014-12-03 11:47:55 -0800238 Criteria.OpticalSignalTypeCriterion.class,
239 Criteria.LambdaCriterion.class,
240 Criteria.MplsCriterion.class,
Yuta HIGUCHI85d58d12014-10-20 23:59:44 -0700241 Criterion.class,
242 Criterion.Type.class,
243 DefaultTrafficTreatment.class,
244 Instructions.DropInstruction.class,
Yuta HIGUCHI40d01772014-10-21 00:08:44 -0700245 Instructions.OutputInstruction.class,
Jonathan Hart68fef9d2014-10-29 17:30:03 -0700246 L0ModificationInstruction.class,
247 L0ModificationInstruction.L0SubType.class,
248 L0ModificationInstruction.ModLambdaInstruction.class,
249 L2ModificationInstruction.class,
250 L2ModificationInstruction.L2SubType.class,
251 L2ModificationInstruction.ModEtherInstruction.class,
252 L2ModificationInstruction.ModVlanIdInstruction.class,
253 L2ModificationInstruction.ModVlanPcpInstruction.class,
254 L3ModificationInstruction.class,
255 L3ModificationInstruction.L3SubType.class,
256 L3ModificationInstruction.ModIPInstruction.class,
Yuta HIGUCHI9def0472014-10-23 15:51:10 -0700257 RoleInfo.class,
258 FlowRuleBatchOperation.class,
259 CompletedBatchOperation.class,
260 FlowRuleBatchEntry.class,
Yuta HIGUCHI087019b2014-10-28 21:07:56 -0700261 FlowRuleBatchEntry.FlowRuleOperation.class,
262 IntentId.class,
263 IntentState.class,
264 Intent.class,
265 ConnectivityIntent.class,
266 PathIntent.class,
267 DefaultPath.class,
268 DefaultEdgeLink.class,
269 HostToHostIntent.class,
270 PointToPointIntent.class,
Jonathan Hart68fef9d2014-10-29 17:30:03 -0700271 MultiPointToSinglePointIntent.class,
Michele Santuari4a338072014-11-05 18:38:55 +0100272 SinglePointToMultiPointIntent.class,
Brian O'Connor41718fc2014-10-30 16:57:21 -0700273 LinkCollectionIntent.class,
274 OpticalConnectivityIntent.class,
275 OpticalPathIntent.class,
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800276 LinkResourceRequest.class,
Yuta HIGUCHIadac04a2014-11-13 00:02:45 -0800277 DefaultLinkResourceRequest.class,
278 BandwidthResourceRequest.class,
279 LambdaResourceRequest.class,
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800280 Lambda.class,
281 Bandwidth.class,
Yuta HIGUCHIadac04a2014-11-13 00:02:45 -0800282 DefaultLinkResourceAllocations.class,
283 BandwidthResourceAllocation.class,
284 LambdaResourceAllocation.class,
Sho SHIMIZUcd4bac82014-11-11 17:07:25 -0800285 // Constraints
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800286 LambdaConstraint.class,
287 BandwidthConstraint.class,
288 LinkTypeConstraint.class,
Sho SHIMIZUcd4bac82014-11-11 17:07:25 -0800289 LatencyConstraint.class,
290 WaypointConstraint.class,
291 ObstacleConstraint.class,
292 AnnotationConstraint.class,
Brian O'Connor72a034c2014-11-26 18:24:23 -0800293 BooleanConstraint.class,
294 IntentOperation.class,
295 IntentOperations.class
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700296 )
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800297 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
298 .register(new URISerializer(), URI.class)
299 .register(new NodeIdSerializer(), NodeId.class)
300 .register(new ProviderIdSerializer(), ProviderId.class)
301 .register(new DeviceIdSerializer(), DeviceId.class)
302 .register(new PortNumberSerializer(), PortNumber.class)
303 .register(new DefaultPortSerializer(), DefaultPort.class)
304 .register(new LinkKeySerializer(), LinkKey.class)
305 .register(new ConnectPointSerializer(), ConnectPoint.class)
306 .register(new DefaultLinkSerializer(), DefaultLink.class)
307 .register(new MastershipTermSerializer(), MastershipTerm.class)
308 .register(new HostLocationSerializer(), HostLocation.class)
309 .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class)
310 .register(ReadRequest.class)
311 .register(WriteRequest.class)
312 .register(WriteRequest.Type.class)
313 .register(WriteResult.class)
314 .register(ReadResult.class)
315 .register(BatchReadRequest.class)
316 .register(BatchWriteRequest.class)
317 .register(ReadStatus.class)
318 .register(WriteStatus.class)
319 .register(VersionedValue.class)
Yuta HIGUCHIf6171232014-11-25 15:14:44 -0800320 .register(DefaultGroupId.class)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700321
322 .build();
323
324
325 // not to be instantiated
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700326 private KryoNamespaces() {}
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700327}