Bug-3075: BMP parser/serializer and registry APIs 89/21089/4
authorMilos Fabian <milfabia@cisco.com>
Tue, 26 May 2015 07:40:22 +0000 (09:40 +0200)
committerDana Kutenicsova <dkutenic@cisco.com>
Wed, 24 Jun 2015 07:24:43 +0000 (07:24 +0000)
-Java API for BMP message and TLV parsers/serializers
-Java API for BMP registry and extension consumer/provider

Change-Id: I4ea6fe6418b964bcf8976d85724d120efb128a5f
Signed-off-by: Milos Fabian <milfabia@cisco.com>
15 files changed:
bgp/bmp-spi/.project [new file with mode: 0644]
bgp/bmp-spi/pom.xml [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpDeserializationException.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageParser.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageSerializer.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvParser.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvSerializer.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionConsumerContext.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderActivator.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderContext.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistrator.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistry.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistrator.java [new file with mode: 0644]
bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistry.java [new file with mode: 0644]
bgp/pom.xml

diff --git a/bgp/bmp-spi/.project b/bgp/bmp-spi/.project
new file mode 100644 (file)
index 0000000..9058a9f
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>bgp-bmp-spi</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.m2e.core.maven2Builder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+               <nature>org.eclipse.m2e.core.maven2Nature</nature>
+       </natures>
+</projectDescription>
diff --git a/bgp/bmp-spi/pom.xml b/bgp/bmp-spi/pom.xml
new file mode 100644 (file)
index 0000000..1cd19bc
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2015 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
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/bgpcep.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main</url>
+        <tag>HEAD</tag>
+    </scm>
+    <parent>
+        <groupId>org.opendaylight.bgpcep</groupId>
+        <artifactId>bgp-parent</artifactId>
+        <version>0.5.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>bgp-bmp-spi</artifactId>
+    <description>BMP SPI</description>
+    <packaging>bundle</packaging>
+    <name>${project.artifactId}</name>
+    <prerequisites>
+        <maven>3.0.4</maven>
+    </prerequisites>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>bgp-bmp-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>bgp-parser-spi</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+    </dependencies>
+
+    <build>
+      <plugins>
+          <plugin>
+              <groupId>org.opendaylight.yangtools</groupId>
+              <artifactId>yang-maven-plugin</artifactId>
+          </plugin>
+          <plugin>
+              <groupId>org.apache.felix</groupId>
+              <artifactId>maven-bundle-plugin</artifactId>
+              <extensions>true</extensions>
+              <configuration>
+                  <instructions>
+                      <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+                  </instructions>
+              </configuration>
+          </plugin>
+      </plugins>
+  </build>
+
+</project>
\ No newline at end of file
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpDeserializationException.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpDeserializationException.java
new file mode 100644 (file)
index 0000000..c193935
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.parser;
+
+
+public class BmpDeserializationException extends Exception {
+
+    private static final long serialVersionUID = -7486453568941661756L;
+
+    /**
+     * Creates new BmpDeserializationException with specific error message.
+     * @param message message bound with this exception
+     */
+    public BmpDeserializationException(final String message) {
+        super(message, null);
+    }
+    /**
+     * @param message message bound with this exception
+     * @param cause   cause for the error
+     */
+    public BmpDeserializationException(final String message, final Throwable cause) {
+        super(message, cause);
+    }
+}
\ No newline at end of file
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageParser.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageParser.java
new file mode 100644 (file)
index 0000000..171e453
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.parser;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface BmpMessageParser {
+
+    Notification parseMessage(final ByteBuf bytes) throws BmpDeserializationException;
+
+}
\ No newline at end of file
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageSerializer.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageSerializer.java
new file mode 100644 (file)
index 0000000..46c6011
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.parser;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface BmpMessageSerializer {
+
+    void serializeMessage(final Notification message, final ByteBuf buffer);
+
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvParser.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvParser.java
new file mode 100644 (file)
index 0000000..73c0a7a
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.parser;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Tlv;
+
+public interface BmpTlvParser {
+
+    Tlv parseTlv(ByteBuf buffer) throws BmpDeserializationException ;
+
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvSerializer.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvSerializer.java
new file mode 100644 (file)
index 0000000..c651c31
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.parser;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Tlv;
+
+public interface BmpTlvSerializer {
+
+    void serializeTlv(Tlv tlv, ByteBuf output);
+
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionConsumerContext.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionConsumerContext.java
new file mode 100644 (file)
index 0000000..e915e88
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.registry;
+
+public interface BmpExtensionConsumerContext {
+
+    BmpMessageRegistry getBmpMessageRegistry();
+
+    BmpTlvRegistry getBmpStatisticsTlvRegistry();
+
+    BmpTlvRegistry getBmpInitiationTlvRegistry();
+
+    BmpTlvRegistry getBmpTerminationTlvRegistry();
+
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderActivator.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderActivator.java
new file mode 100644 (file)
index 0000000..a00a0ed
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.registry;
+
+public interface BmpExtensionProviderActivator {
+
+    void start(BmpExtensionProviderContext context);
+
+    void stop();
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderContext.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderContext.java
new file mode 100644 (file)
index 0000000..a7da8b8
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.registry;
+
+import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
+import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Tlv;
+
+public interface BmpExtensionProviderContext extends BmpMessageRegistrator, BmpExtensionConsumerContext {
+
+    AutoCloseable registerBmpStatisticsTlvParser(int tlvType, BmpTlvParser parser);
+
+    AutoCloseable registerBmpStatisticsTlvSerializer(Class<? extends Tlv> tlvClass, BmpTlvSerializer serializer);
+
+    AutoCloseable registerBmpInitiationTlvParser(int tlvType, BmpTlvParser parser);
+
+    AutoCloseable registerBmpInitiationTlvSerializer(Class<? extends Tlv> tlvClass, BmpTlvSerializer serializer);
+
+    AutoCloseable registerBmpTerminationTlvParser(int tlvType, BmpTlvParser parser);
+
+    AutoCloseable registerBmpTerminationTlvSerializer(Class<? extends Tlv> tlvClass, BmpTlvSerializer serializer);
+
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistrator.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistrator.java
new file mode 100644 (file)
index 0000000..ba67219
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.registry;
+
+import org.opendaylight.protocol.bmp.spi.parser.BmpMessageParser;
+import org.opendaylight.protocol.bmp.spi.parser.BmpMessageSerializer;
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface BmpMessageRegistrator {
+
+    AutoCloseable registerBmpMessageParser(int messageType, BmpMessageParser parser);
+
+    AutoCloseable registerBmpMessageSerializer(Class<? extends Notification> messageClass, BmpMessageSerializer serializer);
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistry.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistry.java
new file mode 100644 (file)
index 0000000..468a1e0
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.registry;
+
+import org.opendaylight.protocol.bmp.spi.parser.BmpMessageParser;
+import org.opendaylight.protocol.bmp.spi.parser.BmpMessageSerializer;
+
+public interface BmpMessageRegistry extends BmpMessageSerializer, BmpMessageParser, BmpMessageRegistrator {
+
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistrator.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistrator.java
new file mode 100644 (file)
index 0000000..a1ca235
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.registry;
+
+import org.opendaylight.protocol.bmp.spi.parser.BmpTlvParser;
+import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Tlv;
+
+public interface BmpTlvRegistrator {
+
+    AutoCloseable registerBmpTlvParser(int tlvType, BmpTlvParser parser);
+
+    AutoCloseable registerBmpTlvSerializer(Class<? extends Tlv> tlvClass, BmpTlvSerializer serializer);
+}
diff --git a/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistry.java b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistry.java
new file mode 100644 (file)
index 0000000..184b99f
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2015 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.bmp.spi.registry;
+
+import io.netty.buffer.ByteBuf;
+import org.opendaylight.protocol.bmp.spi.parser.BmpDeserializationException;
+import org.opendaylight.protocol.bmp.spi.parser.BmpTlvSerializer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev150512.Tlv;
+
+public interface BmpTlvRegistry extends BmpTlvSerializer, BmpTlvRegistrator {
+
+    Tlv parseTlv(int tlvType, ByteBuf buffer) throws BmpDeserializationException ;
+
+}
index 2fc1e5b78f207e262fb3ac5e4332471d7fb2e1fa..848fffba5862a3278bea7546d5ddab57c0f43736 100644 (file)
@@ -46,8 +46,8 @@
         <module>topology-provider</module>
         <module>util</module>
         <module>bmp-api</module>
+        <module>bmp-spi</module>
 
         <module>controller-config</module>
-
     </modules>
 </project>