+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.impl;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.opendaylight.protocol.concepts.AbstractRegistration;
-import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPExplicitRouteObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPIncludeRouteObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPLoadBalancingObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPLspObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPPathKeyObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPReportedRouteObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
-import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
-import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv4TlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv6TlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LspDbVersionTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LspSymbolicNameTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.LspUpdateErrorTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.OrderTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.OverloadedDurationTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.PCEStatefulCapabilityTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.PredundancyGroupTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.RSVPErrorSpecTlvParser;
-import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
-import org.opendaylight.protocol.pcep.spi.MessageParser;
-import org.opendaylight.protocol.pcep.spi.MessageSerializer;
-import org.opendaylight.protocol.pcep.spi.ObjectParser;
-import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
-import org.opendaylight.protocol.pcep.spi.SubobjectParser;
-import org.opendaylight.protocol.pcep.spi.SubobjectSerializer;
-import org.opendaylight.protocol.pcep.spi.TlvParser;
-import org.opendaylight.protocol.pcep.spi.TlvSerializer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspErrorCodeTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspIdentifiersTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OrderTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OverloadDurationTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcepErrorObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReqMissingTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RsvpErrorSpecTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SymbolicPathNameTlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
-
-import com.google.common.base.Preconditions;
-
-public class HandlerRegistryImpl implements HandlerRegistry {
- public static final HandlerRegistry INSTANCE;
-
- static {
- final HandlerRegistry reg = new HandlerRegistryImpl();
-
- // FIXME: fill this in
-
- // reg.registerMessageHandler(PCEPOpenMessage.class, 1, new PCEPOpenMessageParser());
- // reg.registerMessageHandler(PCEPNotificationMessage.class, 5, new PCEPNotificationMessageParser());
- // reg.registerMessageHandler(PCEPKeepAliveMessage.class, 2, new PCEPKeepAliveMessageParser());
- // reg.registerMessageHandler(PCEPReplyMessage.class, 4, new PCEPReplyMessageParser());
- // reg.registerMessageHandler(PCEPRequestMessage.class, 3, new PCEPRequestMessageParser());
- // reg.registerMessageHandler(PCEPErrorMessage.class, 6, new PCEPErrorMessageParser());
- // reg.registerMessageHandler(PCEPCloseMessage.class, 7, new PCEPCloseMessageParser());
- // reg.registerMessageHandler(PCEPUpdateRequestMessage.class, 11, new PCEPUpdateRequestMessageParser());
- // reg.registerMessageHandler(PCEPReportMessage.class, 10, new PCEPReportMessageParser());
- // reg.registerMessageHandler(PCCreateMessage.class, 12, new PCCreateMessageParser());
-
- reg.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
- reg.registerTlvParser(OverloadedDurationTlvParser.TYPE, new OverloadedDurationTlvParser());
- reg.registerTlvParser(ReqMissingTlvParser.TYPE, new ReqMissingTlvParser());
- reg.registerTlvParser(OFListTlvParser.TYPE, new OFListTlvParser());
- reg.registerTlvParser(OrderTlvParser.TYPE, new OrderTlvParser());
- reg.registerTlvParser(PCEStatefulCapabilityTlvParser.TYPE, new PCEStatefulCapabilityTlvParser());
- reg.registerTlvParser(LspSymbolicNameTlvParser.TYPE, new LspSymbolicNameTlvParser());
- reg.registerTlvParser(LSPIdentifierIPv4TlvParser.TYPE, new LSPIdentifierIPv4TlvParser());
- reg.registerTlvParser(LSPIdentifierIPv6TlvParser.TYPE, new LSPIdentifierIPv6TlvParser());
- reg.registerTlvParser(LspUpdateErrorTlvParser.TYPE, new LspUpdateErrorTlvParser());
- reg.registerTlvParser(RSVPErrorSpecTlvParser.TYPE, new RSVPErrorSpecTlvParser());
- reg.registerTlvParser(LspDbVersionTlvParser.TYPE, new LspDbVersionTlvParser());
- reg.registerTlvParser(PredundancyGroupTlvParser.TYPE, new PredundancyGroupTlvParser());
-
- reg.registerTlvSerializer(NoPathVectorTlv.class, new NoPathVectorTlvParser());
- reg.registerTlvSerializer(OverloadDurationTlv.class, new OverloadedDurationTlvParser());
- reg.registerTlvSerializer(ReqMissingTlv.class, new ReqMissingTlvParser());
- reg.registerTlvSerializer(OfListTlv.class, new OFListTlvParser());
- reg.registerTlvSerializer(OrderTlv.class, new OrderTlvParser());
- reg.registerTlvSerializer(StatefulCapabilityTlv.class, new PCEStatefulCapabilityTlvParser());
- reg.registerTlvSerializer(SymbolicPathNameTlv.class, new LspSymbolicNameTlvParser());
- reg.registerTlvSerializer(LspIdentifiersTlv.class, new LSPIdentifierIPv4TlvParser());
- reg.registerTlvSerializer(LspErrorCodeTlv.class, new LspUpdateErrorTlvParser());
- reg.registerTlvSerializer(RsvpErrorSpecTlv.class, new RSVPErrorSpecTlvParser());
- reg.registerTlvSerializer(LspDbVersionTlv.class, new LspDbVersionTlvParser());
- reg.registerTlvSerializer(PredundancyGroupIdTlv.class, new PredundancyGroupTlvParser());
-
- reg.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(reg));
- reg.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE,
- new PCEPRequestParameterObjectParser(reg));
- reg.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(reg));
- reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(reg));
- reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6, new PCEPEndPointsObjectParser(reg));
- reg.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(reg));
- reg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE, new PCEPBandwidthObjectParser(reg));
- reg.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(reg));
- reg.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE,
- new PCEPExplicitRouteObjectParser(reg));
- reg.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE,
- new PCEPReportedRouteObjectParser(reg));
- reg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser(reg));
- reg.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE,
- new PCEPIncludeRouteObjectParser(reg));
- reg.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(reg));
- reg.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE,
- new PCEPNotificationObjectParser(reg));
- reg.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, new PCEPErrorObjectParser(reg));
- reg.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE,
- new PCEPLoadBalancingObjectParser(reg));
- reg.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, new PCEPCloseObjectParser(reg));
- reg.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, new PCEPPathKeyObjectParser(reg));
- reg.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE,
- new PCEPObjectiveFunctionObjectParser(reg));
- reg.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(reg));
- reg.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE,
- new PCEPGlobalConstraintsObjectParser(reg));
- reg.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(reg));
- reg.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(reg));
- // reg.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, new
- // PCEPExcludeRouteObjectParser(reg));
-
- reg.registerObjectSerializer(OpenObject.class, new PCEPOpenObjectParser(reg));
- reg.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(reg));
- reg.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(reg));
- reg.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(reg));
- reg.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(reg));
- reg.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(reg));
- reg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(reg));
- reg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(reg));
- reg.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(reg));
- reg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(reg));
- reg.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(reg));
- reg.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(reg));
- reg.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(reg));
- reg.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(reg));
- reg.registerObjectSerializer(CloseObject.class, new PCEPCloseObjectParser(reg));
- reg.registerObjectSerializer(PathKeyObject.class, new PCEPPathKeyObjectParser(reg));
- reg.registerObjectSerializer(OfObject.class, new PCEPObjectiveFunctionObjectParser(reg));
- reg.registerObjectSerializer(ClasstypeObject.class, new PCEPClassTypeObjectParser(reg));
- reg.registerObjectSerializer(GcObject.class, new PCEPGlobalConstraintsObjectParser(reg));
- reg.registerObjectSerializer(LspObject.class, new PCEPLspObjectParser(reg));
- reg.registerObjectSerializer(SrpObject.class, new PCEPSrpObjectParser(reg));
- // reg.registerObjectSerializer(ExcludeRouteObject.class, new PCEPExcludeRouteObjectParser(reg));
-
- reg.registerSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
-
- reg.registerSubobjectSerializer(AsNumberSubobject.class, new EROAsNumberSubobjectParser());
-
- INSTANCE = reg;
- }
-
- private final Map<Integer, MessageParser> msgParsers = new ConcurrentHashMap<>();
- private final Map<Class<? extends Message>, MessageSerializer> msgSerializers = new ConcurrentHashMap<>();
-
- private final Map<Integer, ObjectParser> objParsers = new ConcurrentHashMap<>();
- private final Map<Class<? extends Object>, ObjectSerializer> objSerializers = new ConcurrentHashMap<>();
-
- private final Map<Integer, TlvParser> tlvParsers = new ConcurrentHashMap<>();
- private final Map<Class<? extends Tlv>, TlvSerializer> tlvSerializers = new ConcurrentHashMap<>();
-
- private final Map<Integer, SubobjectParser> subobjectParsers = new ConcurrentHashMap<>();
- private final Map<Class<? extends CSubobject>, SubobjectSerializer> subobjectSerializers = new ConcurrentHashMap<>();
-
- private HandlerRegistryImpl() {
-
- }
-
- @Override
- public MessageParser getMessageParser(final int messageType) {
- Preconditions.checkArgument(messageType >= 0 && messageType <= 255);
- return this.msgParsers.get(messageType);
- }
-
- @Override
- public MessageSerializer getMessageSerializer(final Message message) {
- final Class<? extends Message> c = message.getClass();
- for (final Map.Entry<Class<? extends Message>, MessageSerializer> s : this.msgSerializers.entrySet()) {
- if (s.getKey().isAssignableFrom(c)) {
- return s.getValue();
- }
- }
-
- return null;
- }
-
- @Override
- public synchronized ObjectParser getObjectParser(final int objectClass, final int objectType) {
- Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
- Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
-
- return this.objParsers.get((objectClass << 4) + objectType);
- }
-
- @Override
- public ObjectSerializer getObjectSerializer(final Object object) {
- final Class<? extends Object> c = object.getClass();
- for (final Map.Entry<Class<? extends Object>, ObjectSerializer> s : this.objSerializers.entrySet()) {
- if (s.getKey().isAssignableFrom(c)) {
- return s.getValue();
- }
- }
-
- return null;
- }
-
- @Override
- public TlvParser getTlvParser(final int tlvType) {
- Preconditions.checkArgument(tlvType >= 0 && tlvType <= 65535);
- return this.tlvParsers.get(tlvType);
- }
-
- @Override
- public TlvSerializer getTlvSerializer(final Tlv tlv) {
- final Class<? extends Tlv> c = tlv.getClass();
- for (final Map.Entry<Class<? extends Tlv>, TlvSerializer> s : this.tlvSerializers.entrySet()) {
- if (s.getKey().isAssignableFrom(c)) {
- return s.getValue();
- }
- }
-
- return null;
- }
-
- @Override
- public SubobjectSerializer getSubobjectSerializer(final CSubobject subobject) {
- final Class<? extends CSubobject> c = subobject.getClass();
- for (final Map.Entry<Class<? extends CSubobject>, SubobjectSerializer> s : this.subobjectSerializers.entrySet()) {
- if (s.getKey().isAssignableFrom(c)) {
- return s.getValue();
- }
- }
- return null;
- }
-
- @Override
- public SubobjectParser getSubobjectParser(final int subobjectType) {
- Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
- return this.subobjectParsers.get(subobjectType);
- }
-
- private synchronized void unregisterMessageParser(final Integer msgType) {
- this.msgParsers.remove(msgType);
- }
-
- @Override
- public synchronized AutoCloseable registerMessageParser(final int msgType, final MessageParser parser) {
- Preconditions.checkArgument(msgType >= 0 && msgType <= 255);
- Preconditions.checkArgument(!this.msgParsers.containsKey(msgType), "Message type %s already registered", msgType);
- this.msgParsers.put(msgType, parser);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterMessageParser(msgType);
- }
- };
- }
-
- private synchronized void unregisterMessageSerializer(final Class<? extends Message> msgClass) {
- this.msgSerializers.remove(msgClass);
- }
-
- @Override
- public synchronized AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass, final MessageSerializer serializer) {
- Preconditions.checkArgument(!this.msgSerializers.containsKey(msgClass), "Message class %s already registered", msgClass);
- this.msgSerializers.put(msgClass, serializer);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterMessageSerializer(msgClass);
- }
- };
- }
-
- private synchronized void unregisterObjectParser(final Integer key) {
- this.objParsers.remove(key);
- }
-
- @Override
- public synchronized AutoCloseable registerObjectParser(final int objectClass, final int objectType, final ObjectParser parser) {
- Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
- Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
-
- final Integer key = (objectClass << 4) + objectType;
- Preconditions.checkArgument(!this.objParsers.containsKey(key), "Object class %s type %s already registered", objectClass,
- objectType);
- this.objParsers.put(key, parser);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterObjectParser(key);
- }
- };
- }
-
- private synchronized void unregisterObjectSerializer(final Class<? extends Object> objClass) {
- this.objSerializers.remove(objClass);
- }
-
- @Override
- public synchronized AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass, final ObjectSerializer serializer) {
- Preconditions.checkArgument(!this.objSerializers.containsKey(objClass), "Object class %s already registered", objClass);
- this.objSerializers.put(objClass, serializer);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterObjectSerializer(objClass);
- }
- };
- }
-
- private synchronized void unregisterTlvParser(final int tlvType) {
- this.tlvParsers.remove(tlvType);
- }
-
- @Override
- public synchronized AutoCloseable registerTlvParser(final int tlvType, final TlvParser parser) {
- Preconditions.checkArgument(tlvType >= 0 && tlvType <= 65535);
- Preconditions.checkArgument(!this.tlvParsers.containsKey(tlvType), "TLV type %s already registered", tlvType);
-
- this.tlvParsers.put(tlvType, parser);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterTlvParser(tlvType);
- }
- };
- }
-
- private synchronized void unregisterTlvSerializer(final Class<? extends Tlv> tlvClass) {
- this.tlvSerializers.remove(tlvClass);
- }
-
- @Override
- public synchronized AutoCloseable registerTlvSerializer(final Class<? extends Tlv> tlvClass, final TlvSerializer serializer) {
- Preconditions.checkArgument(!this.tlvSerializers.containsKey(tlvClass), "TLV class %s already registered", tlvClass);
- this.tlvSerializers.put(tlvClass, serializer);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterTlvSerializer(tlvClass);
- }
- };
- }
-
- @Override
- public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass, final SubobjectSerializer serializer) {
- Preconditions.checkArgument(!this.tlvSerializers.containsKey(subobjectClass), "Subobject class %s already registered",
- subobjectClass);
- this.subobjectSerializers.put(subobjectClass, serializer);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterSubobjectSerializer(subobjectClass);
- }
- };
- }
-
- private synchronized void unregisterSubobjectSerializer(final Class<? extends CSubobject> subobjectClass) {
- this.subobjectSerializers.remove(subobjectClass);
- }
-
- @Override
- public AutoCloseable registerSubobjectParser(final int subobjectType, final SubobjectParser parser) {
- Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
- Preconditions.checkArgument(!this.subobjectParsers.containsKey(subobjectType), "Subobject type %s already registered",
- subobjectType);
-
- this.subobjectParsers.put(subobjectType, parser);
-
- return new AbstractRegistration() {
- @Override
- protected void removeRegistration() {
- unregisterSubobjectParser(subobjectType);
- }
- };
- }
-
- private synchronized void unregisterSubobjectParser(final int subobjectType) {
- this.subobjectParsers.remove(subobjectType);
- }
-}
private final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf;
- private final PCEPHandlerFactory hf = new PCEPHandlerFactory();
+ private final PCEPHandlerFactory hf = new PCEPHandlerFactory(SimpleMessageHandlerFactory.INSTANCE);
/**
* Creates an instance of PCEPDispatcherImpl, gets the default selector and opens it.
import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
+import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
/**
public class PCEPHandlerFactory extends ProtocolHandlerFactory<Message> {
private final ProtocolMessageEncoder<Message> encoder;
- public PCEPHandlerFactory() {
- super(new PCEPMessageFactory());
+ public PCEPHandlerFactory(final MessageHandlerRegistry registry) {
+ super(new PCEPMessageFactory(registry));
this.encoder = new ProtocolMessageEncoder<Message>(this.msgFactory);
}
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
import org.opendaylight.protocol.pcep.spi.MessageSerializer;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
private static final int VERSION_SF_LENGTH = 3;
- private final HandlerRegistry registry;
-
private static final int VER_FLAGS_MF_LENGTH = 1;
private static final int TYPE_F_LENGTH = 1;
private static final int LENGTH_F_LENGTH = 2;
private static final int TYPE_F_OFFSET = VER_FLAGS_MF_LENGTH + VER_FLAGS_MF_OFFSET;
private static final int LENGTH_F_OFFSET = TYPE_F_LENGTH + TYPE_F_OFFSET;
- public PCEPMessageFactory() {
- this.registry = HandlerRegistryImpl.INSTANCE;
+ private final MessageHandlerRegistry registry;
+
+ public PCEPMessageFactory(final MessageHandlerRegistry registry) {
+ this.registry = Preconditions.checkNotNull(registry);
}
@Override
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.MessageParser;
+import org.opendaylight.protocol.pcep.spi.MessageSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+/**
+ *
+ */
+public final class SimpleMessageHandlerFactory implements MessageHandlerRegistry {
+ public static final MessageHandlerRegistry INSTANCE;
+
+ static {
+ final MessageHandlerRegistry reg = new SimpleMessageHandlerFactory();
+
+ // FIXME: fill this in
+ // reg.registerMessageHandler(PCEPOpenMessage.class, 1, new PCEPOpenMessageParser());
+ // reg.registerMessageHandler(PCEPNotificationMessage.class, 5, new PCEPNotificationMessageParser());
+ // reg.registerMessageHandler(PCEPKeepAliveMessage.class, 2, new PCEPKeepAliveMessageParser());
+ // reg.registerMessageHandler(PCEPReplyMessage.class, 4, new PCEPReplyMessageParser());
+ // reg.registerMessageHandler(PCEPRequestMessage.class, 3, new PCEPRequestMessageParser());
+ // reg.registerMessageHandler(PCEPErrorMessage.class, 6, new PCEPErrorMessageParser());
+ // reg.registerMessageHandler(PCEPCloseMessage.class, 7, new PCEPCloseMessageParser());
+ // reg.registerMessageHandler(PCEPUpdateRequestMessage.class, 11, new PCEPUpdateRequestMessageParser());
+ // reg.registerMessageHandler(PCEPReportMessage.class, 10, new PCEPReportMessageParser());
+ // reg.registerMessageHandler(PCCreateMessage.class, 12, new PCCreateMessageParser());
+
+ INSTANCE = reg;
+ }
+
+ private final HandlerRegistry<DataContainer, MessageParser, MessageSerializer> handlers = new HandlerRegistry<>();
+
+ @Override
+ public AutoCloseable registerMessageParser(final int messageType, final MessageParser parser) {
+ Preconditions.checkArgument(messageType >= 0 && messageType <= 255);
+ return handlers.registerParser(messageType, parser);
+ }
+
+ @Override
+ public AutoCloseable registerMessageSerializer(final Class<? extends Message> msgClass, final MessageSerializer serializer) {
+ return handlers.registerSerializer(msgClass, serializer);
+ }
+
+ @Override
+ public MessageParser getMessageParser(final int messageType) {
+ Preconditions.checkArgument(messageType >= 0 && messageType <= 255);
+ return handlers.getParser(messageType);
+ }
+
+ @Override
+ public MessageSerializer getMessageSerializer(final Message message) {
+ return handlers.getSerializer(message.getImplementedInterface());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPEndPointsObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPExplicitRouteObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPGlobalConstraintsObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPIncludeRouteObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPLoadBalancingObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPLspObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPLspaObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPMetricObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPNoPathObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPNotificationObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPObjectiveFunctionObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPOpenObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPPathKeyObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPReportedRouteObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPSrpObjectParser;
+import org.opendaylight.protocol.pcep.impl.object.PCEPSvecObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectParser;
+import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcepErrorObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RpObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SvecObject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+/**
+ *
+ */
+public final class SimpleObjectHandlerRegistry implements ObjectHandlerRegistry {
+ public static final ObjectHandlerRegistry INSTANCE;
+
+ static {
+ final ObjectHandlerRegistry reg = new SimpleObjectHandlerRegistry();
+
+ final SubobjectHandlerRegistry subobjReg = SimpleSubobjectHandlerFactory.INSTANCE;
+ final TlvHandlerRegistry tlvReg = SimpleTlvHandlerRegistry.INSTANCE;
+
+ reg.registerObjectParser(PCEPOpenObjectParser.CLASS, PCEPOpenObjectParser.TYPE, new PCEPOpenObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPRequestParameterObjectParser.CLASS, PCEPRequestParameterObjectParser.TYPE,
+ new PCEPRequestParameterObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPNoPathObjectParser.CLASS, PCEPNoPathObjectParser.TYPE, new PCEPNoPathObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS, PCEPEndPointsObjectParser.TYPE, new PCEPEndPointsObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPEndPointsObjectParser.CLASS_6, PCEPEndPointsObjectParser.TYPE_6, new PCEPEndPointsObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPBandwidthObjectParser.CLASS, PCEPBandwidthObjectParser.TYPE, new PCEPBandwidthObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPBandwidthObjectParser.E_CLASS, PCEPBandwidthObjectParser.E_TYPE, new PCEPBandwidthObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPMetricObjectParser.CLASS, PCEPMetricObjectParser.TYPE, new PCEPMetricObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPExplicitRouteObjectParser.CLASS, PCEPExplicitRouteObjectParser.TYPE,
+ new PCEPExplicitRouteObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPReportedRouteObjectParser.CLASS, PCEPReportedRouteObjectParser.TYPE,
+ new PCEPReportedRouteObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPLspaObjectParser.CLASS, PCEPLspaObjectParser.TYPE, new PCEPLspaObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPIncludeRouteObjectParser.CLASS, PCEPIncludeRouteObjectParser.TYPE,
+ new PCEPIncludeRouteObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPSvecObjectParser.CLASS, PCEPSvecObjectParser.TYPE, new PCEPSvecObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPNotificationObjectParser.CLASS, PCEPNotificationObjectParser.TYPE,
+ new PCEPNotificationObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPErrorObjectParser.CLASS, PCEPErrorObjectParser.TYPE, new PCEPErrorObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPLoadBalancingObjectParser.CLASS, PCEPLoadBalancingObjectParser.TYPE,
+ new PCEPLoadBalancingObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPCloseObjectParser.CLASS, PCEPCloseObjectParser.TYPE, new PCEPCloseObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPPathKeyObjectParser.CLASS, PCEPPathKeyObjectParser.TYPE, new PCEPPathKeyObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPObjectiveFunctionObjectParser.CLASS, PCEPObjectiveFunctionObjectParser.TYPE,
+ new PCEPObjectiveFunctionObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPClassTypeObjectParser.CLASS, PCEPClassTypeObjectParser.TYPE, new PCEPClassTypeObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPGlobalConstraintsObjectParser.CLASS, PCEPGlobalConstraintsObjectParser.TYPE,
+ new PCEPGlobalConstraintsObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPLspObjectParser.CLASS, PCEPLspObjectParser.TYPE, new PCEPLspObjectParser(subobjReg, tlvReg));
+ reg.registerObjectParser(PCEPSrpObjectParser.CLASS, PCEPSrpObjectParser.TYPE, new PCEPSrpObjectParser(subobjReg, tlvReg));
+ // reg.registerObjectParser(PCEPExcludeRouteObjectParser.CLASS, PCEPExcludeRouteObjectParser.TYPE, new
+ // PCEPExcludeRouteObjectParser(reg));
+
+ reg.registerObjectSerializer(OpenObject.class, new PCEPOpenObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(RpObject.class, new PCEPRequestParameterObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(NoPathObject.class, new PCEPNoPathObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(EndpointsObject.class, new PCEPEndPointsObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(BandwidthObject.class, new PCEPBandwidthObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(MetricObject.class, new PCEPMetricObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(ExplicitRouteObject.class, new PCEPExplicitRouteObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(ReportedRouteObject.class, new PCEPReportedRouteObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(LspaObject.class, new PCEPLspaObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(IncludeRouteObject.class, new PCEPIncludeRouteObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(SvecObject.class, new PCEPSvecObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(NotificationObject.class, new PCEPNotificationObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(PcepErrorObject.class, new PCEPErrorObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(LoadBalancingObject.class, new PCEPLoadBalancingObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(CloseObject.class, new PCEPCloseObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(PathKeyObject.class, new PCEPPathKeyObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(OfObject.class, new PCEPObjectiveFunctionObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(ClasstypeObject.class, new PCEPClassTypeObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(GcObject.class, new PCEPGlobalConstraintsObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(LspObject.class, new PCEPLspObjectParser(subobjReg, tlvReg));
+ reg.registerObjectSerializer(SrpObject.class, new PCEPSrpObjectParser(subobjReg, tlvReg));
+ // reg.registerObjectSerializer(ExcludeRouteObject.class, new PCEPExcludeRouteObjectParser(reg));
+
+ INSTANCE = reg;
+ }
+
+ private final HandlerRegistry<DataContainer, ObjectParser, ObjectSerializer> handlers = new HandlerRegistry<>();
+
+ private static final int createKey(final int objectClass, final int objectType) {
+ Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
+ Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
+ return (objectClass << 4) | objectType;
+ }
+
+ @Override
+ public AutoCloseable registerObjectParser(final int objectClass, final int objectType, final ObjectParser parser) {
+ Preconditions.checkArgument(objectClass >= 0 && objectClass <= 255);
+ Preconditions.checkArgument(objectType >= 0 && objectType <= 15);
+ return handlers.registerParser(createKey(objectClass, objectType), parser);
+ }
+
+ @Override
+ public AutoCloseable registerObjectSerializer(final Class<? extends Object> objClass, final ObjectSerializer serializer) {
+ return handlers.registerSerializer(objClass, serializer);
+ }
+
+ @Override
+ public ObjectParser getObjectParser(final int objectClass, final int objectType) {
+ return handlers.getParser(createKey(objectClass, objectType));
+ }
+
+ @Override
+ public ObjectSerializer getObjectSerializer(final Object object) {
+ return handlers.getSerializer(object.getImplementedInterface());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.impl.subobject.EROAsNumberSubobjectParser;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectParser;
+import org.opendaylight.protocol.pcep.spi.SubobjectSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.AsNumberSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+public final class SimpleSubobjectHandlerFactory implements SubobjectHandlerRegistry {
+ public static final SubobjectHandlerRegistry INSTANCE;
+
+ static {
+ final SubobjectHandlerRegistry reg = new SimpleSubobjectHandlerFactory();
+
+ reg.registerSubobjectParser(EROAsNumberSubobjectParser.TYPE, new EROAsNumberSubobjectParser());
+ reg.registerSubobjectSerializer(AsNumberSubobject.class, new EROAsNumberSubobjectParser());
+
+ INSTANCE = reg;
+ }
+
+ private final HandlerRegistry<DataContainer, SubobjectParser, SubobjectSerializer> handlers = new HandlerRegistry<>();
+
+ @Override
+ public AutoCloseable registerSubobjectParser(final int subobjectType, final SubobjectParser parser) {
+ Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+ return handlers.registerParser(subobjectType, parser);
+ }
+
+ @Override
+ public SubobjectParser getSubobjectParser(final int subobjectType) {
+ Preconditions.checkArgument(subobjectType >= 0 && subobjectType <= 65535);
+ return handlers.getParser(subobjectType);
+ }
+
+ @Override
+ public AutoCloseable registerSubobjectSerializer(final Class<? extends CSubobject> subobjectClass, final SubobjectSerializer serializer) {
+ return handlers.registerSerializer(subobjectClass, serializer);
+ }
+
+ @Override
+ public SubobjectSerializer getSubobjectSerializer(final CSubobject subobject) {
+ return handlers.getSerializer(subobject.getImplementedInterface());
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.impl;
+
+import org.opendaylight.protocol.concepts.HandlerRegistry;
+import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv4TlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LSPIdentifierIPv6TlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LspDbVersionTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LspSymbolicNameTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.LspUpdateErrorTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.NoPathVectorTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.OFListTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.OrderTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.OverloadedDurationTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.PCEStatefulCapabilityTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.PredundancyGroupTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.RSVPErrorSpecTlvParser;
+import org.opendaylight.protocol.pcep.impl.tlv.ReqMissingTlvParser;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvParser;
+import org.opendaylight.protocol.pcep.spi.TlvSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspErrorCodeTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspIdentifiersTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OfListTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OrderTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OverloadDurationTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PredundancyGroupIdTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReqMissingTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.RsvpErrorSpecTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SymbolicPathNameTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+
+import com.google.common.base.Preconditions;
+
+/**
+ *
+ */
+public final class SimpleTlvHandlerRegistry implements TlvHandlerRegistry {
+ public static final TlvHandlerRegistry INSTANCE;
+
+ static {
+ final TlvHandlerRegistry reg = new SimpleTlvHandlerRegistry();
+
+ reg.registerTlvParser(NoPathVectorTlvParser.TYPE, new NoPathVectorTlvParser());
+ reg.registerTlvParser(OverloadedDurationTlvParser.TYPE, new OverloadedDurationTlvParser());
+ reg.registerTlvParser(ReqMissingTlvParser.TYPE, new ReqMissingTlvParser());
+ reg.registerTlvParser(OFListTlvParser.TYPE, new OFListTlvParser());
+ reg.registerTlvParser(OrderTlvParser.TYPE, new OrderTlvParser());
+ reg.registerTlvParser(PCEStatefulCapabilityTlvParser.TYPE, new PCEStatefulCapabilityTlvParser());
+ reg.registerTlvParser(LspSymbolicNameTlvParser.TYPE, new LspSymbolicNameTlvParser());
+ reg.registerTlvParser(LSPIdentifierIPv4TlvParser.TYPE, new LSPIdentifierIPv4TlvParser());
+ reg.registerTlvParser(LSPIdentifierIPv6TlvParser.TYPE, new LSPIdentifierIPv6TlvParser());
+ reg.registerTlvParser(LspUpdateErrorTlvParser.TYPE, new LspUpdateErrorTlvParser());
+ reg.registerTlvParser(RSVPErrorSpecTlvParser.TYPE, new RSVPErrorSpecTlvParser());
+ reg.registerTlvParser(LspDbVersionTlvParser.TYPE, new LspDbVersionTlvParser());
+ reg.registerTlvParser(PredundancyGroupTlvParser.TYPE, new PredundancyGroupTlvParser());
+
+ reg.registerTlvSerializer(NoPathVectorTlv.class, new NoPathVectorTlvParser());
+ reg.registerTlvSerializer(OverloadDurationTlv.class, new OverloadedDurationTlvParser());
+ reg.registerTlvSerializer(ReqMissingTlv.class, new ReqMissingTlvParser());
+ reg.registerTlvSerializer(OfListTlv.class, new OFListTlvParser());
+ reg.registerTlvSerializer(OrderTlv.class, new OrderTlvParser());
+ reg.registerTlvSerializer(StatefulCapabilityTlv.class, new PCEStatefulCapabilityTlvParser());
+ reg.registerTlvSerializer(SymbolicPathNameTlv.class, new LspSymbolicNameTlvParser());
+ reg.registerTlvSerializer(LspIdentifiersTlv.class, new LSPIdentifierIPv4TlvParser());
+ reg.registerTlvSerializer(LspErrorCodeTlv.class, new LspUpdateErrorTlvParser());
+ reg.registerTlvSerializer(RsvpErrorSpecTlv.class, new RSVPErrorSpecTlvParser());
+ reg.registerTlvSerializer(LspDbVersionTlv.class, new LspDbVersionTlvParser());
+ reg.registerTlvSerializer(PredundancyGroupIdTlv.class, new PredundancyGroupTlvParser());
+
+ INSTANCE = reg;
+ }
+
+ private final HandlerRegistry<DataContainer, TlvParser, TlvSerializer> handlers = new HandlerRegistry<>();
+
+ @Override
+ public AutoCloseable registerTlvParser(final int tlvType, final TlvParser parser) {
+ Preconditions.checkArgument(tlvType >= 0 && tlvType < 65535);
+ return handlers.registerParser(tlvType, parser);
+ }
+
+ @Override
+ public TlvParser getTlvParser(final int tlvType) {
+ return handlers.getParser(tlvType);
+ }
+
+ @Override
+ public AutoCloseable registerTlvSerializer(final Class<? extends Tlv> tlvClass, final TlvSerializer serializer) {
+ return handlers.registerSerializer(tlvClass, serializer);
+ }
+
+ @Override
+ public TlvSerializer getTlvSerializer(final Tlv tlv) {
+ return handlers.getSerializer(tlv.getImplementedInterface());
+ }
+}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcinitiateMessage;
private final int TYPE = 12;
- public PCCreateMessageParser(final HandlerRegistry registry) {
+ public PCCreateMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
- if (!(message instanceof PcinitiateMessage))
+ if (!(message instanceof PcinitiateMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
+ ". Needed PcinitiateMessage.");
+ }
}
@Override
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Close;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseMessage;
private final int TYPE = 7;
- public PCEPCloseMessageParser(final HandlerRegistry registry) {
+ public PCEPCloseMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
- if (!(message instanceof CloseMessage))
+ if (!(message instanceof CloseMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
+ ". Nedded CloseMessage.");
+ }
final CCloseMessage close = ((CloseMessage) message).getCCloseMessage();
if (close.getCClose() == null) {
}
private Close validate(final List<Object> objects) throws PCEPDeserializerException {
- if (objects == null)
+ if (objects == null) {
throw new IllegalArgumentException("Passed list can't be null.");
+ }
- if (objects.isEmpty() || !(objects.get(0) instanceof CClose))
+ if (objects.isEmpty() || !(objects.get(0) instanceof CClose)) {
throw new PCEPDeserializerException("Close message doesn't contain CLOSE object.");
+ }
final Object o = objects.get(0);
final CCloseMessage msg = new CCloseMessageBuilder().setCClose((CClose) o).build();
objects.remove(0);
- if (!objects.isEmpty())
+ if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
+ }
return new CloseBuilder().setCCloseMessage(msg).build();
}
import org.opendaylight.protocol.pcep.PCEPErrors;
import org.opendaylight.protocol.pcep.UnknownObject;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
public final int TYPE = 6;
- public PCEPErrorMessageParser(final HandlerRegistry registry) {
+ public PCEPErrorMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
- if (!(message instanceof PcerrMessage))
+ if (!(message instanceof PcerrMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance " + message.getClass()
+ ". Nedded ErrorMessage.");
+ }
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessage err = ((PcerrMessage) message).getPcerrMessage();
- if (err.getErrors() == null || err.getErrors().isEmpty())
+ if (err.getErrors() == null || err.getErrors().isEmpty()) {
throw new IllegalArgumentException("Errors should not be empty.");
+ }
if (err.getErrorType() instanceof Request) {
final List<Rps> rps = ((Request) err.getErrorType()).getRps();
}
private PcerrMessage validate(final List<Object> objects) throws PCEPDeserializerException, PCEPDocumentedException {
- if (objects == null)
+ if (objects == null) {
throw new IllegalArgumentException("Passed list can't be null.");
+ }
Open openObj = null;
final List<Rps> requestParameters = Lists.newArrayList();
while (!objects.isEmpty()) {
obj = objects.get(0);
- if (obj instanceof UnknownObject)
+ if (obj instanceof UnknownObject) {
return new PcerrBuilder().setPcerrMessage(b.setErrors(((UnknownObject) obj).getErrors()).build()).build();
+ }
switch (state) {
case 1:
state = 2;
if (obj instanceof RpObject) {
final RpObject o = ((RpObject) obj);
- if (o.isProcessingRule())
+ if (o.isProcessingRule()) {
throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+ }
requestParameters.add((Rps) o);
state = 1;
break;
state = 3;
}
- if (state == 3)
+ if (state == 3) {
break;
+ }
objects.remove(0);
}
objects.remove(0);
}
- if (errorObjects.isEmpty() && errorObjects.isEmpty())
+ if (errorObjects.isEmpty() && errorObjects.isEmpty()) {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
+ }
- if (!objects.isEmpty())
+ if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
- if (requestParameters != null)
+ }
+ if (requestParameters != null) {
b.setErrorType(new RequestBuilder().setRps(requestParameters).build());
- if (openObj != null)
+ }
+ if (openObj != null) {
b.setErrorType(new SessionBuilder().setOpen(openObj).build());
+ }
return new PcerrBuilder().setPcerrMessage(b.setErrors(errorObjects).build()).build();
}
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
* Parser for {@link KeepaliveMessage}
*/
public class PCEPKeepAliveMessageParser extends AbstractMessageParser {
-
+
private final int TYPE = 2;
- public PCEPKeepAliveMessageParser(HandlerRegistry registry) {
+ public PCEPKeepAliveMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
- public void serializeMessage(Message message, ByteBuf buffer) {
- if (!(message instanceof KeepaliveMessage))
+ public void serializeMessage(final Message message, final ByteBuf buffer) {
+ if (!(message instanceof KeepaliveMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
+ ". Nedded KeepaliveMessage.");
+ }
buffer.writeBytes(new byte[0]);
}
@Override
- public KeepaliveMessage parseMessage(byte[] buffer) {
+ public KeepaliveMessage parseMessage(final byte[] buffer) {
return new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build();
}
import org.opendaylight.protocol.pcep.PCEPErrors;
import org.opendaylight.protocol.pcep.UnknownObject;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
private final int TYPE = 5;
- public PCEPNotificationMessageParser(final HandlerRegistry registry) {
+ public PCEPNotificationMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
- if (!(message instanceof PcntfMessage))
+ if (!(message instanceof PcntfMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
+ ". Needed PcntfMessage.");
+ }
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessage msg = ((PcntfMessage) message).getPcntfMessage();
for (final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications n : msg.getNotifications()) {
}
public Message validate(final List<Object> objects) throws PCEPDeserializerException {
- if (objects == null)
+ if (objects == null) {
throw new IllegalArgumentException("Passed list can't be null.");
+ }
final PCEPErrorMapping maping = PCEPErrorMapping.getInstance();
return new PcerrBuilder().setPcerrMessage(b.build()).build();
}
- if (comObj == null)
+ if (comObj == null) {
break;
+ }
compositeNotifications.add(comObj);
}
- if (compositeNotifications.isEmpty())
+ if (compositeNotifications.isEmpty()) {
throw new PCEPDeserializerException("Atleast one CompositeNotifiObject is mandatory.");
+ }
- if (!objects.isEmpty())
+ if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
+ }
return new PcntfBuilder().setPcntfMessage(new PcntfMessageBuilder().setNotifications(compositeNotifications).build()).build();
}
while (!objects.isEmpty()) {
obj = objects.get(0);
- if (obj instanceof UnknownObject)
+ if (obj instanceof UnknownObject) {
throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
+ }
switch (state) {
case 1:
state = 2;
if (obj instanceof RpObject) {
final RpObject rp = (RpObject) obj;
- if (rp.isProcessingRule())
+ if (rp.isProcessingRule()) {
throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+ }
requestParameters.add((Rps) rp);
state = 1;
break;
state = 3;
}
- if (state == 3)
+ if (state == 3) {
break;
+ }
objects.remove(obj);
}
- if (notifications.isEmpty())
+ if (notifications.isEmpty()) {
return null;
+ }
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.NotificationsBuilder().setNotifications(
notifications).setRps(requestParameters).build();
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage;
private final int TYPE = 1;
- public PCEPOpenMessageParser(final HandlerRegistry registry) {
+ public PCEPOpenMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
public void serializeMessage(final Message message, final ByteBuf buffer) {
- if (!(message instanceof OpenMessage))
+ if (!(message instanceof OpenMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance " + message.getClass() + ". Nedded OpenMessage.");
+ }
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage open = ((OpenMessage) message).getOpenMessage();
if (open.getOpen() == null) {
private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage validate(
final List<Object> objects) throws PCEPDeserializerException {
- if (objects == null)
+ if (objects == null) {
throw new IllegalArgumentException("Passed list can't be null.");
+ }
- if (objects.isEmpty() || !(objects.get(0) instanceof Open))
+ if (objects.isEmpty() || !(objects.get(0) instanceof Open)) {
throw new PCEPDeserializerException("Open message doesn't contain OPEN object.");
+ }
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage msg = new OpenMessageBuilder().setOpen(
(Open) objects.get(0)).build();
objects.remove(0);
- if (!objects.isEmpty())
+ if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
+ }
return msg;
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
*/
// FIXME: finish
public class PCEPReplyMessageParser extends AbstractMessageParser {
-
+
private final int TYPE = 4;
- public PCEPReplyMessageParser(HandlerRegistry registry) {
+ public PCEPReplyMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
- public void serializeMessage(Message message, ByteBuf buffer) {
- if (!(message instanceof PcrepMessage))
+ public void serializeMessage(final Message message, final ByteBuf buffer) {
+ if (!(message instanceof PcrepMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
+ ". Nedded PcrepMessage.");
+ }
}
@Override
- public PcrepMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+ public PcrepMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
return null;
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrptMessage;
public class PCEPReportMessageParser extends AbstractMessageParser {
private final int TYPE = 10;
-
- public PCEPReportMessageParser(HandlerRegistry registry) {
+
+ public PCEPReportMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
- public void serializeMessage(Message message, ByteBuf buffer) {
- if (!(message instanceof PcrptMessage))
+ public void serializeMessage(final Message message, final ByteBuf buffer) {
+ if (!(message instanceof PcrptMessage)) {
throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass()
+ ". Nedded PcrptMessage.");
+ }
}
@Override
- public PcrptMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+ public PcrptMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
return null;
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcrepMessage;
*/
//FIXME finish
public class PCEPRequestMessageParser extends AbstractMessageParser {
-
+
private final int TYPE = 3;
- public PCEPRequestMessageParser(HandlerRegistry registry) {
+ public PCEPRequestMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
- public void serializeMessage(Message message, ByteBuf buffer) {
- if (!(message instanceof PcrepMessage))
+ public void serializeMessage(final Message message, final ByteBuf buffer) {
+ if (!(message instanceof PcrepMessage)) {
throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + message.getClass()
+ ". Needed PcrepMessage.");
+ }
}
@Override
- public PcrepMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+ public PcrepMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
// TODO Auto-generated method stub
return null;
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcupdMessage;
/**
- * Parser for {@link PcupdMessage}
+ * Parser for {@link PcupdMessage}
*/
public class PCEPUpdateRequestMessageParser extends AbstractMessageParser {
-
+
private final int TYPE = 11;
-
- public PCEPUpdateRequestMessageParser(HandlerRegistry registry) {
+
+ public PCEPUpdateRequestMessageParser(final ObjectHandlerRegistry registry) {
super(registry);
}
@Override
- public void serializeMessage(Message message, ByteBuf buffer) {
- if (!(message instanceof PcupdMessage))
+ public void serializeMessage(final Message message, final ByteBuf buffer) {
+ if (!(message instanceof PcupdMessage)) {
throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + message.getClass()
+ ". Nedded PcupdMessage.");
+ }
}
@Override
- public PcupdMessage parseMessage(byte[] buffer) throws PCEPDeserializerException {
+ public PcupdMessage parseMessage(final byte[] buffer) throws PCEPDeserializerException {
// TODO Auto-generated method stub
return null;
}
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.BandwidthObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
private static final int BANDWIDTH_F_LENGTH = 4;
- public PCEPBandwidthObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPBandwidthObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public BandwidthObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
- if (bytes.length != BANDWIDTH_F_LENGTH)
+ }
+ if (bytes.length != BANDWIDTH_F_LENGTH) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: "
+ BANDWIDTH_F_LENGTH + ".");
+ }
final BandwidthBuilder builder = new BandwidthBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof BandwidthObject))
+ if (!(object instanceof BandwidthObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed BandwidthObject.");
+ }
return ((BandwidthObject) object).getBandwidth().getValue();
}
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClasstypeObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
*/
public static final int SIZE = (RESERVED + CT_F_LENGTH) / 8;
- public PCEPClassTypeObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPClassTypeObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public ClasstypeObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null)
+ PCEPDocumentedException {
+ if (bytes == null) {
throw new IllegalArgumentException("Byte array is mandatory.");
- if (bytes.length != SIZE)
+ }
+ if (bytes.length != SIZE) {
throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: "
+ bytes.length);
- if (!header.isProcessingRule())
+ }
+ if (!header.isProcessingRule()) {
throw new PCEPDocumentedException("Processed bit not set", PCEPErrors.P_FLAG_NOT_SET);
+ }
final ClassTypeBuilder builder = new ClassTypeBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof ClasstypeObject))
+ if (!(object instanceof ClasstypeObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed ClasstypeObject.");
+ }
final byte[] retBytes = new byte[SIZE];
retBytes[SIZE - 1] = ((ClasstypeObject) object).getClassType().getValue().byteValue();
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.impl.Util;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.CloseObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
*/
public static final int TLVS_OFFSET = REASON_F_OFFSET + REASON_F_LENGTH;
- public PCEPCloseObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPCloseObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public CloseObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null)
+ if (bytes == null) {
throw new IllegalArgumentException("Byte array is mandatory.");
+ }
final CCloseBuilder builder = new CCloseBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof CloseObject))
+ if (!(object instanceof CloseObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed CloseObject.");
+ }
final CloseObject obj = (CloseObject) object;
final byte[] tlvs = serializeTlvs(obj.getTlvs());
int tlvsLength = 0;
- if (tlvs != null)
+ if (tlvs != null) {
tlvsLength = tlvs.length;
+ }
final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
- if (tlvs != null)
+ if (tlvs != null) {
ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+ }
final int reason = ((CClose) obj).getReason().intValue();
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.PCEPErrors;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.EndpointsObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
public static final int SRC4_F_OFFSET = 0;
public static final int DEST4_F_OFFSET = SRC4_F_OFFSET + SRC4_F_LENGTH;
-
+
public static final int CLASS_6 = 4;
public static final int TYPE_6 = 2;
public static final int SRC6_F_OFFSET = 0;
public static final int DEST6_F_OFFSET = SRC6_F_OFFSET + SRC6_F_LENGTH;
- public PCEPEndPointsObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPEndPointsObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public EndpointsObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null)
+ PCEPDocumentedException {
+ if (bytes == null) {
throw new IllegalArgumentException("Array of bytes is mandatory");
-
- if (!header.isProcessingRule())
+ }
+
+ if (!header.isProcessingRule()) {
throw new PCEPDocumentedException("Processed flag not set", PCEPErrors.P_FLAG_NOT_SET);
-
+ }
+
final EndpointsBuilder builder = new EndpointsBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
-
+
if (bytes.length == SRC4_F_LENGTH + DEST4_F_LENGTH) {
final Ipv4Builder b = new Ipv4Builder();
b.setSourceIpv4Address(Ipv4Util.addressForBytes(ByteArray.subByte(bytes, SRC4_F_OFFSET, SRC4_F_LENGTH)));
b.setSourceIpv6Address(Ipv6Util.addressForBytes(ByteArray.subByte(bytes, SRC6_F_OFFSET, SRC6_F_LENGTH)));
b.setDestinationIpv6Address((Ipv6Util.addressForBytes(ByteArray.subByte(bytes, DEST6_F_OFFSET, DEST6_F_LENGTH))));
builder.setAddressFamily(b.build());
- } else
+ } else {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
+ }
return builder.build();
}
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof EndpointsObject))
+ if (!(object instanceof EndpointsObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed EndpointsObject.");
+ }
final EndpointsObject ePObj = (EndpointsObject) object;
ByteArray.copyWhole(Ipv6Util.bytesForAddress(((Ipv6) afi).getSourceIpv6Address()), retBytes, SRC6_F_OFFSET);
ByteArray.copyWhole(Ipv6Util.bytesForAddress(((Ipv6) afi).getDestinationIpv6Address()), retBytes, DEST6_F_OFFSET);
return retBytes;
- } else
+ } else {
throw new IllegalArgumentException("Wrong instance of NetworkAddress. Passed " + afi.getClass() + ". Needed IPv4");
+ }
}
@Override
public int getObjectClass() {
return CLASS;
}
-
+
public int get6ObjectType() {
return TYPE_6;
}
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.impl.Util;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
public static final int EV_F_OFFSET = ET_F_OFFSET + ET_F_LENGTH;
public static final int TLVS_OFFSET = EV_F_OFFSET + EV_F_LENGTH;
- public PCEPErrorObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPErrorObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public PcepErrorObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null)
+ PCEPDocumentedException {
+ if (bytes == null) {
throw new IllegalArgumentException("Array of bytes is mandatory.");
+ }
final ErrorsBuilder builder = new ErrorsBuilder();
@Override
public void addTlv(final ErrorsBuilder builder, final Tlv tlv) {
- if (tlv instanceof ReqMissingTlv && builder.getType() == 7)
+ if (tlv instanceof ReqMissingTlv && builder.getType() == 7) {
builder.setTlvs(new TlvsBuilder().setReqMissing(
new ReqMissingBuilder().setRequestId(((ReqMissingTlv) tlv).getRequestId()).build()).build());
+ }
}
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof PcepErrorObject))
+ if (!(object instanceof PcepErrorObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed PcepErrorObject.");
+ }
final PcepErrorObject errObj = (PcepErrorObject) object;
final byte[] tlvs = serializeTlvs(((Errors) errObj).getTlvs());
int tlvsLength = 0;
- if (tlvs != null)
+ if (tlvs != null) {
tlvsLength = tlvs.length;
+ }
final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
- if (tlvs != null)
+ if (tlvs != null) {
ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+ }
retBytes[ET_F_OFFSET] = ByteArray.shortToBytes(errObj.getType())[1];
retBytes[EV_F_OFFSET] = ByteArray.shortToBytes(errObj.getValue())[1];
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ExplicitRouteObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
public static final int TYPE = 1;
- public PCEPExplicitRouteObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPExplicitRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public ExplicitRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+ }
final ExplicitRouteBuilder builder = new ExplicitRouteBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof ExplicitRouteObject))
+ if (!(object instanceof ExplicitRouteObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
+ ". Needed ExplicitRouteObject.");
+ }
final ExplicitRouteObject ero = ((ExplicitRouteObject) object);
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.GcObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
private final static int TLVS_OFFSET = OVER_BOOKING_FACTOR_F_OFFSET + OVER_BOOKING_FACTOR_F_LENGTH;
- public PCEPGlobalConstraintsObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPGlobalConstraintsObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public GcObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
final GcBuilder builder = new GcBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof GcObject))
+ if (!(object instanceof GcObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed GcObject.");
+ }
final GcObject specObj = (GcObject) object;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.IncludeRouteObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
public static final int TYPE = 1;
- public PCEPIncludeRouteObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPIncludeRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public IncludeRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+ }
final IncludeRouteBuilder builder = new IncludeRouteBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof IncludeRouteObject))
+ if (!(object instanceof IncludeRouteObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed IncludeRouteObject.");
+ }
assert !(((IncludeRouteObject) object).getSubobjects().isEmpty()) : "Empty Include Route Object.";
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LoadBalancingObject;
public static final int SIZE = MIN_BAND_F_OFFSET + MIN_BAND_F_LENGTH;
- public PCEPLoadBalancingObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPLoadBalancingObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public LoadBalancingObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+ }
- if (bytes.length != SIZE)
+ if (bytes.length != SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: " + SIZE + ".");
+ }
final LoadBalancingBuilder builder = new LoadBalancingBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof LoadBalancingObject))
+ if (!(object instanceof LoadBalancingObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
+ ". Needed LoadBalancingObject.");
+ }
final LoadBalancingObject specObj = (LoadBalancingObject) object;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
private static final int SYNC_FLAG_OFFSET = 14;
private static final int REMOVE_FLAG_OFFSET = 12;
- public PCEPLspObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPLspObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public LspObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, 2, 2));
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof LspObject))
+ if (!(object instanceof LspObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed LspObject.");
+ }
final LspObject specObj = (LspObject) object;
retBytes[0] = (byte) (lspID >> 12);
retBytes[1] = (byte) (lspID >> 4);
retBytes[2] = (byte) (lspID << 4);
- if (specObj.isDelegate())
+ if (specObj.isDelegate()) {
retBytes[3] |= 1 << (Byte.SIZE - (DELEGATE_FLAG_OFFSET - Byte.SIZE) - 1);
+ }
// FIXME: !!
// if (specObj.isOperational())
// retBytes[3] |= 1 << (Byte.SIZE - (OPERATIONAL_FLAG_OFFSET - Byte.SIZE) - 1);
- if (specObj.isRemove())
+ if (specObj.isRemove()) {
retBytes[3] |= 1 << (Byte.SIZE - (REMOVE_FLAG_OFFSET - Byte.SIZE) - 1);
- if (specObj.isSync())
+ }
+ if (specObj.isSync()) {
retBytes[3] |= 1 << (Byte.SIZE - (SYNC_FLAG_OFFSET - Byte.SIZE) - 1);
+ }
// ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspaObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
public static final int FLAGS_F_OFFSET = HOLD_PRIO_F_OFFSET + HOLD_PRIO_F_LENGTH;
public static final int TLVS_F_OFFSET = FLAGS_F_OFFSET + FLAGS_F_LENGTH + 1; // added reserved field of length 1B
- public PCEPLspaObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPLspaObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public LspaObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null)
+ if (bytes == null) {
throw new IllegalArgumentException("Bytes array is mandatory.");
+ }
final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, FLAGS_F_OFFSET, FLAGS_F_LENGTH));
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof LspaObject))
+ if (!(object instanceof LspaObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed LspaObject.");
+ }
final LspaObject lspaObj = (LspaObject) object;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ieee754.rev130819.Float32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.MetricObject;
public static final int SIZE = METRIC_VALUE_F_OFFSET + METRIC_VALUE_F_LENGTH;
- public PCEPMetricObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPMetricObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public MetricObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
- if (bytes.length != SIZE)
+ }
+ if (bytes.length != SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: " + SIZE + ".");
+ }
final byte[] flagBytes = { bytes[FLAGS_F_OFFSET] };
final BitSet flags = ByteArray.bytesToBitSet(flagBytes);
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof MetricObject))
+ if (!(object instanceof MetricObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed MetricObject.");
+ }
final MetricObject mObj = (MetricObject) object;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.impl.Util;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.pcrep.pcrep.message.replies.result.failure.NoPath;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.pcrep.pcrep.message.replies.result.failure.no.path.Tlvs;
public static final int C_FLAG_OFFSET = 0;
- public PCEPNoPathObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPNoPathObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public NoPathObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, FLAGS_F_OFFSET, FLAGS_F_LENGTH));
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof NoPathObject))
+ if (!(object instanceof NoPathObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed NoPathObject.");
+ }
final NoPathObject nPObj = (NoPathObject) object;
final byte[] tlvs = serializeTlvs(((NoPath) nPObj).getTlvs());
int tlvsLength = 0;
- if (tlvs != null)
+ if (tlvs != null) {
tlvsLength = tlvs.length;
+ }
final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
- if (tlvs != null)
+ if (tlvs != null) {
ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+ }
final BitSet flags = new BitSet(FLAGS_F_LENGTH * Byte.SIZE);
flags.set(C_FLAG_OFFSET, nPObj.isUnsatisfiedConstraints());
retBytes[NI_F_OFFSET] = ByteArray.shortToBytes(nPObj.getNatureOfIssue())[1];
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.impl.Util;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NotificationObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
public static final int NV_F_OFFSET = NT_F_OFFSET + NT_F_LENGTH;
public static final int TLVS_OFFSET = NV_F_OFFSET + NV_F_LENGTH;
- public PCEPNotificationObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPNotificationObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public NotificationObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
final NotificationsBuilder builder = new NotificationsBuilder();
@Override
public void addTlv(final NotificationsBuilder builder, final Tlv tlv) {
- if (tlv instanceof OverloadDurationTlv && builder.getType() == 2 && builder.getValue() == 1)
+ if (tlv instanceof OverloadDurationTlv && builder.getType() == 2 && builder.getValue() == 1) {
builder.setTlvs(new TlvsBuilder().setOverloadDuration(
new OverloadDurationBuilder().setDuration(((OverloadDurationTlv) tlv).getDuration()).build()).build());
+ }
}
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof NotificationObject))
+ if (!(object instanceof NotificationObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed NotificationObject.");
+ }
final NotificationObject notObj = (NotificationObject) object;
final byte[] tlvs = serializeTlvs(notObj.getTlvs());
int tlvsLength = 0;
- if (tlvs != null)
+ if (tlvs != null) {
tlvsLength = tlvs.length;
+ }
final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
- if (tlvs != null)
+ if (tlvs != null) {
ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+ }
retBytes[NT_F_OFFSET] = ByteArray.shortToBytes(notObj.getType())[1];
retBytes[NV_F_OFFSET] = ByteArray.shortToBytes(notObj.getValue())[1];
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
public static final int OF_CODE_F_OFFSET = 0;
public static final int TLVS_OFFSET = OF_CODE_F_OFFSET + OF_CODE_F_LENGTH + 2; // added reserved field of size 2
- public PCEPObjectiveFunctionObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPObjectiveFunctionObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public OfObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
final OfBuilder builder = new OfBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof OfObject))
+ if (!(object instanceof OfObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
+ ". Needed PCEPObjectiveFunction.");
+ }
final OfObject specObj = (OfObject) object;
// FIXME
import org.opendaylight.protocol.pcep.PCEPErrors;
import org.opendaylight.protocol.pcep.impl.Util;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.LspDbVersionTlv;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
private static final int PCEP_VERSION = 1;
- public PCEPOpenObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPOpenObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public OpenObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
final int versionValue = ByteArray.copyBitsRange(bytes[VER_FLAGS_MF_OFFSET], VERSION_SF_OFFSET, VERSION_SF_LENGTH);
- if (versionValue != PCEP_VERSION)
+ if (versionValue != PCEP_VERSION) {
throw new PCEPDocumentedException("Unsupported PCEP version " + versionValue, PCEPErrors.PCEP_VERSION_NOT_SUPPORTED);
+ }
final OpenBuilder builder = new OpenBuilder();
@Override
public void addTlv(final OpenBuilder builder, final Tlv tlv) {
final TlvsBuilder tbuilder = new TlvsBuilder();
- if (tlv instanceof OfListTlv)
+ if (tlv instanceof OfListTlv) {
tbuilder.setOfList(new OfListBuilder().setCodes(((OfListTlv) tlv).getCodes()).build());
- else if (tlv instanceof StatefulCapabilityTlv)
+ } else if (tlv instanceof StatefulCapabilityTlv) {
tbuilder.setStateful(new StatefulBuilder().setFlags(((StatefulCapabilityTlv) tlv).getFlags()).build());
- else if (tlv instanceof PredundancyGroupIdTlv)
+ } else if (tlv instanceof PredundancyGroupIdTlv) {
tbuilder.setPredundancyGroupId(new PredundancyGroupIdBuilder().setIdentifier(((PredundancyGroupIdTlv) tlv).getIdentifier()).build());
- else if (tlv instanceof LspDbVersionTlv)
+ } else if (tlv instanceof LspDbVersionTlv) {
tbuilder.setLspDbVersion(new LspDbVersionBuilder().build());
+ }
builder.setTlvs(tbuilder.build());
}
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof OpenObject))
+ if (!(object instanceof OpenObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed OpenObject.");
+ }
final OpenObject open = (OpenObject) object;
final byte versionFlagMF = (byte) (PCEP_VERSION << (Byte.SIZE - VERSION_SF_LENGTH));
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PathKeyObject;
public static final int TYPE = 1;
- public PCEPPathKeyObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPPathKeyObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public PathKeyObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
+ PCEPDocumentedException {
// FIXME : finish
final PathKeyBuilder builder = new PathKeyBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof PathKeyObject))
+ if (!(object instanceof PathKeyObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed PathKeyObject.");
+ }
final PathKeyObject pkey = (PathKeyObject) object;
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ReportedRouteObject;
public static final int TYPE = 1;
- public PCEPReportedRouteObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPReportedRouteObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public ReportedRouteObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException,
- PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ PCEPDocumentedException {
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Byte array is mandatory. Can't be null or empty.");
+ }
final ReportedRouteBuilder builder = new ReportedRouteBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof ReportedRouteObject))
+ if (!(object instanceof ReportedRouteObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass()
+ ". Needed ReportedRouteObject.");
+ }
assert !(((ReportedRouteObject) object).getSubobjects().isEmpty()) : "Empty Reported Route Object.";
// FIXME add subobjects
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.impl.Util;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
private static int E_FLAG_OFFSET = 20;
- public PCEPRequestParameterObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPRequestParameterObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public RpObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
final BitSet flags = ByteArray.bytesToBitSet(Arrays.copyOfRange(bytes, FLAGS_PRI_MF_OFFSET, FLAGS_PRI_MF_OFFSET
+ FLAGS_PRI_MF_LENGTH));
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof RpObject))
+ if (!(object instanceof RpObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed RpObject.");
+ }
final RpObject rPObj = (RpObject) object;
final byte[] tlvs = serializeTlvs(rPObj.getTlvs());
int tlvsLength = 0;
- if (tlvs != null)
+ if (tlvs != null) {
tlvsLength = tlvs.length;
+ }
final byte[] retBytes = new byte[TLVS_OFFSET + tlvsLength + Util.getPadding(TLVS_OFFSET + tlvs.length, PADDED_TO)];
- if (tlvs != null)
+ if (tlvs != null) {
ByteArray.copyWhole(tlvs, retBytes, TLVS_OFFSET);
+ }
ByteArray.copyWhole(ByteArray.bitSetToBytes(flags_priority, FLAGS_PRI_MF_LENGTH), retBytes, FLAGS_PRI_MF_OFFSET);
ByteArray.copyWhole(ByteArray.subByte(ByteArray.longToBytes(rPObj.getRequestId().getValue()), (Long.SIZE / Byte.SIZE)
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.SrpObject;
public static final int TYPE = 1;
- public PCEPSrpObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPSrpObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof SrpObject))
+ if (!(object instanceof SrpObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed SrpObject.");
+ }
final SrpObject srp = (SrpObject) object;
// FIXME: finish
import org.opendaylight.protocol.pcep.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.PCEPDocumentedException;
import org.opendaylight.protocol.pcep.spi.AbstractObjectParser;
-import org.opendaylight.protocol.pcep.spi.HandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.SubobjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
import org.opendaylight.protocol.util.ByteArray;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
*/
public static final int MIN_SIZE = FLAGS_F_LENGTH + FLAGS_F_OFFSET;
- public PCEPSvecObjectParser(final HandlerRegistry registry) {
- super(registry);
+ public PCEPSvecObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ super(subobjReg, tlvReg);
}
@Override
public SvecObject parseObject(final ObjectHeader header, final byte[] bytes) throws PCEPDeserializerException, PCEPDocumentedException {
- if (bytes == null || bytes.length == 0)
+ if (bytes == null || bytes.length == 0) {
throw new IllegalArgumentException("Array of bytes is mandatory. Can't be null or empty.");
+ }
- if (bytes.length < MIN_SIZE)
+ if (bytes.length < MIN_SIZE) {
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + bytes.length + "; Expected: >=" + MIN_SIZE
+ ".");
+ }
final BitSet flags = ByteArray.bytesToBitSet(ByteArray.subByte(bytes, FLAGS_F_OFFSET, FLAGS_F_LENGTH));
final List<RequestId> requestIDs = Lists.newArrayList();
requestIDs.add(new RequestId(ByteArray.bytesToLong(ByteArray.subByte(bytes, i, REQ_LIST_ITEM_LENGTH))));
}
- if (requestIDs.isEmpty())
+ if (requestIDs.isEmpty()) {
throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
+ }
final SvecBuilder builder = new SvecBuilder();
@Override
public byte[] serializeObject(final Object object) {
- if (!(object instanceof SvecObject))
+ if (!(object instanceof SvecObject)) {
throw new IllegalArgumentException("Wrong instance of PCEPObject. Passed " + object.getClass() + ". Needed SvecObject.");
+ }
final SvecObject svecObj = (SvecObject) object;
final byte[] retBytes = new byte[svecObj.getRequestsIds().size() * REQ_LIST_ITEM_LENGTH + REQ_ID_LIST_OFFSET];
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.primitives.UnsignedBytes;
private final static int P_FLAG_OFFSET = 6;
private final static int I_FLAG_OFFSET = 7;
- private final HandlerRegistry registry;
+ private final ObjectHandlerRegistry registry;
- protected AbstractMessageParser(final HandlerRegistry registry) {
- this.registry = registry;
+ protected AbstractMessageParser(final ObjectHandlerRegistry registry) {
+ this.registry = Preconditions.checkNotNull(registry);
}
protected byte[] serializeObject(final Object object) {
- if (object == null)
+ if (object == null) {
throw new IllegalArgumentException("Null object passed.");
+ }
final ObjectSerializer serializer = this.registry.getObjectSerializer(object);
// objType_flags multi-field
retBytes[OT_FLAGS_MF_OFFSET] = (byte) (serializer.getObjectType() << (Byte.SIZE - OT_SF_LENGTH));
- if (object.isProcessingRule())
+ if (object.isProcessingRule()) {
retBytes[OT_FLAGS_MF_OFFSET] |= 1 << Byte.SIZE - (P_FLAG_OFFSET) - 1;
- if (object.isIgnore())
+ }
+ if (object.isIgnore()) {
retBytes[OT_FLAGS_MF_OFFSET] |= 1 << Byte.SIZE - (I_FLAG_OFFSET) - 1;
+ }
// objLength
System.arraycopy(ByteArray.intToBytes(valueBytes.length), Integer.SIZE / Byte.SIZE - OBJ_LENGTH_F_LENGTH, retBytes,
int offset = 0;
final List<Object> objs = Lists.newArrayList();
while (bytes.length - offset > 0) {
- if (bytes.length - offset < COMMON_OBJECT_HEADER_LENGTH)
+ if (bytes.length - offset < COMMON_OBJECT_HEADER_LENGTH) {
throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + (bytes.length - offset) + " Expected: >= "
+ COMMON_OBJECT_HEADER_LENGTH + ".");
+ }
final int objClass = ByteArray.bytesToInt(Arrays.copyOfRange(bytes, OC_F_OFFSET, OC_F_OFFSET + OC_F_LENGTH));
final BitSet flags = ByteArray.bytesToBitSet(flagsBytes);
- if (bytes.length - offset < objLength)
+ if (bytes.length - offset < objLength) {
throw new PCEPDeserializerException("Too few bytes in passed array. Passed: " + (bytes.length - offset) + " Expected: >= "
+ objLength + ".");
+ }
// copy bytes for deeper parsing
final byte[] bytesToPass = ByteArray.subByte(bytes, offset + COMMON_OBJECT_HEADER_LENGTH, objLength
if (e.getError() == PCEPErrors.UNRECOGNIZED_OBJ_CLASS | e.getError() == PCEPErrors.UNRECOGNIZED_OBJ_TYPE
| e.getError() == PCEPErrors.NOT_SUPPORTED_OBJ_CLASS | e.getError() == PCEPErrors.NOT_SUPPORTED_OBJ_TYPE) {
objs.add(new UnknownObject(e.getError()));
- } else
+ } else {
throw e;
+ }
}
}
return objs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
protected static final int PADDED_TO = 4;
- private final HandlerRegistry registry;
+ private final SubobjectHandlerRegistry subobjReg;
+ private final TlvHandlerRegistry tlvReg;
- protected AbstractObjectParser(final HandlerRegistry registry) {
- this.registry = registry;
+ protected AbstractObjectParser(final SubobjectHandlerRegistry subobjReg, final TlvHandlerRegistry tlvReg) {
+ this.subobjReg = Preconditions.checkNotNull(subobjReg);
+ this.tlvReg = Preconditions.checkNotNull(tlvReg);
}
protected final void parseTlvs(final BUILDER builder, final byte[] bytes) throws PCEPDeserializerException {
- if (bytes == null)
+ if (bytes == null) {
throw new IllegalArgumentException("Byte array is mandatory.");
+ }
int length;
int byteOffset = 0;
length = ByteArray.bytesToInt(ByteArray.subByte(bytes, byteOffset, TLV_LENGTH_F_LENGTH));
byteOffset += TLV_LENGTH_F_LENGTH;
- if (TLV_HEADER_LENGTH + length > bytes.length - byteOffset)
+ if (TLV_HEADER_LENGTH + length > bytes.length - byteOffset) {
throw new PCEPDeserializerException("Wrong length specified. Passed: " + (TLV_HEADER_LENGTH + length) + "; Expected: <= "
+ (bytes.length - byteOffset) + ".");
+ }
final byte[] tlvBytes = ByteArray.subByte(bytes, byteOffset, length);
logger.trace("Attempt to parse tlv from bytes: {}", ByteArray.bytesToHexString(tlvBytes));
- final Tlv tlv = this.registry.getTlvParser(type).parseTlv(tlvBytes);
+ final Tlv tlv = this.tlvReg.getTlvParser(type).parseTlv(tlvBytes);
logger.trace("Tlv was parsed. {}", tlv);
addTlv(builder, tlv);
protected final byte[] serializeTlv(final Tlv tlv) {
- final TlvSerializer serializer = this.registry.getTlvSerializer(tlv);
+ final TlvSerializer serializer = this.tlvReg.getTlvSerializer(tlv);
final byte[] typeBytes = (ByteArray.cutBytes(ByteArray.intToBytes(serializer.getType()), (Integer.SIZE / 8) - TLV_TYPE_F_LENGTH));
}
protected final void parseSubobjects(final BUILDER builder, final byte[] bytes) throws PCEPDeserializerException {
- if (bytes == null)
+ if (bytes == null) {
throw new IllegalArgumentException("Byte array is mandatory.");
+ }
boolean loose_flag = false;
int type;
type = (bytes[offset + TYPE_FLAG_F_OFFSET] & 0xff) & ~(1 << 7);
- if (length > bytes.length - offset)
+ if (length > bytes.length - offset) {
throw new PCEPDeserializerException("Wrong length specified. Passed: " + length + "; Expected: <= "
+ (bytes.length - offset));
+ }
soContentsBytes = new byte[length - SO_CONTENTS_OFFSET];
System.arraycopy(bytes, offset + SO_CONTENTS_OFFSET, soContentsBytes, 0, length - SO_CONTENTS_OFFSET);
logger.debug("Attempt to parse subobject from bytes: {}", ByteArray.bytesToHexString(soContentsBytes));
- final CSubobject subObj = this.registry.getSubobjectParser(type).parseSubobject(soContentsBytes);
+ final CSubobject subObj = this.subobjReg.getSubobjectParser(type).parseSubobject(soContentsBytes);
logger.debug("Subobject was parsed. {}", subObj);
subs.put(subObj, loose_flag);
final CSubobject subobject = entry.getKey();
- final SubobjectSerializer serializer = this.registry.getSubobjectSerializer(subobject);
+ final SubobjectSerializer serializer = this.subobjReg.getSubobjectSerializer(subobject);
final byte[] valueBytes = serializer.serializeSubobject(subobject);
+++ /dev/null
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.spi;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
-
-public interface HandlerRegistry {
- public AutoCloseable registerMessageParser(int messageType, MessageParser parser);
- public MessageParser getMessageParser(int messageType);
-
- public AutoCloseable registerMessageSerializer(Class<? extends Message> msgClass, MessageSerializer serializer);
- public MessageSerializer getMessageSerializer(Message message);
-
- public AutoCloseable registerObjectParser(int objectClass, int objectType, ObjectParser parser);
- public ObjectParser getObjectParser(int objectClass, int objectType);
-
- public AutoCloseable registerObjectSerializer(Class<? extends Object> objClass, ObjectSerializer serializer);
- public ObjectSerializer getObjectSerializer(Object object);
-
- public AutoCloseable registerTlvParser(int tlvType, TlvParser parser);
- public TlvParser getTlvParser(int tlvType);
-
- public AutoCloseable registerTlvSerializer(Class<? extends Tlv> tlvClass, TlvSerializer serializer);
- public TlvSerializer getTlvSerializer(Tlv tlv);
-
- public AutoCloseable registerSubobjectParser(int subobjectType, SubobjectParser parser);
- public SubobjectParser getSubobjectParser(int subobjectType);
-
- public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, SubobjectSerializer serializer);
- public SubobjectSerializer getSubobjectSerializer(CSubobject subobject);
-}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+public interface MessageHandlerRegistry {
+ public AutoCloseable registerMessageParser(int messageType, MessageParser parser);
+ public AutoCloseable registerMessageSerializer(Class<? extends Message> msgClass, MessageSerializer serializer);
+
+ public MessageParser getMessageParser(int messageType);
+ public MessageSerializer getMessageSerializer(Message message);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
+
+public interface ObjectHandlerRegistry {
+ public AutoCloseable registerObjectParser(int objectClass, int objectType, ObjectParser parser);
+ public AutoCloseable registerObjectSerializer(Class<? extends Object> objClass, ObjectSerializer serializer);
+
+ public ObjectParser getObjectParser(int objectClass, int objectType);
+ public ObjectSerializer getObjectSerializer(Object object);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.CSubobject;
+
+public interface SubobjectHandlerRegistry {
+ public AutoCloseable registerSubobjectParser(int subobjectType, SubobjectParser parser);
+ public SubobjectParser getSubobjectParser(int subobjectType);
+
+ public AutoCloseable registerSubobjectSerializer(Class<? extends CSubobject> subobjectClass, SubobjectSerializer serializer);
+ public SubobjectSerializer getSubobjectSerializer(CSubobject subobject);
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.protocol.pcep.spi;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
+
+public interface TlvHandlerRegistry {
+ public AutoCloseable registerTlvParser(int tlvType, TlvParser parser);
+ public TlvParser getTlvParser(int tlvType);
+
+ public AutoCloseable registerTlvSerializer(Class<? extends Tlv> tlvClass, TlvSerializer serializer);
+ public TlvSerializer getTlvSerializer(Tlv tlv);
+}
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.impl.PCEPHandlerFactory;
import org.opendaylight.protocol.pcep.impl.PCEPSessionImpl;
+import org.opendaylight.protocol.pcep.impl.SimpleMessageHandlerFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.open.message.OpenBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new OpenBuilder().setKeepalive(
(short) 30).setDeadTimer((short) 120).setSessionId((short) 0).setTlvs(builder.build()).build(), 0);
- final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
+ final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf,
+ new PCEPHandlerFactory(SimpleMessageHandlerFactory.INSTANCE),
+ new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
pcc.createClient(new InetSocketAddress("127.0.0.3", 12345), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000),
new SessionListenerFactory<PCEPSessionListener>() {
- @Override
- public PCEPSessionListener getSessionListener() {
- return new SimpleSessionListener();
- }
- }).get();
+ @Override
+ public PCEPSessionListener getSessionListener() {
+ return new SimpleSessionListener();
+ }
+ }).get();
}
}