blob: deddb87eee4a5f09af3f3c76f0fb2421d14afa55 [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;
Brian O'Connorabafb502014-12-02 22:26:20 -080031import org.onosproject.cluster.ControllerNode;
32import org.onosproject.cluster.DefaultControllerNode;
33import org.onosproject.cluster.Leadership;
34import org.onosproject.cluster.LeadershipEvent;
35import org.onosproject.cluster.NodeId;
36import org.onosproject.cluster.RoleInfo;
37import org.onosproject.core.DefaultApplicationId;
38import org.onosproject.core.DefaultGroupId;
39import org.onosproject.mastership.MastershipTerm;
40import org.onosproject.net.ConnectPoint;
41import org.onosproject.net.DefaultAnnotations;
42import org.onosproject.net.DefaultDevice;
43import org.onosproject.net.DefaultEdgeLink;
44import org.onosproject.net.DefaultLink;
45import org.onosproject.net.DefaultPath;
46import org.onosproject.net.DefaultPort;
47import org.onosproject.net.Device;
48import org.onosproject.net.DeviceId;
49import org.onosproject.net.Element;
50import org.onosproject.net.HostId;
51import org.onosproject.net.HostLocation;
52import org.onosproject.net.Link;
53import org.onosproject.net.LinkKey;
54import org.onosproject.net.Port;
55import org.onosproject.net.PortNumber;
56import org.onosproject.net.device.DefaultDeviceDescription;
57import org.onosproject.net.device.DefaultPortDescription;
58import org.onosproject.net.flow.CompletedBatchOperation;
sangho11c30ac2015-01-22 14:30:55 -080059import org.onosproject.net.flow.FlowRule;
Brian O'Connorabafb502014-12-02 22:26:20 -080060import org.onosproject.net.flow.DefaultFlowEntry;
61import org.onosproject.net.flow.DefaultFlowRule;
62import org.onosproject.net.flow.DefaultTrafficSelector;
63import org.onosproject.net.flow.DefaultTrafficTreatment;
64import org.onosproject.net.flow.FlowEntry;
65import org.onosproject.net.flow.FlowId;
66import org.onosproject.net.flow.FlowRuleBatchEntry;
67import org.onosproject.net.flow.FlowRuleBatchOperation;
68import org.onosproject.net.flow.StoredFlowEntry;
69import org.onosproject.net.flow.criteria.Criteria;
70import org.onosproject.net.flow.criteria.Criterion;
71import org.onosproject.net.flow.instructions.Instructions;
72import org.onosproject.net.flow.instructions.L0ModificationInstruction;
73import org.onosproject.net.flow.instructions.L2ModificationInstruction;
74import org.onosproject.net.flow.instructions.L3ModificationInstruction;
75import org.onosproject.net.host.DefaultHostDescription;
76import org.onosproject.net.host.HostDescription;
77import org.onosproject.net.intent.ConnectivityIntent;
78import org.onosproject.net.intent.HostToHostIntent;
79import org.onosproject.net.intent.Intent;
80import org.onosproject.net.intent.IntentId;
81import org.onosproject.net.intent.IntentOperation;
82import org.onosproject.net.intent.IntentOperations;
83import org.onosproject.net.intent.IntentState;
84import org.onosproject.net.intent.LinkCollectionIntent;
85import org.onosproject.net.intent.MultiPointToSinglePointIntent;
86import org.onosproject.net.intent.OpticalConnectivityIntent;
87import org.onosproject.net.intent.OpticalPathIntent;
88import org.onosproject.net.intent.PathIntent;
89import org.onosproject.net.intent.PointToPointIntent;
Brian O'Connorabafb502014-12-02 22:26:20 -080090import org.onosproject.net.intent.SinglePointToMultiPointIntent;
Jonathan Hart45727852015-01-28 13:35:54 -080091import org.onosproject.net.intent.constraint.AnnotationConstraint;
Brian O'Connorabafb502014-12-02 22:26:20 -080092import org.onosproject.net.intent.constraint.BandwidthConstraint;
93import org.onosproject.net.intent.constraint.BooleanConstraint;
94import org.onosproject.net.intent.constraint.LambdaConstraint;
95import org.onosproject.net.intent.constraint.LatencyConstraint;
96import org.onosproject.net.intent.constraint.LinkTypeConstraint;
97import org.onosproject.net.intent.constraint.ObstacleConstraint;
98import org.onosproject.net.intent.constraint.WaypointConstraint;
99import org.onosproject.net.link.DefaultLinkDescription;
100import org.onosproject.net.packet.DefaultOutboundPacket;
101import org.onosproject.net.provider.ProviderId;
102import org.onosproject.net.resource.Bandwidth;
103import org.onosproject.net.resource.BandwidthResourceAllocation;
104import org.onosproject.net.resource.BandwidthResourceRequest;
105import org.onosproject.net.resource.DefaultLinkResourceAllocations;
106import org.onosproject.net.resource.DefaultLinkResourceRequest;
107import org.onosproject.net.resource.Lambda;
108import org.onosproject.net.resource.LambdaResourceAllocation;
109import org.onosproject.net.resource.LambdaResourceRequest;
110import org.onosproject.net.resource.LinkResourceRequest;
111import org.onosproject.store.Timestamp;
112import org.onosproject.store.service.BatchReadRequest;
113import org.onosproject.store.service.BatchWriteRequest;
114import org.onosproject.store.service.ReadRequest;
115import org.onosproject.store.service.ReadResult;
116import org.onosproject.store.service.ReadStatus;
117import org.onosproject.store.service.VersionedValue;
118import org.onosproject.store.service.WriteRequest;
119import org.onosproject.store.service.WriteResult;
120import org.onosproject.store.service.WriteStatus;
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700121
Jonathan Hart45727852015-01-28 13:35:54 -0800122import java.net.URI;
123import java.time.Duration;
124import java.util.ArrayList;
125import java.util.Arrays;
126import java.util.Collections;
127import java.util.HashMap;
128import java.util.HashSet;
129import java.util.LinkedList;
130import java.util.Optional;
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)
Jonathan Hart45727852015-01-28 13:35:54 -0800161 .register(Collections.emptyList().getClass())
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800162 .build();
163
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700164 /**
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700165 * KryoNamespace which can serialize ON.lab misc classes.
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700166 */
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700167 public static final KryoNamespace MISC = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800168 .nextId(KryoNamespace.FLOATING_ID)
169 .register(new IpPrefixSerializer(), IpPrefix.class)
170 .register(new Ip4PrefixSerializer(), Ip4Prefix.class)
171 .register(new Ip6PrefixSerializer(), Ip6Prefix.class)
172 .register(new IpAddressSerializer(), IpAddress.class)
173 .register(new Ip4AddressSerializer(), Ip4Address.class)
174 .register(new Ip6AddressSerializer(), Ip6Address.class)
175 .register(new MacAddressSerializer(), MacAddress.class)
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700176 .register(VlanId.class)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700177 .build();
178
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800179 /**
180 * Kryo registration Id for user custom registration.
181 */
182 public static final int BEGIN_USER_CUSTOM_ID = 300;
183
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700184 // TODO: Populate other classes
185 /**
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700186 * KryoNamespace which can serialize API bundle classes.
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700187 */
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700188 public static final KryoNamespace API = KryoNamespace.newBuilder()
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800189 .nextId(KryoNamespace.INITIAL_ID)
Yuta HIGUCHI1aa249c2014-11-05 17:40:28 -0800190 .register(BASIC)
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800191 .nextId(KryoNamespace.INITIAL_ID + 30)
192 .register(MISC)
193 .nextId(KryoNamespace.INITIAL_ID + 30 + 10)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700194 .register(
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700195 ControllerNode.State.class,
196 Device.Type.class,
Thomas Vachuskad16ce182014-10-29 17:25:29 -0700197 Port.Type.class,
alshabib7911a052014-10-16 17:49:37 -0700198 ChassisId.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700199 DefaultAnnotations.class,
200 DefaultControllerNode.class,
201 DefaultDevice.class,
Madan Jampani53e44e62014-10-07 12:39:51 -0700202 DefaultDeviceDescription.class,
Madan Jampani2ff05592014-10-10 15:42:47 -0700203 DefaultLinkDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700204 Port.class,
Madan Jampani53e44e62014-10-07 12:39:51 -0700205 DefaultPortDescription.class,
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700206 Element.class,
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -0700207 Link.Type.class,
Thomas Vachuska57126fe2014-11-11 17:13:24 -0800208 Link.State.class,
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700209 Timestamp.class,
Madan Jampani1ee91782014-11-20 20:24:24 -0800210 Leadership.class,
211 LeadershipEvent.class,
212 LeadershipEvent.Type.class,
Yuta HIGUCHI5fa3dc02014-10-15 17:08:13 -0700213 HostId.class,
214 HostDescription.class,
Madan Jampani38b250d2014-10-17 11:02:38 -0700215 DefaultHostDescription.class,
Madan Jampani117aaae2014-10-23 10:04:05 -0700216 DefaultFlowEntry.class,
217 StoredFlowEntry.class,
sangho11c30ac2015-01-22 14:30:55 -0800218 FlowRule.Type.class,
Yuta HIGUCHI2fcfde92014-10-20 18:37:14 -0700219 DefaultFlowRule.class,
alshabib3d643ec2014-10-22 18:33:00 -0700220 DefaultFlowEntry.class,
alshabibf6c2ede2014-10-22 23:31:50 -0700221 FlowEntry.FlowEntryState.class,
Yuta HIGUCHI2809bf32014-10-20 22:44:12 -0700222 FlowId.class,
Yuta HIGUCHI85d58d12014-10-20 23:59:44 -0700223 DefaultTrafficSelector.class,
224 Criteria.PortCriterion.class,
225 Criteria.EthCriterion.class,
226 Criteria.EthTypeCriterion.class,
227 Criteria.IPCriterion.class,
228 Criteria.IPProtocolCriterion.class,
229 Criteria.VlanIdCriterion.class,
230 Criteria.VlanPcpCriterion.class,
231 Criteria.TcpPortCriterion.class,
Praseed Balakrishnandb8a9d22014-12-03 11:47:55 -0800232 Criteria.OpticalSignalTypeCriterion.class,
233 Criteria.LambdaCriterion.class,
234 Criteria.MplsCriterion.class,
Yuta HIGUCHI85d58d12014-10-20 23:59:44 -0700235 Criterion.class,
236 Criterion.Type.class,
237 DefaultTrafficTreatment.class,
238 Instructions.DropInstruction.class,
Yuta HIGUCHI40d01772014-10-21 00:08:44 -0700239 Instructions.OutputInstruction.class,
Jonathan Hart68fef9d2014-10-29 17:30:03 -0700240 L0ModificationInstruction.class,
241 L0ModificationInstruction.L0SubType.class,
242 L0ModificationInstruction.ModLambdaInstruction.class,
243 L2ModificationInstruction.class,
244 L2ModificationInstruction.L2SubType.class,
245 L2ModificationInstruction.ModEtherInstruction.class,
246 L2ModificationInstruction.ModVlanIdInstruction.class,
247 L2ModificationInstruction.ModVlanPcpInstruction.class,
248 L3ModificationInstruction.class,
249 L3ModificationInstruction.L3SubType.class,
250 L3ModificationInstruction.ModIPInstruction.class,
Yuta HIGUCHI9def0472014-10-23 15:51:10 -0700251 RoleInfo.class,
252 FlowRuleBatchOperation.class,
253 CompletedBatchOperation.class,
254 FlowRuleBatchEntry.class,
Yuta HIGUCHI087019b2014-10-28 21:07:56 -0700255 FlowRuleBatchEntry.FlowRuleOperation.class,
256 IntentId.class,
257 IntentState.class,
258 Intent.class,
259 ConnectivityIntent.class,
260 PathIntent.class,
261 DefaultPath.class,
262 DefaultEdgeLink.class,
263 HostToHostIntent.class,
264 PointToPointIntent.class,
Jonathan Hart68fef9d2014-10-29 17:30:03 -0700265 MultiPointToSinglePointIntent.class,
Michele Santuari4a338072014-11-05 18:38:55 +0100266 SinglePointToMultiPointIntent.class,
Brian O'Connor41718fc2014-10-30 16:57:21 -0700267 LinkCollectionIntent.class,
268 OpticalConnectivityIntent.class,
269 OpticalPathIntent.class,
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800270 LinkResourceRequest.class,
Yuta HIGUCHIadac04a2014-11-13 00:02:45 -0800271 DefaultLinkResourceRequest.class,
272 BandwidthResourceRequest.class,
273 LambdaResourceRequest.class,
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800274 Lambda.class,
275 Bandwidth.class,
Yuta HIGUCHIadac04a2014-11-13 00:02:45 -0800276 DefaultLinkResourceAllocations.class,
277 BandwidthResourceAllocation.class,
278 LambdaResourceAllocation.class,
Sho SHIMIZUcd4bac82014-11-11 17:07:25 -0800279 // Constraints
Thomas Vachuska7d0032b2014-11-04 17:39:57 -0800280 LambdaConstraint.class,
281 BandwidthConstraint.class,
282 LinkTypeConstraint.class,
Sho SHIMIZUcd4bac82014-11-11 17:07:25 -0800283 LatencyConstraint.class,
284 WaypointConstraint.class,
285 ObstacleConstraint.class,
286 AnnotationConstraint.class,
Brian O'Connor72a034c2014-11-26 18:24:23 -0800287 BooleanConstraint.class,
288 IntentOperation.class,
289 IntentOperations.class
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700290 )
Yuta HIGUCHI91768e32014-11-22 05:06:35 -0800291 .register(new DefaultApplicationIdSerializer(), DefaultApplicationId.class)
292 .register(new URISerializer(), URI.class)
293 .register(new NodeIdSerializer(), NodeId.class)
294 .register(new ProviderIdSerializer(), ProviderId.class)
295 .register(new DeviceIdSerializer(), DeviceId.class)
296 .register(new PortNumberSerializer(), PortNumber.class)
297 .register(new DefaultPortSerializer(), DefaultPort.class)
298 .register(new LinkKeySerializer(), LinkKey.class)
299 .register(new ConnectPointSerializer(), ConnectPoint.class)
300 .register(new DefaultLinkSerializer(), DefaultLink.class)
301 .register(new MastershipTermSerializer(), MastershipTerm.class)
302 .register(new HostLocationSerializer(), HostLocation.class)
303 .register(new DefaultOutboundPacketSerializer(), DefaultOutboundPacket.class)
304 .register(ReadRequest.class)
305 .register(WriteRequest.class)
306 .register(WriteRequest.Type.class)
307 .register(WriteResult.class)
308 .register(ReadResult.class)
309 .register(BatchReadRequest.class)
310 .register(BatchWriteRequest.class)
311 .register(ReadStatus.class)
312 .register(WriteStatus.class)
313 .register(VersionedValue.class)
Yuta HIGUCHIf6171232014-11-25 15:14:44 -0800314 .register(DefaultGroupId.class)
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700315
316 .build();
317
318
319 // not to be instantiated
Yuta HIGUCHI8d143d22014-10-19 23:15:09 -0700320 private KryoNamespaces() {}
Yuta HIGUCHI03fec1f2014-10-03 09:13:50 -0700321}