From: Milos Fabian Date: Tue, 26 May 2015 07:40:22 +0000 (+0200) Subject: Bug-3075: BMP parser/serializer and registry APIs X-Git-Tag: release/beryllium~299 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=0de6075801baeb2da6620dd959930aa65fa77385;p=bgpcep.git Bug-3075: BMP parser/serializer and registry APIs -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 --- diff --git a/bgp/bmp-spi/.project b/bgp/bmp-spi/.project new file mode 100644 index 0000000000..9058a9fecd --- /dev/null +++ b/bgp/bmp-spi/.project @@ -0,0 +1,23 @@ + + + bgp-bmp-spi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/bgp/bmp-spi/pom.xml b/bgp/bmp-spi/pom.xml new file mode 100644 index 0000000000..1cd19bc7d0 --- /dev/null +++ b/bgp/bmp-spi/pom.xml @@ -0,0 +1,68 @@ + + + + + + 4.0.0 + + scm:git:ssh://git.opendaylight.org:29418/bgpcep.git + scm:git:ssh://git.opendaylight.org:29418/bgpcep.git + https://wiki.opendaylight.org/view/BGP_LS_PCEP:Main + HEAD + + + org.opendaylight.bgpcep + bgp-parent + 0.5.0-SNAPSHOT + + bgp-bmp-spi + BMP SPI + bundle + ${project.artifactId} + + 3.0.4 + + + + + ${project.groupId} + bgp-bmp-api + ${project.version} + + + ${project.groupId} + bgp-parser-spi + + + + junit + junit + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.groupId}.${project.artifactId} + + + + + + + \ 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 index 0000000000..c193935fad --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpDeserializationException.java @@ -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 index 0000000000..171e45324c --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageParser.java @@ -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 index 0000000000..46c6011ac8 --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpMessageSerializer.java @@ -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 index 0000000000..73c0a7a74c --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvParser.java @@ -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 index 0000000000..c651c31827 --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/parser/BmpTlvSerializer.java @@ -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 index 0000000000..e915e88c6b --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionConsumerContext.java @@ -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 index 0000000000..a00a0edfdd --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderActivator.java @@ -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 index 0000000000..a7da8b8116 --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpExtensionProviderContext.java @@ -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 tlvClass, BmpTlvSerializer serializer); + + AutoCloseable registerBmpInitiationTlvParser(int tlvType, BmpTlvParser parser); + + AutoCloseable registerBmpInitiationTlvSerializer(Class tlvClass, BmpTlvSerializer serializer); + + AutoCloseable registerBmpTerminationTlvParser(int tlvType, BmpTlvParser parser); + + AutoCloseable registerBmpTerminationTlvSerializer(Class 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 index 0000000000..ba6721902b --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistrator.java @@ -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 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 index 0000000000..468a1e06d0 --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpMessageRegistry.java @@ -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 index 0000000000..a1ca235118 --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistrator.java @@ -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 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 index 0000000000..184b99f8b8 --- /dev/null +++ b/bgp/bmp-spi/src/main/java/org/opendaylight/protocol/bmp/spi/registry/BmpTlvRegistry.java @@ -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 ; + +} diff --git a/bgp/pom.xml b/bgp/pom.xml index 2fc1e5b78f..848fffba58 100644 --- a/bgp/pom.xml +++ b/bgp/pom.xml @@ -46,8 +46,8 @@ topology-provider util bmp-api + bmp-spi controller-config -