Setting stateful02 to be primary draft version. 37/5137/6
authorDana Kutenicsova <dkutenic@cisco.com>
Wed, 5 Feb 2014 21:23:31 +0000 (22:23 +0100)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 6 Feb 2014 21:12:09 +0000 (21:12 +0000)
Change-Id: I67cabb804da2fc10cf52f996b407822e9c89e5d6
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
concepts/src/main/java/org/opendaylight/protocol/concepts/MultiRegistry.java
pcep/ietf-stateful02/pom.xml
pcep/ietf-stateful02/src/main/java/org/opendaylight/protocol/pcep/crabbe/initiated00/InitiatedActivator.java
pcep/ietf-stateful02/src/main/java/org/opendaylight/protocol/pcep/crabbe/initiated00/PCEStatefulCapabilityTlvParser.java
pcep/ietf-stateful02/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPObjectParserTest.java [new file with mode: 0644]
pcep/ietf-stateful02/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPTlvParserTest.java [new file with mode: 0644]
pcep/ietf-stateful02/src/test/resources/PCEPOpenMessage1.bin [new file with mode: 0755]
pcep/ietf-stateful02/src/test/resources/PCEPOpenObject1.bin [new file with mode: 0644]
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/PCEPOpenMessageParser.java [deleted file]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractMessageParser.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/AbstractObjectWithTlvsParser.java

index 17675e7510264a757bb617e3d286120aa9ba4615..28529bca78c75bd4f6b4fbf13644c8b3938f3b48 100644 (file)
@@ -84,6 +84,6 @@ public final class MultiRegistry<K, V> {
        }
 
        public V get(final K key) {
-               return current.get(key);
+               return this.current.get(key);
        }
 }
index 68d6ef881984c203e1e8d36e7b9c93c9710e7597..91dd4172d97c443a15ecf49431c1d086e5955334 100644 (file)
             <groupId>org.opendaylight.yangtools.model</groupId>
             <artifactId>ietf-inet-types</artifactId>
         </dependency>
+        
+         <!--test dependencies -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
     </dependencies>
 
     <build>
index 9e1db04738e36c537b2d7c98ac2989bea6dcdb6d..c353dc0eb98f79ea3ddb295422bab10b03416929 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
 import org.opendaylight.protocol.pcep.spi.pojo.AbstractPCEPExtensionProviderActivator;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.Pcinitiate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.lsp.cleanup.tlv.LspCleanup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.stateful.capability.tlv.Stateful;
 
 public class InitiatedActivator extends AbstractPCEPExtensionProviderActivator {
        @Override
@@ -28,7 +29,7 @@ public class InitiatedActivator extends AbstractPCEPExtensionProviderActivator {
                regs.add(context.registerTlvSerializer(LspCleanup.class, new LSPCleanupTlvParser()));
 
                regs.add(context.registerTlvParser(PCEStatefulCapabilityTlvParser.TYPE, new PCEStatefulCapabilityTlvParser()));
-               // regs.add(context.registerTlvSerializer(Stateful.class, new PCEStatefulCapabilityTlvParser()));
+               regs.add(context.registerTlvSerializer(Stateful.class, new PCEStatefulCapabilityTlvParser()));
 
                return regs;
        }
index aebf246869583c823bb4b520e31caff57a41d1e2..9badab21cbde656aada9f178423a0fd1b106e82a 100644 (file)
@@ -68,10 +68,12 @@ public final class PCEStatefulCapabilityTlvParser implements TlvParser, TlvSeria
                if (sfi != null) {
                        flags.set(I_FLAG_OFFSET, sfi.isInitiation());
                }
-
-               flags.set(U_FLAG_OFFSET, sct.isLspUpdateCapability());
-               flags.set(S_FLAG_OFFSET, sct.isIncludeDbVersion());
-
+               if (sct.isLspUpdateCapability() != null && sct.isLspUpdateCapability()) {
+                       flags.set(U_FLAG_OFFSET, sct.isLspUpdateCapability());
+               }
+               if (sct.isIncludeDbVersion() != null && sct.isIncludeDbVersion()) {
+                       flags.set(S_FLAG_OFFSET, sct.isIncludeDbVersion());
+               }
                return ByteArray.bitSetToBytes(flags, FLAGS_F_LENGTH);
        }
 
