Adding serializer for FilteredConnectPoint
Change-Id: Ie21f2fbbdf8b936719c5c2745a83c3bd662c8cc1
Showing
2 changed files
with
53 additions
and
0 deletions
| 1 | +/* | ||
| 2 | + * Copyright 2016-present 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 | + */ | ||
| 16 | +package org.onosproject.store.serializers; | ||
| 17 | + | ||
| 18 | +import com.esotericsoftware.kryo.Kryo; | ||
| 19 | +import com.esotericsoftware.kryo.Serializer; | ||
| 20 | +import com.esotericsoftware.kryo.io.Input; | ||
| 21 | +import com.esotericsoftware.kryo.io.Output; | ||
| 22 | +import org.onosproject.net.ConnectPoint; | ||
| 23 | +import org.onosproject.net.FilteredConnectPoint; | ||
| 24 | +import org.onosproject.net.flow.TrafficSelector; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * Kryo Serializer for {@link FilteredConnectPointSerializer}. | ||
| 28 | + */ | ||
| 29 | +public class FilteredConnectPointSerializer extends Serializer<FilteredConnectPoint> { | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * Creates {@link FilteredConnectPointSerializer} serializer instance. | ||
| 33 | + */ | ||
| 34 | + public FilteredConnectPointSerializer() { | ||
| 35 | + // non-null, immutable | ||
| 36 | + super(false, true); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public void write(Kryo kryo, Output output, FilteredConnectPoint object) { | ||
| 41 | + kryo.writeClassAndObject(output, object.connectPoint()); | ||
| 42 | + kryo.writeClassAndObject(output, object.trafficSelector()); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public FilteredConnectPoint read(Kryo kryo, Input input, Class<FilteredConnectPoint> type) { | ||
| 47 | + ConnectPoint connectPoint = (ConnectPoint) kryo.readClassAndObject(input); | ||
| 48 | + TrafficSelector trafficSelector = (TrafficSelector) kryo.readClassAndObject(input); | ||
| 49 | + return new FilteredConnectPoint(connectPoint, trafficSelector); | ||
| 50 | + } | ||
| 51 | +} |
| ... | @@ -68,6 +68,7 @@ import org.onosproject.net.Device; | ... | @@ -68,6 +68,7 @@ import org.onosproject.net.Device; |
| 68 | import org.onosproject.net.DeviceId; | 68 | import org.onosproject.net.DeviceId; |
| 69 | import org.onosproject.net.Element; | 69 | import org.onosproject.net.Element; |
| 70 | import org.onosproject.net.EncapsulationType; | 70 | import org.onosproject.net.EncapsulationType; |
| 71 | +import org.onosproject.net.FilteredConnectPoint; | ||
| 71 | import org.onosproject.net.GridType; | 72 | import org.onosproject.net.GridType; |
| 72 | import org.onosproject.net.HostId; | 73 | import org.onosproject.net.HostId; |
| 73 | import org.onosproject.net.HostLocation; | 74 | import org.onosproject.net.HostLocation; |
| ... | @@ -500,6 +501,7 @@ public final class KryoNamespaces { | ... | @@ -500,6 +501,7 @@ public final class KryoNamespaces { |
| 500 | .register(new DefaultPortSerializer(), DefaultPort.class) | 501 | .register(new DefaultPortSerializer(), DefaultPort.class) |
| 501 | .register(new LinkKeySerializer(), LinkKey.class) | 502 | .register(new LinkKeySerializer(), LinkKey.class) |
| 502 | .register(new ConnectPointSerializer(), ConnectPoint.class) | 503 | .register(new ConnectPointSerializer(), ConnectPoint.class) |
| 504 | + .register(new FilteredConnectPointSerializer(), FilteredConnectPoint.class) | ||
| 503 | .register(new DefaultLinkSerializer(), DefaultLink.class) | 505 | .register(new DefaultLinkSerializer(), DefaultLink.class) |
| 504 | .register(new MastershipTermSerializer(), MastershipTerm.class) | 506 | .register(new MastershipTermSerializer(), MastershipTerm.class) |
| 505 | .register(new HostLocationSerializer(), HostLocation.class) | 507 | .register(new HostLocationSerializer(), HostLocation.class) | ... | ... |
-
Please register or login to post a comment