diff --git a/pcep/ietf-stateful02/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPObjectParserTest.java b/pcep/ietf-stateful02/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPObjectParserTest.java
new file mode 100644 (file)
index 0000000..757fd69
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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.ietf;
+
+import static org.junit.Assert.assertArrayEquals;
+
+import java.io.IOException;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.protocol.pcep.ietf.stateful02.PCEPOpenObjectParser;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
+import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.Stateful1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated._00.rev140113.Stateful1Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.Tlvs2;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.Tlvs2Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.stateful.capability.tlv.Stateful;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.stateful.capability.tlv.StatefulBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ProtocolVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
+
+public class PCEPObjectParserTest {
+
+       private TlvHandlerRegistry tlvRegistry;
+
+       @Before
+       public void setUp() throws Exception {
+               this.tlvRegistry = ServiceLoaderPCEPExtensionProviderContext.create().getTlvHandlerRegistry();
+       }
+
+       @Test
+       public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
+               final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry);
+               final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin");
+
+               final OpenBuilder builder = new OpenBuilder();
+               builder.setProcessingRule(false);
+               builder.setIgnore(false);
+               builder.setVersion(new ProtocolVersion((short) 1));
+               builder.setKeepalive((short) 30);
+               builder.setDeadTimer((short) 120);
+               builder.setSessionId((short) 1);
+
+               final Stateful tlv1 = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).setIncludeDbVersion(Boolean.FALSE).addAugmentation(
+                               Stateful1.class, new Stateful1Builder().setInitiation(true).build()).build();
+
+               final Tlvs2Builder statBuilder = new Tlvs2Builder();
+               statBuilder.setStateful(tlv1);
+
+               builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().addAugmentation(
+                               Tlvs2.class, statBuilder.build()).build());
+
+               // FIXME: enable once the registry is rewritten
+               // assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
+               // ByteArray.cutBytes(result, 4)));
+               // assertArrayEquals(result, parser.serializeObject(builder.build()));
+       }
+
+       @Test
+       public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
+               // final PCEPLspObjectParser parser = new PCEPLspObjectParser(this.tlvRegistry);
+               // final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPLspObject1WithTLV.bin");
+               //
+               // final LspBuilder builder = new LspBuilder();
+               // builder.setProcessingRule(true);
+               // builder.setIgnore(true);
+               // builder.setDelegate(false);
+               // builder.setRemove(true);
+               // builder.setSync(false);
+               //
+               // final LspErrorCode tlv1 = new LspErrorCodeBuilder().setErrorCode(627610883L).build();
+               // final SymbolicPathName tlv2 = new SymbolicPathNameBuilder().setPathName(
+               // new
+               // org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.SymbolicPathName("Med".getBytes())).build();
+               // builder.setTlvs(new
+               // org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.TlvsBuilder().setLspErrorCode(
+               // tlv1).setSymbolicPathName(tlv2).build());
+               // assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), ByteArray.cutBytes(result,
+               // 4)));
+               // assertArrayEquals(result, parser.serializeObject(builder.build()));
+       }
+}
diff --git a/pcep/ietf-stateful02/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPTlvParserTest.java b/pcep/ietf-stateful02/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPTlvParserTest.java
new file mode 100644 (file)
index 0000000..2619285
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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.ietf;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.protocol.concepts.Ipv4Util;
+import org.opendaylight.protocol.concepts.Ipv6Util;
+import org.opendaylight.protocol.pcep.ietf.stateful02.LspSymbolicNameTlvParser;
+import org.opendaylight.protocol.pcep.ietf.stateful02.PCEStatefulCapabilityTlvParser;
+import org.opendaylight.protocol.pcep.ietf.stateful02.RSVPErrorSpecTlvParser;
+import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.iana.rev130816.EnterpriseNumber;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.rsvp.error.spec.tlv.RsvpErrorSpec;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.rsvp.error.spec.tlv.RsvpErrorSpecBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.rsvp.error.spec.tlv.rsvp.error.spec.error.type.RsvpCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.rsvp.error.spec.tlv.rsvp.error.spec.error.type.UserCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.rsvp.error.spec.tlv.rsvp.error.spec.error.type.rsvp._case.RsvpErrorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.rsvp.error.spec.tlv.rsvp.error.spec.error.type.user._case.UserErrorBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.stateful.capability.tlv.Stateful;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.stateful.capability.tlv.StatefulBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.symbolic.path.name.tlv.SymbolicPathName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.symbolic.path.name.tlv.SymbolicPathNameBuilder;
+
+public class PCEPTlvParserTest {
+
+       private static final byte[] statefulBytes = { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
+       private static final byte[] symbolicNameBytes = { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65,
+                       (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d,
+                       (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d,
+                       (byte) 0x65 };
+       private static final byte[] rsvpErrorBytes = { (byte) 0x06, (byte) 0x01, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
+                       (byte) 0x02, (byte) 0x92, (byte) 0x16, (byte) 0x02 };
+       private static final byte[] rsvpError6Bytes = { (byte) 0x06, (byte) 0x02, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
+                       (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a,
+                       (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x02, (byte) 0xd5, (byte) 0xc5, (byte) 0xd9 };
+       private static final byte[] userErrorBytes = { (byte) 0xc2, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x30, (byte) 0x39,
+                       (byte) 0x05, (byte) 0x09, (byte) 0x00, (byte) 0x26, (byte) 0x75, (byte) 0x73, (byte) 0x65, (byte) 0x72, (byte) 0x20,
+                       (byte) 0x64, (byte) 0x65, (byte) 0x73, (byte) 0x63 };
+
+       @Test
+       public void testStatefulTlv() throws PCEPDeserializerException {
+               final PCEStatefulCapabilityTlvParser parser = new PCEStatefulCapabilityTlvParser();
+               final Stateful tlv = new StatefulBuilder().setLspUpdateCapability(Boolean.TRUE).setIncludeDbVersion(false).build();
+               assertEquals(tlv, parser.parseTlv(statefulBytes));
+               assertArrayEquals(statefulBytes, parser.serializeTlv(tlv));
+       }
+
+       @Test
+       public void testSymbolicNameTlv() throws PCEPDeserializerException {
+               final LspSymbolicNameTlvParser parser = new LspSymbolicNameTlvParser();
+               final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(
+                               new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.stateful._02.rev140110.SymbolicPathName("Med test of symbolic name".getBytes())).build();
+               assertEquals(tlv, parser.parseTlv(symbolicNameBytes));
+               assertArrayEquals(symbolicNameBytes, parser.serializeTlv(tlv));
+       }
+
+       @Test
+       public void testRSVPError4SpecTlv() throws PCEPDeserializerException {
+               final RSVPErrorSpecTlvParser parser = new RSVPErrorSpecTlvParser();
+               final RsvpErrorBuilder builder = new RsvpErrorBuilder();
+               builder.setNode(new IpAddress(Ipv4Util.addressForBytes(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 })));
+               builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ErrorSpec.Flags(false, true));
+               builder.setCode((short) 146);
+               builder.setValue(5634);
+               final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new RsvpCaseBuilder().setRsvpError(builder.build()).build()).build();
+               assertEquals(tlv, parser.parseTlv(rsvpErrorBytes));
+               assertArrayEquals(rsvpErrorBytes, parser.serializeTlv(tlv));
+       }
+
+       @Test
+       public void testRSVPError6SpecTlv() throws PCEPDeserializerException {
+               final RSVPErrorSpecTlvParser parser = new RSVPErrorSpecTlvParser();
+               final RsvpErrorBuilder builder = new RsvpErrorBuilder();
+               builder.setNode(new IpAddress(Ipv6Util.addressForBytes(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78,
+                               (byte) 0x9a, (byte) 0xbc, (byte) 0xde, (byte) 0xf0, (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9a,
+                               (byte) 0xbc, (byte) 0xde, (byte) 0xf0 })));
+               builder.setFlags(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.ErrorSpec.Flags(false, true));
+               builder.setCode((short) 213);
+               builder.setValue(50649);
+               final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new RsvpCaseBuilder().setRsvpError(builder.build()).build()).build();
+               assertEquals(tlv, parser.parseTlv(rsvpError6Bytes));
+               assertArrayEquals(rsvpError6Bytes, parser.serializeTlv(tlv));
+       }
+
+       @Test
+       public void testUserErrorSpecTlv() throws PCEPDeserializerException {
+               final RSVPErrorSpecTlvParser parser = new RSVPErrorSpecTlvParser();
+               final UserErrorBuilder builder = new UserErrorBuilder();
+               builder.setEnterprise(new EnterpriseNumber(12345L));
+               builder.setSubOrg((short) 5);
+               builder.setValue(38);
+               builder.setDescription("user desc");
+               final RsvpErrorSpec tlv = new RsvpErrorSpecBuilder().setErrorType(new UserCaseBuilder().setUserError(builder.build()).build()).build();
+               assertEquals(tlv, parser.parseTlv(userErrorBytes));
+               assertArrayEquals(userErrorBytes, parser.serializeTlv(tlv));
+       }
+}
diff --git a/pcep/ietf-stateful02/src/test/resources/PCEPOpenMessage1.bin b/pcep/ietf-stateful02/src/test/resources/PCEPOpenMessage1.bin
new file mode 100755 (executable)
index 0000000..388f098
Binary files /dev/null and b/pcep/ietf-stateful02/src/test/resources/PCEPOpenMessage1.bin differ
diff --git a/pcep/ietf-stateful02/src/test/resources/PCEPOpenObject1.bin b/pcep/ietf-stateful02/src/test/resources/PCEPOpenObject1.bin
new file mode 100644 (file)
index 0000000..9d1152b
Binary files /dev/null and b/pcep/ietf-stateful02/src/test/resources/PCEPOpenObject1.bin differ
diff --git a/pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/PCEPOpenMessageParser.java b/pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/PCEPOpenMessageParser.java
deleted file mode 100644 (file)
index 3303bea..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.ietf.stateful07;
-
-import io.netty.buffer.ByteBuf;
-
-import java.util.List;
-
-import org.opendaylight.protocol.pcep.spi.AbstractMessageParser;
-import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
-import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder;
-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;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-
-/**
- * Parser for {@link OpenMessage}
- */
-public class PCEPOpenMessageParser extends AbstractMessageParser {
-
-       public static final int TYPE = 1;
-
-       public PCEPOpenMessageParser(final ObjectHandlerRegistry registry) {
-               super(registry);
-       }
-
-       @Override
-       public void serializeMessage(final Message message, final ByteBuf buffer) {
-               if (!(message instanceof OpenMessage)) {
-                       throw new IllegalArgumentException("Wrong instance of Message. Passed instance " + message.getClass() + ". Needed 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) {
-                       throw new IllegalArgumentException("Open Object must be present in Open Message.");
-               }
-
-               buffer.writeBytes(serializeObject(open.getOpen()));
-       }
-
-       @Override
-       protected org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
-               if (objects == null) {
-                       throw new IllegalArgumentException("Passed list can't be null.");
-               }
-
-               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()) {
-                       throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
-               }
-
-               return new OpenBuilder().setOpenMessage(msg).build();
-       }
-
-       @Override
-       public int getMessageType() {
-               return TYPE;
-       }
-}
index e999bf3c99d822699bb0097cf6ef29a24a529951..8d865e3f777bfc113e065512db93a6dad578fc64 100644 (file)
@@ -23,6 +23,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.RequestBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.request._case.request.RpsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.Rp;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
@@ -30,6 +32,8 @@ import com.google.common.primitives.UnsignedBytes;
 
 public abstract class AbstractMessageParser implements MessageParser, MessageSerializer {
 
+       private static final Logger LOG = LoggerFactory.getLogger(AbstractMessageParser.class);
+
        private static final int COMMON_OBJECT_HEADER_LENGTH = 4;
 
        private static final int OC_F_LENGTH = 1;
@@ -60,6 +64,7 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
                        return new byte[] {};
                }
                final ObjectSerializer serializer = this.registry.getObjectSerializer(object);
+               LOG.trace("Choosen serializer {}", serializer);
                return serializer.serializeObject(object);
        }
 
index 9309d8a1e356274b7d33457a655e35c9693c6523..083949ed410fb1f2b959121e7f1b59d65f71993d 100644 (file)
@@ -71,6 +71,7 @@ public abstract class AbstractObjectWithTlvsParser<T> implements ObjectParser, O
        protected final byte[] serializeTlv(final Tlv tlv) {
 
                final TlvSerializer serializer = this.tlvReg.getTlvSerializer(tlv);
+               LOG.trace("Choosen serializer {}", serializer);
 
                final byte[] typeBytes = ByteArray.intToBytes(serializer.getType(), TLV_TYPE_F_LENGTH);