From: Dana Kutenicsova Date: Mon, 11 Nov 2013 12:19:42 +0000 (+0000) Subject: Merge "BUG-108: rename routes objects to prevent confusion" X-Git-Tag: jenkins-bgpcep-bulk-release-prepare-only-1~237^2~52 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=a30ebb3fa33730c471c28977ab957a2dbef5dc4d;hp=89a722fd5161949e423034abd48a32fd354138d4;p=bgpcep.git Merge "BUG-108: rename routes objects to prevent confusion" --- diff --git a/bgp/pom.xml b/bgp/pom.xml index 41073eea18..99a6075f47 100644 --- a/bgp/pom.xml +++ b/bgp/pom.xml @@ -30,5 +30,9 @@ rib-mock topology-provider util - + rib-api-config + update-api-config + update-mock-config + rib-impl-config + diff --git a/bgp/rib-api-config/pom.xml b/bgp/rib-api-config/pom.xml new file mode 100644 index 0000000000..f5b2367979 --- /dev/null +++ b/bgp/rib-api-config/pom.xml @@ -0,0 +1,93 @@ + + + org.opendaylight.bgpcep + bgp-parent + 0.3.0-SNAPSHOT + + + 4.0.0 + bgp-rib-api-config + BGP RIB API CONFIG + bundle + ${project.artifactId} + + 3.0.4 + + + + + org.opendaylight.controller + config-api + ${controller.config.version} + + + ${project.groupId} + bgp-rib-api + ${project.version} + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${project.build.directory}/generated-sources/config + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${controller.config.version} + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.version} + true + + + ${project.groupId}.${project.artifactId} + + org.opendaylight.controller.config.yang.bgp.rib + + + + + + + + + + ${project.artifactId} + BGP-RIB-API-CONFIG Module site + ${basedir}/target/site/${project.artifactId} + + + + \ No newline at end of file diff --git a/bgp/rib-api-config/src/main/yang/bgp-rib.yang b/bgp/rib-api-config/src/main/yang/bgp-rib.yang new file mode 100644 index 0000000000..7a20fe1bf0 --- /dev/null +++ b/bgp/rib-api-config/src/main/yang/bgp-rib.yang @@ -0,0 +1,38 @@ +// vi: set smarttab et sw=4 tabstop=4: +module bgp-rib { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:rib"; + prefix "bgprib"; + + import config { prefix config; revision-date 2013-04-05; } + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + BGP listener service. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-07-01" { + description + "Initial revision"; + } + + identity rib { + description + "Service representing a BGP RIB service. Each instance allows + registration of listeners."; + + base "config:service-type"; + config:java-class "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.Rib"; + } +} + diff --git a/bgp/rib-impl-config/pom.xml b/bgp/rib-impl-config/pom.xml new file mode 100644 index 0000000000..b7fe703893 --- /dev/null +++ b/bgp/rib-impl-config/pom.xml @@ -0,0 +1,122 @@ + + + org.opendaylight.bgpcep + bgp-parent + 0.3.0-SNAPSHOT + + + 4.0.0 + bgp-rib-impl-config + BGP RIB implementation configuration + bundle + ${project.artifactId} + + 3.0.4 + + + + + ${project.groupId} + bgp-rib-api-config + ${project.version} + + + ${project.groupId} + bgp-parser-api + ${project.version} + + + ${project.groupId} + bgp-rib-impl + ${project.version} + + + ${project.groupId} + bgp-parser-impl + ${project.version} + + + ${project.groupId} + bgp-update-api-config + ${project.version} + + + org.opendaylight.controller + config-api + ${controller.config.version} + + + org.opendaylight.controller + sal-binding-config + 1.0-SNAPSHOT + + + org.opendaylight.controller + threadpool-config-api + ${controller.config.version} + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${project.build.directory}/generated-sources/config + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${controller.config.version} + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.version} + true + + + ${project.groupId}.${project.artifactId} + + org.opendaylight.controller.config.yang.bgp.rib.impl + + + + + + + + + + ${project.artifactId} + BGP-RIB-IMPL-CONFIG Module site + ${basedir}/target/site/${project.artifactId} + + + \ No newline at end of file diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModule.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModule.java new file mode 100644 index 0000000000..05680c2c8e --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModule.java @@ -0,0 +1,47 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-dispatcher-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:32 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +import org.opendaylight.protocol.bgp.parser.BGPMessageFactory; +import org.opendaylight.protocol.bgp.rib.impl.BGPDispatcherImpl; + +/** +* +*/ +public final class BGPDispatcherImplModule + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPDispatcherImplModule { + + public BGPDispatcherImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public BGPDispatcherImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + BGPDispatcherImplModule oldModule, + java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + // Add custom validation for module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + final BGPMessageFactory messageFactoryDependency = getMessageFactoryDependency(); + return new BGPDispatcherImpl(messageFactoryDependency, getBossGroupDependency(), getWorkerGroupDependency()); + } +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModuleFactory.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModuleFactory.java new file mode 100644 index 0000000000..70c7412dd6 --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPDispatcherImplModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-dispatcher-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:32 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +/** +* +*/ +public class BGPDispatcherImplModuleFactory + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPDispatcherImplModuleFactory { + +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPImplModule.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPImplModule.java new file mode 100644 index 0000000000..d15bc50885 --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPImplModule.java @@ -0,0 +1,48 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:31 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +import java.net.InetSocketAddress; + +import org.opendaylight.protocol.bgp.rib.impl.BGPImpl; + +/** +* +*/ +public final class BGPImplModule + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPImplModule { + + public BGPImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public BGPImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + BGPImplModule oldModule, java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + // Add custom validation for module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + InetSocketAddress address = new InetSocketAddress(getHost(), getPort()); + return new BGPImpl(getBgpDispatcherDependency(), address, + getBgpProposalDependency()); + } +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPImplModuleFactory.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPImplModuleFactory.java new file mode 100644 index 0000000000..7e8e29bb85 --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPImplModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:31 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +/** +* +*/ +public class BGPImplModuleFactory + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPImplModuleFactory { + +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModule.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModule.java new file mode 100644 index 0000000000..235ba2317c --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModule.java @@ -0,0 +1,82 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-message-factory-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:31 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +import org.opendaylight.protocol.bgp.parser.BGPMessageFactory; +import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl; +import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext; +import org.opendaylight.protocol.framework.DeserializerException; +import org.opendaylight.protocol.framework.DocumentedException; +import org.opendaylight.yangtools.yang.binding.Notification; + +/** +* +*/ +public final class BGPMessageFactoryImplModule + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryImplModule { + + public BGPMessageFactoryImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public BGPMessageFactoryImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + BGPMessageFactoryImplModule oldModule, + java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + // Add custom validation for module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + try { + return new BGPMessageFactoryCloseable(new BGPMessageFactoryImpl( + ServiceLoaderBGPExtensionProviderContext + .createConsumerContext().getMessageRegistry())); + } catch (Exception e) { + throw new RuntimeException("Failed to create consumer context.", e); + } + } + + private static class BGPMessageFactoryCloseable implements + BGPMessageFactory, AutoCloseable { + private final BGPMessageFactoryImpl inner; + + public BGPMessageFactoryCloseable( + BGPMessageFactoryImpl bgpMessageFactory) { + this.inner = bgpMessageFactory; + } + + @Override + public void close() throws Exception { + // NOOP + } + + @Override + public Notification parse(byte[] bytes) throws DeserializerException, + DocumentedException { + return inner.parse(bytes); + } + + @Override + public byte[] put(Notification bgpMessage) { + return inner.put(bgpMessage); + } + } +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleFactory.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleFactory.java new file mode 100644 index 0000000000..bbe69aeca2 --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-message-factory-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:31 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +/** +* +*/ +public class BGPMessageFactoryImplModuleFactory + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryImplModuleFactory { + +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPSessionProposalImplModule.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPSessionProposalImplModule.java new file mode 100644 index 0000000000..3d9b81787c --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPSessionProposalImplModule.java @@ -0,0 +1,72 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-proposal-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:32 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl; +import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences; +import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; + +/** +* +*/ +public final class BGPSessionProposalImplModule + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPSessionProposalImplModule { + + public BGPSessionProposalImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public BGPSessionProposalImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + BGPSessionProposalImplModule oldModule, + java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + // Add custom validation for module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + final Ipv4Address bgpId = new Ipv4Address(getBgpId()); + final BGPSessionProposalImpl bgpSessionProposal = new BGPSessionProposalImpl( + getHoldtimer(), getAsNumber(), bgpId); + return new BgpSessionProposalCloseable(bgpSessionProposal); + } + + private static final class BgpSessionProposalCloseable implements + BGPSessionProposal, AutoCloseable { + + private final BGPSessionProposalImpl inner; + + public BgpSessionProposalCloseable( + BGPSessionProposalImpl bgpSessionProposal) { + this.inner = bgpSessionProposal; + } + + @Override + public void close() throws Exception { + // NOOP + } + + @Override + public BGPSessionPreferences getProposal() { + return inner.getProposal(); + } + } +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPSessionProposalImplModuleFactory.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPSessionProposalImplModuleFactory.java new file mode 100644 index 0000000000..a43c638b2e --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPSessionProposalImplModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: bgp-proposal-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:32 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +/** +* +*/ +public class BGPSessionProposalImplModuleFactory + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPSessionProposalImplModuleFactory { + +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModule.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModule.java new file mode 100644 index 0000000000..5ee3dbbd1a --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModule.java @@ -0,0 +1,112 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: rib-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:32 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +import io.netty.util.concurrent.GlobalEventExecutor; + +import java.io.IOException; + +import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; +import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.protocol.bgp.parser.BGPSessionListener; +import org.opendaylight.protocol.bgp.rib.impl.BGP; +import org.opendaylight.protocol.bgp.rib.impl.BGPPeer; +import org.opendaylight.protocol.bgp.rib.impl.RIBImpl; +import org.opendaylight.protocol.concepts.ListenerRegistration; +import org.opendaylight.protocol.framework.TimedReconnectStrategy; +import org.osgi.framework.BundleContext; + +import com.google.common.base.Preconditions; + +/** +* +*/ +public final class RIBImplModule + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractRIBImplModule { + + public RIBImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public RIBImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + RIBImplModule oldModule, java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + // Add custom validation for module attributes here. + } + + @Override + public java.lang.AutoCloseable createInstance() { + BAProvider provider = new BAProvider(); + + ProviderContext providerContext = ((BindingAwareBroker) getOsgiRegistry()) + .registerProvider(provider, provider.ctx); + DataProviderService dataProviderService = providerContext + .getSALService(DataProviderService.class); + RIBImpl rib = new RIBImpl(dataProviderService); + BGP bgp = getBgpDependency(); + final BGPPeer peer = new BGPPeer(rib, "peer-" + bgp.toString()); + + try { + final long reconnects = getReconnectAttempts(); + ListenerRegistration reg = bgp + .registerUpdateListener(peer, new TimedReconnectStrategy( + GlobalEventExecutor.INSTANCE, + getConnectionTimeout(), 5000, 1.0, null, + reconnects, null)); + return new RibImplCloseable(reg, rib); + } catch (IOException e) { + throw new RuntimeException("Failed to register with BGP", e); + } + } + + private static final class RibImplCloseable implements AutoCloseable { + private final ListenerRegistration reg; + private final RIBImpl innerRib; + + private RibImplCloseable(ListenerRegistration reg, + RIBImpl innerRib) { + this.reg = reg; + this.innerRib = innerRib; + } + + @Override + public void close() throws Exception { + reg.close(); + } + } + + private static final class BAProvider extends AbstractBindingAwareProvider { + + BundleContext ctx; + + @Override + public void onSessionInitiated(ProviderContext session) { + + } + + @Override + protected void startImpl(final BundleContext context) { + this.ctx = Preconditions.checkNotNull(context); + } + + } +} diff --git a/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModuleFactory.java b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModuleFactory.java new file mode 100644 index 0000000000..58bb01e480 --- /dev/null +++ b/bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/RIBImplModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-rib-impl yang module local name: rib-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:02:32 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.rib.impl; + +/** +* +*/ +public class RIBImplModuleFactory + extends + org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractRIBImplModuleFactory { + +} diff --git a/bgp/rib-impl-config/src/main/yang/bgp-rib-impl.yang b/bgp/rib-impl-config/src/main/yang/bgp-rib-impl.yang new file mode 100644 index 0000000000..b1510f0ecc --- /dev/null +++ b/bgp/rib-impl-config/src/main/yang/bgp-rib-impl.yang @@ -0,0 +1,227 @@ +// vi: set smarttab et sw=4 tabstop=4: +module bgp-rib-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:rib:impl"; + prefix "bgprib-impl"; + + import bgp-listener { prefix bgpl; revision-date 2013-04-09; } + import bgp-rib { prefix bgprib; revision-date 2013-07-01; } + import opendaylight-md-sal-binding {prefix mdsb; revision-date 2013-10-28; } + import threadpool { prefix th; revision-date 2013-04-09; } + import config { prefix config; revision-date 2013-04-05; } + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + BGP listener implementation. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-04-09" { + description + "Initial revision"; + } + + identity bgp-message-factory { + description + "Service representing a BGP proposal."; + + base "config:service-type"; + config:java-class "org.opendaylight.protocol.bgp.parser.BGPMessageFactory"; + } + + identity bgp-message-factory-impl { + base config:module-type; + config:provided-service bgp-message-factory; + config:java-name-prefix BGPMessageFactoryImpl; + + } + + augment "/config:modules/config:module/config:configuration" { + case bgp-message-factory-impl { + when "/config:modules/config:module/config:type = 'bgp-message-factory-impl'"; + } + } + + identity bgp-proposal { + description + "Service representing a BGP proposal."; + + base "config:service-type"; + config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal"; + } + + identity bgp-proposal-impl { + base config:module-type; + config:provided-service bgp-proposal; + config:java-name-prefix BGPSessionProposalImpl; + + } + + augment "/config:modules/config:module/config:configuration" { + case bgp-proposal-impl { + when "/config:modules/config:module/config:type = 'bgp-proposal-impl'"; + + leaf holdtimer { + type int16; + default 180; + } + + leaf bgp-id { + mandatory true; + type string; + } + + leaf as-number { + mandatory true; + type int32; + } + } + } + + identity bgp-dispatcher { + description + "Service representing a BGP Dispatcher."; + + base "config:service-type"; + config:java-class "org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher"; + } + + identity bgp-dispatcher-impl { + base config:module-type; + config:provided-service bgp-dispatcher; + config:java-name-prefix BGPDispatcherImpl; + + } + + augment "/config:modules/config:module/config:configuration" { + case bgp-dispatcher-impl { + when "/config:modules/config:module/config:type = 'bgp-dispatcher-impl'"; + + container message-factory { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity bgp-message-factory; + } + } + } + + container boss-group { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity th:netty-threadgroup; + } + } + } + + container worker-group { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity th:netty-threadgroup; + } + } + } + } + } + + identity bgp-impl { + base config:module-type; + config:provided-service bgpl:listener; + config:java-name-prefix BGPImpl; + + } + + augment "/config:modules/config:module/config:configuration" { + case bgp-impl { + when "/config:modules/config:module/config:type = 'bgp-impl'"; + + container bgp-dispatcher { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity bgp-dispatcher; + } + } + } + + container bgp-proposal { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity bgp-proposal; + } + } + } + + leaf host { + mandatory true; + type string; + } + + leaf port { + mandatory true; + type uint16; + } + } + } + + identity rib-impl { + base config:module-type; + config:provided-service bgprib:rib; + config:java-name-prefix RIBImpl; + } + + + augment "/config:modules/config:module/config:configuration" { + case rib-impl { + when "/config:modules/config:module/config:type = 'rib-impl'"; + + container bgp { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity bgpl:listener; + } + } + } + + leaf rib-name { + mandatory true; + type string; + } + + leaf connection-timeout { + mandatory true; + type int32; + } + + leaf reconnect-attempts { + mandatory true; + type int64; + } + + container osgi-registry { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity mdsb:binding-broker-osgi-registry; + } + } + } + } + } + + +} + diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java index b3e754d9ad..1c5ea526ca 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java @@ -31,12 +31,12 @@ import com.google.common.base.Objects.ToStringHelper; import com.google.common.base.Preconditions; @ThreadSafe -final class RIBImpl { +public class RIBImpl { private static final Logger logger = LoggerFactory.getLogger(RIBImpl.class); private final DataProviderService dps; private final RIBTables tables; - RIBImpl(final DataProviderService dps) { + public RIBImpl(final DataProviderService dps) { this.dps = Preconditions.checkNotNull(dps); this.tables = new RIBTables(BGPObjectComparator.INSTANCE, AdjRIBsInFactoryRegistryImpl.INSTANCE); } diff --git a/bgp/update-api-config/pom.xml b/bgp/update-api-config/pom.xml new file mode 100644 index 0000000000..0bfb8c222e --- /dev/null +++ b/bgp/update-api-config/pom.xml @@ -0,0 +1,92 @@ + + + org.opendaylight.bgpcep + bgp-parent + 0.3.0-SNAPSHOT + + 4.0.0 + bgp-update-api-config + BGP Update API + bundle + ${project.artifactId} + + 3.0.4 + + + + + org.opendaylight.controller + config-api + ${controller.config.version} + + + ${project.groupId} + bgp-rib-impl + ${project.version} + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${project.build.directory}/generated-sources/config + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${controller.config.version} + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.version} + true + + + ${project.groupId}.${project.artifactId} + + org.opendaylight.controller.config.yang.bgp.listener + + + + + + + + + + ${project.artifactId} + BGP-UPDATE-API-CONFIG Module site + ${basedir}/target/site/${project.artifactId} + + + + \ No newline at end of file diff --git a/bgp/update-api-config/src/main/yang/bgp-listener.yang b/bgp/update-api-config/src/main/yang/bgp-listener.yang new file mode 100644 index 0000000000..aee09f9b3f --- /dev/null +++ b/bgp/update-api-config/src/main/yang/bgp-listener.yang @@ -0,0 +1,39 @@ +// vi: set smarttab et sw=4 tabstop=4: +module bgp-listener { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:listener"; + prefix "bgpl"; + + import config { prefix config; revision-date 2013-04-05; } + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + BGP listener service. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-04-09" { + description + "Initial revision"; + } + + identity listener { + description + "Service representing a BGP service. Each instance allows + registration of listeners. Each listener has its own BGP session. + Events happening on the session are routed to the listener."; + + base "config:service-type"; + config:java-class "org.opendaylight.protocol.bgp.rib.impl.BGP"; + } +} + diff --git a/bgp/update-mock-config/pom.xml b/bgp/update-mock-config/pom.xml new file mode 100644 index 0000000000..1a76a758cf --- /dev/null +++ b/bgp/update-mock-config/pom.xml @@ -0,0 +1,101 @@ + + + org.opendaylight.bgpcep + bgp-parent + 0.3.0-SNAPSHOT + + 4.0.0 + bgp-update-mock-config + BGP UPDATE MOCK CONFIG + bundle + ${project.artifactId} + + 3.0.4 + + + + + org.opendaylight.controller + config-api + ${controller.config.version} + + + ${project.groupId} + bgp-update-api-config + ${project.version} + + + org.opendaylight.controller + threadpool-config-api + ${controller.config.version} + + + ${project.groupId} + bgp-rib-mock + ${project.version} + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${project.build.directory}/generated-sources/config + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${controller.config.version} + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.version} + true + + + ${project.groupId}.${project.artifactId} + + org.opendaylight.controller.config.yang.bgp.mock + + + + + + + + + + ${project.artifactId} + BGP-UPDATE-MOCK-CONFIG Module site + ${basedir}/target/site/${project.artifactId} + + + \ No newline at end of file diff --git a/bgp/update-mock-config/src/main/java/org/opendaylight/controller/config/yang/bgp/mock/BgpMockModule.java b/bgp/update-mock-config/src/main/java/org/opendaylight/controller/config/yang/bgp/mock/BgpMockModule.java new file mode 100644 index 0000000000..23f622d447 --- /dev/null +++ b/bgp/update-mock-config/src/main/java/org/opendaylight/controller/config/yang/bgp/mock/BgpMockModule.java @@ -0,0 +1,106 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-mock yang module local name: bgp-mock + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 12:46:58 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.mock; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nullable; + +import org.opendaylight.controller.config.api.JmxAttributeValidationException; +import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext; +import org.opendaylight.protocol.bgp.rib.mock.BGPMock; +import org.opendaylight.protocol.bgp.util.BinaryBGPDumpFileParser; +import org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser; + +import com.google.common.base.Function; +import com.google.common.collect.Collections2; +import com.google.common.collect.Lists; + +/** +* +*/ +public final class BgpMockModule extends + org.opendaylight.controller.config.yang.bgp.mock.AbstractBgpMockModule { + + private List bgpMessages; + + public BgpMockModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public BgpMockModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + BgpMockModule oldModule, java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + JmxAttributeValidationException.checkCondition( + (getBinDump() != null && getHexDump() != null) == false, + "Both 'HexDump' and 'BinDump' contain value", + binDumpJmxAttribute); + if (getBinDump() == null && getHexDump() == null) { + bgpMessages = new ArrayList<>(); + } else if (getHexDump() != null) { + try { + bgpMessages = HexDumpBGPFileParser.parseMessages(getHexDump()); + bgpMessages = Lists.newArrayList(fixMessages(bgpMessages)); + } catch (Exception e) { + JmxAttributeValidationException.wrap(e, + "Error while parsing HexDump", hexDumpJmxAttribute); + } + } else { + try { + bgpMessages = BinaryBGPDumpFileParser + .parseMessages(getBinDump()); + } catch (Exception e) { + JmxAttributeValidationException.wrap(e, + "Error while parsing BinDump", binDumpJmxAttribute); + } + } + } + + @Override + public java.lang.AutoCloseable createInstance() { + try { + return new BGPMock(getEventBusDependency(), + ServiceLoaderBGPExtensionProviderContext + .createConsumerContext().getMessageRegistry(), + bgpMessages); + } catch (Exception e) { + throw new RuntimeException("Failed to create consumer context.", e); + } + } + + private Collection fixMessages(Collection bgpMessages) { + return Collections2.transform(bgpMessages, + new Function() { + + @Nullable + @Override + public byte[] apply(@Nullable byte[] input) { + byte[] ret = new byte[input.length + 1]; + // ff + ret[0] = -1; + for (int i = 0; i < input.length; i++) { + ret[i + 1] = input[i]; + } + return ret; + } + }); + } +} diff --git a/bgp/update-mock-config/src/main/java/org/opendaylight/controller/config/yang/bgp/mock/BgpMockModuleFactory.java b/bgp/update-mock-config/src/main/java/org/opendaylight/controller/config/yang/bgp/mock/BgpMockModuleFactory.java new file mode 100644 index 0000000000..2828e27a91 --- /dev/null +++ b/bgp/update-mock-config/src/main/java/org/opendaylight/controller/config/yang/bgp/mock/BgpMockModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: bgp-mock yang module local name: bgp-mock + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 12:46:58 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.bgp.mock; + +/** +* +*/ +public class BgpMockModuleFactory + extends + org.opendaylight.controller.config.yang.bgp.mock.AbstractBgpMockModuleFactory { + +} diff --git a/bgp/update-mock-config/src/main/yang/bgp-mock.yang b/bgp/update-mock-config/src/main/yang/bgp-mock.yang new file mode 100644 index 0000000000..b7b491f104 --- /dev/null +++ b/bgp/update-mock-config/src/main/yang/bgp-mock.yang @@ -0,0 +1,59 @@ +// vi: set smarttab et sw=4 tabstop=4: +module bgp-mock { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:bgp:mock"; + prefix "th-java"; + + import config { prefix config; revision-date 2013-04-05; } + import threadpool { prefix th; revision-date 2013-04-09; } + import bgp-listener { prefix bgpl; revision-date 2013-04-09; } + + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + BGP message parser pure Java implementation. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-04-09" { + description + "Initial version."; + } + + identity bgp-mock { + base config:module-type; + config:provided-service bgpl:listener; + } + + augment "/config:modules/config:module/config:configuration" { + case bgp-mock { + when "/config:modules/config:module/config:type = 'bgp-mock'"; + container eventBus { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity th:eventbus; + } + } + } + + leaf hexDump { + type string; + } + + leaf binDump { + type binary; + } + } + } +} + diff --git a/pcep/api-config/pom.xml b/pcep/api-config/pom.xml new file mode 100644 index 0000000000..3d9c04b138 --- /dev/null +++ b/pcep/api-config/pom.xml @@ -0,0 +1,91 @@ + + + org.opendaylight.bgpcep + pcep-parent + 0.3.0-SNAPSHOT + + 4.0.0 + pcep-api-config + PCE Protocol API + bundle + ${project.artifactId} + + 3.0.4 + + + + + org.opendaylight.controller + config-api + ${controller.config.version} + + + ${project.groupId} + pcep-api + ${project.version} + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${project.build.directory}/generated-sources/config + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${controller.config.version} + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.version} + true + + + ${project.groupId}.${project.artifactId} + + org.opendaylight.controller.config.yang.pcep + + + + + + + + + + ${project.artifactId} + PCEP-API-CONFIG Module site + ${basedir}/target/site/${project.artifactId} + + + \ No newline at end of file diff --git a/pcep/api-config/src/main/yang/pcep.yang b/pcep/api-config/src/main/yang/pcep.yang new file mode 100644 index 0000000000..67cf117ad3 --- /dev/null +++ b/pcep/api-config/src/main/yang/pcep.yang @@ -0,0 +1,48 @@ +// vi: set smarttab et sw=4 tabstop=4: +module pcep { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep"; + prefix "pcep"; + + import config { prefix config; revision-date 2013-04-05; } + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + PCEP protocol handler. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-04-09" { + description + "Initial revision"; + } + + identity pcep-dispatcher { + description + "Service representing a PCEP dispatcher service. The service + can create both PCEP client sessions and PCEP servers."; + + base "config:service-type"; + config:java-class "org.opendaylight.protocol.pcep.PCEPDispatcher"; + } + + identity pcep-session-proposal-factory { + description + "Service representing a PCEP session proposal factory service. The service + provides initial session attributes given by the user."; + + base "config:service-type"; + config:java-class "org.opendaylight.protocol.pcep.PCEPSessionProposalFactory"; + } + +} + diff --git a/pcep/api/src/main/yang/pcep-types.yang b/pcep/api/src/main/yang/pcep-types.yang index 43112e3da3..8774adfd27 100644 --- a/pcep/api/src/main/yang/pcep-types.yang +++ b/pcep/api/src/main/yang/pcep-types.yang @@ -1003,7 +1003,7 @@ module pcep-types { uses include-route-object; - uses of-object; + //uses of-object; uses classtype-object; } diff --git a/pcep/impl-config/pom.xml b/pcep/impl-config/pom.xml new file mode 100644 index 0000000000..c7c0c63756 --- /dev/null +++ b/pcep/impl-config/pom.xml @@ -0,0 +1,100 @@ + + + org.opendaylight.bgpcep + pcep-parent + 0.3.0-SNAPSHOT + + 4.0.0 + pcep-impl-config + PCE Protocol Implementation + bundle + ${project.artifactId} + + 3.0.4 + + + + + org.opendaylight.controller + config-api + ${controller.config.version} + + + ${project.groupId} + pcep-impl + ${project.version} + + + ${project.groupId} + pcep-api-config + ${project.version} + + + org.opendaylight.controller + threadpool-config-api + ${controller.config.version} + + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + + generate-sources + + + + + + org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + + ${project.build.directory}/generated-sources/config + + + urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang + + + + + true + + + + + + org.opendaylight.controller + yang-jmx-generator-plugin + ${controller.config.version} + + + + + org.apache.felix + maven-bundle-plugin + ${maven.bundle.version} + true + + + ${project.groupId}.${project.artifactId} + + + + + + + + + + + ${project.artifactId} + PCEP-IMPL-CONFIG Module site + ${basedir}/target/site/${project.artifactId} + + + \ No newline at end of file diff --git a/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPDispatcherImplModule.java b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPDispatcherImplModule.java new file mode 100644 index 0000000000..51f0db2631 --- /dev/null +++ b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPDispatcherImplModule.java @@ -0,0 +1,64 @@ +/** + * Generated file + + * Generated from: yang module name: pcep-impl yang module local name: pcep-dispatcher-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:16:39 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.pcep.impl; + +import io.netty.util.HashedWheelTimer; +import io.netty.util.Timer; + +import org.opendaylight.controller.config.api.JmxAttributeValidationException; +import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory; +import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl; +import org.opendaylight.protocol.pcep.spi.pojo.PCEPExtensionProviderContextImpl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open; + +/** +* +*/ +public final class PCEPDispatcherImplModule + extends + org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPDispatcherImplModule { + + public PCEPDispatcherImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public PCEPDispatcherImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + PCEPDispatcherImplModule oldModule, + java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + JmxAttributeValidationException.checkCondition( + getMaxUnknownMessages() > 0, "Parameter 'maxUnknownMessages' " + + "must be greater than 0", + this.maxUnknownMessagesJmxAttribute); + } + + @Override + public java.lang.AutoCloseable createInstance() { + Timer timer = new HashedWheelTimer(); + Open localPrefs = getPcepSessionProposalFactoryDependency() + .getSessionProposal(null, -1); + DefaultPCEPSessionNegotiatorFactory negFactory = new DefaultPCEPSessionNegotiatorFactory( + timer, localPrefs, getMaxUnknownMessages()); + + final PCEPDispatcherImpl instance = new PCEPDispatcherImpl( + PCEPExtensionProviderContextImpl.getSingletonInstance() + .getMessageHandlerRegistry(), negFactory, getBossGroupDependency(), getWorkerGroupDependency()); + return instance; + } +} diff --git a/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPDispatcherImplModuleFactory.java b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPDispatcherImplModuleFactory.java new file mode 100644 index 0000000000..2d067e1728 --- /dev/null +++ b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPDispatcherImplModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: pcep-impl yang module local name: pcep-dispatcher-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:16:39 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.pcep.impl; + +/** +* +*/ +public class PCEPDispatcherImplModuleFactory + extends + org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPDispatcherImplModuleFactory { + +} diff --git a/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPSessionProposalFactoryImplModule.java b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPSessionProposalFactoryImplModule.java new file mode 100644 index 0000000000..fc3cc23dfa --- /dev/null +++ b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPSessionProposalFactoryImplModule.java @@ -0,0 +1,81 @@ +/** + * Generated file + + * Generated from: yang module name: pcep-impl yang module local name: pcep-session-proposal-factory-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:16:39 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.pcep.impl; + +import java.net.InetSocketAddress; + +import org.opendaylight.controller.config.api.JmxAttributeValidationException; +import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory; +import org.opendaylight.protocol.pcep.impl.PCEPSessionProposalFactoryImpl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open; + +/** +* +*/ +public final class PCEPSessionProposalFactoryImplModule + extends + org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPSessionProposalFactoryImplModule { + + public PCEPSessionProposalFactoryImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(name, dependencyResolver); + } + + public PCEPSessionProposalFactoryImplModule( + org.opendaylight.controller.config.api.ModuleIdentifier name, + org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, + PCEPSessionProposalFactoryImplModule oldModule, + java.lang.AutoCloseable oldInstance) { + super(name, dependencyResolver, oldModule, oldInstance); + } + + @Override + public void validate() { + super.validate(); + JmxAttributeValidationException + .checkCondition( + getDeadTimerValue() % getKeepAliveTimerValue() != 4, + "Parameter 'dead timer value' should be 4 times greater than keepAlive timer value.", + deadTimerValueJmxAttribute); + if ((getActive() || getVersioned() || getTimeout() > 0) + && !getStateful()) + setStateful(true); + } + + @Override + public java.lang.AutoCloseable createInstance() { + PCEPSessionProposalFactoryImpl inner = new PCEPSessionProposalFactoryImpl( + getDeadTimerValue(), getKeepAliveTimerValue(), getStateful(), + getActive(), getVersioned(), getInstantiated(), getTimeout()); + return new PCEPSessionProposalFactoryCloseable(inner); + } + + private static final class PCEPSessionProposalFactoryCloseable implements + PCEPSessionProposalFactory, AutoCloseable { + + private PCEPSessionProposalFactoryImpl inner; + + public PCEPSessionProposalFactoryCloseable( + PCEPSessionProposalFactoryImpl inner) { + this.inner = inner; + } + + @Override + public void close() throws Exception { + } + + @Override + public Open getSessionProposal( + InetSocketAddress inetSocketAddress, int i) { + return inner.getSessionProposal(inetSocketAddress, i); + } + } +} diff --git a/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPSessionProposalFactoryImplModuleFactory.java b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPSessionProposalFactoryImplModuleFactory.java new file mode 100644 index 0000000000..11c181a60a --- /dev/null +++ b/pcep/impl-config/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPSessionProposalFactoryImplModuleFactory.java @@ -0,0 +1,19 @@ +/** + * Generated file + + * Generated from: yang module name: pcep-impl yang module local name: pcep-session-proposal-factory-impl + * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator + * Generated at: Wed Nov 06 13:16:39 CET 2013 + * + * Do not modify this file unless it is present under src/main directory + */ +package org.opendaylight.controller.config.yang.pcep.impl; + +/** +* +*/ +public class PCEPSessionProposalFactoryImplModuleFactory + extends + org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPSessionProposalFactoryImplModuleFactory { + +} diff --git a/pcep/impl-config/src/main/yang/pcep-impl.yang b/pcep/impl-config/src/main/yang/pcep-impl.yang new file mode 100644 index 0000000000..ac19e63cc7 --- /dev/null +++ b/pcep/impl-config/src/main/yang/pcep-impl.yang @@ -0,0 +1,122 @@ +// vi: set smarttab et sw=4 tabstop=4: +module pcep-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep:impl"; + prefix "pcep-impl"; + + import config { prefix config; revision-date 2013-04-05; } + import pcep { prefix pcep; revision-date 2013-04-09; } + import threadpool { prefix th; revision-date 2013-04-09; } + + organization "Cisco Systems, Inc."; + + contact "Robert Varga "; + + description + "This module contains the base YANG definitions for + PCEP implementation. + + Copyright (c)2013 Cisco Systems, Inc. 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"; + + revision "2013-06-27" { + description + "Updated revision dates for imports."; + } + + revision "2013-04-09" { + description + "Initial revision"; + } + + identity pcep-dispatcher-impl { + base config:module-type; + config:provided-service pcep:pcep-dispatcher; + config:java-name-prefix PCEPDispatcherImpl; + } + + augment "/config:modules/config:module/config:configuration" { + case pcep-dispatcher-impl { + when "/config:modules/config:module/config:type = 'pcep-dispatcher-impl'"; + + leaf max-unknown-messages { + type uint16; + } + + container pcep-session-proposal-factory { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity pcep:pcep-session-proposal-factory; + } + } + } + + container boss-group { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity th:netty-threadgroup; + } + } + } + + container worker-group { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity th:netty-threadgroup; + } + } + } + } + } + + identity pcep-session-proposal-factory-impl { + base config:module-type; + config:java-name-prefix "PCEPSessionProposalFactoryImpl"; + config:provided-service pcep:pcep-session-proposal-factory; + } + + augment "/config:modules/config:module/config:configuration" { + case pcep-session-proposal-factory-impl { + when "/config:modules/config:module/config:type = 'pcep-session-proposal-factory-impl'"; + + + leaf dead-timer-value { + type uint16; + } + + leaf keep-alive-timer-value { + type uint16; + } + + leaf instantiated { + type boolean; + } + + leaf timeout { + type uint16; + } + + leaf stateful { + type boolean; + } + + leaf active { + type boolean; + } + + leaf versioned { + type boolean; + } + } + } + + +} + diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java index 96abf428ff..6666388a3b 100644 --- a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java +++ b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java @@ -20,10 +20,12 @@ import javax.annotation.concurrent.GuardedBy; import org.opendaylight.protocol.framework.AbstractSessionNegotiator; import org.opendaylight.protocol.pcep.PCEPErrors; -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.message.rev131007.Keepalive; +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.message.rev131007.OpenBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr; 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.OpenMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcerrMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder; 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; @@ -31,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; /** @@ -49,7 +52,8 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot * action is to terminate negotiation. This timer is restarted between state transitions and runs in all states * except Idle and Finished. */ - private enum State { + @VisibleForTesting + public enum State { /** * Negotiation has not begun. It will be activated once we are asked to provide our initial proposal, at which * point we move into OpenWait state. @@ -87,6 +91,8 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot private volatile boolean localOK, openRetry, remoteOK; + private final Keepalive keepalive = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build(); + protected AbstractPCEPSessionNegotiator(final Timer timer, final Promise promise, final Channel channel) { super(promise, channel); this.timer = Preconditions.checkNotNull(timer); @@ -103,7 +109,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot * Get the revised session parameters proposal based on the feedback the peer has provided to us. * * @param suggestion Peer-provided suggested session parameters - * @return Session parameters proposal. + * @return Session parameters proposal, or null if peers session parameters preclude us from suggesting anything */ protected abstract Open getRevisedProposal(Open suggestion); @@ -201,7 +207,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot case Idle: throw new IllegalStateException("Unexpected handleMessage in state " + this.state); case KeepWait: - if (msg instanceof KeepaliveMessage) { + if (msg instanceof Keepalive) { this.localOK = true; if (this.remoteOK) { negotiationSuccessful(createSession(this.timer, this.channel, this.localPrefs, this.remotePrefs)); @@ -213,8 +219,8 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot } return; - } else if (msg instanceof PcerrMessage) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessage err = ((PcerrMessage) msg).getPcerrMessage(); + } else if (msg instanceof Pcerr) { + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessage err = ((Pcerr) msg).getPcerrMessage(); this.localPrefs = getRevisedProposal(((Session) err.getErrorType()).getOpen()); if (this.localPrefs == null) { sendErrorMessage(PCEPErrors.PCERR_NON_ACC_SESSION_CHAR); @@ -222,7 +228,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot this.state = State.Finished; return; } - + this.channel.writeAndFlush(new OpenBuilder().setOpenMessage(new OpenMessageBuilder().setOpen(this.localPrefs).build()).build()); if (!this.remoteOK) { this.state = State.OpenWait; } @@ -232,11 +238,11 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot break; case OpenWait: - if (msg instanceof OpenMessage) { - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage o = ((OpenMessage) msg).getOpenMessage(); + if (msg instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open) { + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessage o = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open) msg).getOpenMessage(); final Open open = o.getOpen(); if (isProposalAcceptable(open)) { - this.channel.writeAndFlush(new KeepaliveMessageBuilder().build()); + this.channel.writeAndFlush(this.keepalive); this.remotePrefs = open; this.remoteOK = true; if (this.localOK) { @@ -281,4 +287,8 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot negotiationFailed(new Exception("Illegal message encountered")); this.state = State.Finished; } + + public synchronized State getState() { + return this.state; + } } diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java index dfc85b0fdb..d584613d88 100644 --- a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java +++ b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java @@ -30,6 +30,8 @@ import org.opendaylight.protocol.pcep.PCEPSession; import org.opendaylight.protocol.pcep.PCEPSessionListener; import org.opendaylight.protocol.pcep.TerminationReason; 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.message.rev131007.Keepalive; +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.CloseMessage; 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; @@ -97,7 +99,7 @@ public class PCEPSessionImpl extends AbstractProtocolSession implements private final Channel channel; - private final KeepaliveMessage kaMessage = (KeepaliveMessage) new KeepaliveMessageBuilder().build(); + private final Keepalive kaMessage = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build(); PCEPSessionImpl(final Timer timer, final PCEPSessionListener listener, final int maxUnknownMessages, final Channel channel, final Open localOpen, final Open remoteOpen) { diff --git a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageParser.java b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageParser.java index 31d9c282e4..54a1f86250 100644 --- a/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageParser.java +++ b/pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageParser.java @@ -9,22 +9,37 @@ package org.opendaylight.protocol.pcep.impl.message; import io.netty.buffer.ByteBuf; +import java.util.Arrays; import java.util.List; import org.opendaylight.protocol.pcep.PCEPDeserializerException; import org.opendaylight.protocol.pcep.PCEPDocumentedException; -import org.opendaylight.protocol.pcep.PCEPErrors; +import org.opendaylight.protocol.pcep.PCEPErrorMapping; import org.opendaylight.protocol.pcep.UnknownObject; import org.opendaylight.protocol.pcep.impl.AbstractMessageParser; import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry; -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.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.LspaObject; +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.Pcinitiate; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcinitiateBuilder; 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.Object; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcinitiateMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.bandwidth.object.Bandwidth; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.object.EndpointsObj; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.Ero; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.include.route.object.Iro; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.Metrics; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.attributes.MetricsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.Lsp; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.Lspa; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.PcinitiateMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.Requests; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.RequestsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.srp.object.Srp; import com.google.common.collect.Lists; @@ -45,7 +60,31 @@ public class PCCreateMessageParser extends AbstractMessageParser { throw new IllegalArgumentException("Wrong instance of Message. Passed instance of " + message.getClass() + ". Needed PcinitiateMessage."); } - // final PcinitiateMessage init = + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.PcinitiateMessage init = ((Pcinitiate) message).getPcinitiateMessage(); + for (final Requests req : init.getRequests()) { + buffer.writeBytes(serializeObject(req.getSrp())); + buffer.writeBytes(serializeObject(req.getLsp())); + if (req.getEndpointsObj() != null) { + buffer.writeBytes(serializeObject(req.getEndpointsObj())); + } + if (req.getEro() != null) { + buffer.writeBytes(serializeObject(req.getEro())); + } + if (req.getLspa() != null) { + buffer.writeBytes(serializeObject(req.getLspa())); + } + if (req.getBandwidth() != null) { + buffer.writeBytes(serializeObject(req.getBandwidth())); + } + if (req.getMetrics() != null && !req.getMetrics().isEmpty()) { + for (final Metrics m : req.getMetrics()) { + buffer.writeBytes(serializeObject(m.getMetric())); + } + } + if (req.getIro() != null) { + buffer.writeBytes(serializeObject(req.getIro())); + } + } } @Override @@ -61,56 +100,41 @@ public class PCCreateMessageParser extends AbstractMessageParser { if (objects == null) { throw new IllegalArgumentException("Passed list can't be null."); } - return null; - // final List insts = new ArrayList(); - // - // CompositeInstantiationObject inst; - // while (!objects.isEmpty()) { - // try { - // if ((inst = this.getValidInstantiationObject(objects)) == null) { - // break; - // } - // } catch (final PCEPDocumentedException e) { - // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError()))); - // } - // - // insts.add(inst); - // } - // - // if (insts.isEmpty()) { - // throw new PCEPDeserializerException("At least one CompositeInstantiationObject is mandatory."); - // } - // - // if (!objects.isEmpty()) { - // throw new PCEPDeserializerException("Unprocessed objects: " + objects); - // } - // - // return Arrays.asList((Message) new PCCreateMessage(insts)); - } - - private void getValidInstantiationObject(final List objects) throws PCEPDocumentedException { - if (objects.get(0) instanceof UnknownObject) { - throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError()); - } - if (!(objects.get(0) instanceof EndpointsObject)) { - return; + final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder(); + final PCEPErrorMapping maping = PCEPErrorMapping.getInstance(); + final List reqs = Lists.newArrayList(); + Requests req = null; + while (!objects.isEmpty()) { + try { + if ((req = this.getValidRequest(objects)) == null) { + break; + } + } catch (final PCEPDocumentedException e) { + final PcerrMessageBuilder b = new PcerrMessageBuilder(); + b.setErrors(Arrays.asList(new ErrorsBuilder().setErrorObject( + new ErrorObjectBuilder().setType(maping.getFromErrorsEnum(e.getError()).type).setValue( + maping.getFromErrorsEnum(e.getError()).value).build()).build())); + return new PcerrBuilder().setPcerrMessage(b.build()).build(); + } + reqs.add(req); } + builder.setRequests(reqs); + return new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(); + } - final EndpointsObject endPoints = ((EndpointsObject) objects.get(0)); + private Requests getValidRequest(final List objects) throws PCEPDocumentedException { + final Srp srp = ((Srp) objects.get(0)); objects.remove(0); - if (objects.get(0) instanceof UnknownObject) { - throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError()); - } - if (!(objects.get(0) instanceof LspaObject)) { - throw new PCEPDocumentedException("LSPA Object must be second.", PCEPErrors.LSPA_MISSING); - } - final LspaObject lspa = (LspaObject) objects.get(0); + final Lsp lsp = (Lsp) objects.get(0); objects.remove(0); - ExplicitRouteObject ero = null; - BandwidthObject bandwidth = null; - final List metrics = Lists.newArrayList(); + EndpointsObj endpoints = null; + Ero ero = null; + Lspa lspa = null; + Bandwidth bandwidth = null; + final List metrics = Lists.newArrayList(); + Iro iro = null; Object obj; int state = 1; @@ -123,33 +147,49 @@ public class PCCreateMessageParser extends AbstractMessageParser { switch (state) { case 1: state = 2; - if (obj instanceof ExplicitRouteObject) { - ero = (ExplicitRouteObject) obj; + if (obj instanceof EndpointsObj) { + endpoints = (EndpointsObj) obj; break; } case 2: state = 3; - if (obj instanceof BandwidthObject) { - bandwidth = (BandwidthObject) obj; + if (obj instanceof Ero) { + ero = (Ero) obj; break; } case 3: state = 4; - if (obj instanceof MetricObject) { - metrics.add((MetricObject) obj); - state = 3; + if (obj instanceof Lspa) { + lspa = (Lspa) obj; + break; + } + case 4: + state = 5; + if (obj instanceof Bandwidth) { + bandwidth = (Bandwidth) obj; + break; + } + case 5: + state = 6; + if (obj instanceof Metric) { + metrics.add(new MetricsBuilder().setMetric((Metric) obj).build()); + state = 5; + break; + } + case 6: + state = 7; + if (obj instanceof Iro) { + iro = (Iro) obj; break; } } - - if (state == 4) { + if (state == 7) { break; } - objects.remove(0); } - - // return new CompositeInstantiationObject(endPoints, lspa, ero, bandwidth, metrics); + return new RequestsBuilder().setSrp(srp).setLsp(lsp).setEndpointsObj(endpoints).setEro(ero).setLspa(lspa).setBandwidth(bandwidth).setMetrics( + metrics).setIro(iro).build(); } @Override diff --git a/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java b/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java index 358be3d533..09274f83cf 100644 --- a/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java +++ b/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java @@ -9,58 +9,106 @@ package org.opendaylight.protocol.pcep.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelPipeline; +import io.netty.util.HashedWheelTimer; +import io.netty.util.concurrent.DefaultPromise; +import io.netty.util.concurrent.GlobalEventExecutor; + +import java.util.Arrays; +import java.util.List; import org.junit.After; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; +import org.opendaylight.protocol.pcep.PCEPErrorMapping; import org.opendaylight.protocol.pcep.PCEPErrors; -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; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive; +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.message.rev131007.Open; +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.message.rev131007.Pcerr; +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.OpenMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder; +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.pcep.error.object.ErrorObjectBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.SessionBuilder; +import org.opendaylight.yangtools.yang.binding.Notification; + +import com.google.common.collect.Lists; public class FiniteStateMachineTest { - private ServerSessionMock serverSession; + private DefaultPCEPSessionNegotiator serverSession; + + @Mock + private Channel clientListener; + + @Mock + private ChannelPipeline pipeline; + + private final List receivedMsgs = Lists.newArrayList(); - private final SimpleSessionListener serverListener = new SimpleSessionListener(); + private Open openmsg; - private MockPCE client; + private Keepalive kamsg; @Before public void setUp() { - this.client = new MockPCE(); - this.serverSession = new ServerSessionMock(this.serverListener, this.client); - this.client.addSession(this.serverSession); + MockitoAnnotations.initMocks(this); + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open localPrefs = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setKeepalive( + (short) 1).build(); + this.serverSession = new DefaultPCEPSessionNegotiator(new HashedWheelTimer(), new DefaultPromise(GlobalEventExecutor.INSTANCE), this.clientListener, new SimpleSessionListener(), (short) 1, 20, localPrefs); + doAnswer(new Answer() { + @Override + public Object answer(final InvocationOnMock invocation) { + final Object[] args = invocation.getArguments(); + FiniteStateMachineTest.this.receivedMsgs.add((Notification) args[0]); + return null; + } + }).when(this.clientListener).writeAndFlush(any(Notification.class)); + doReturn("TestingChannel").when(this.clientListener).toString(); + doReturn(this.pipeline).when(this.clientListener).pipeline(); + doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class)); + doReturn(mock(ChannelFuture.class)).when(this.clientListener).close(); + this.openmsg = new OpenBuilder().setOpenMessage( + new OpenMessageBuilder().setOpen( + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setDeadTimer( + (short) 3).build()).build()).build(); + this.kamsg = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build(); } /** * Both PCEs accept session characteristics. Also tests KeepAliveTimer and error message and when pce attempts to * establish pce session for the 2nd time. * - * @throws InterruptedException + * @throws Exception */ @Test - @Ignore - public void testSessionCharsAccBoth() throws InterruptedException { - // this.serverSession.startSession(); - assertEquals(1, this.client.getListMsg().size()); - assertTrue(this.client.getListMsg().get(0) instanceof OpenMessage); - // this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(3, 9, 2))); - assertEquals(2, this.client.getListMsg().size()); - assertTrue(this.client.getListMsg().get(1) instanceof KeepaliveMessage); - this.client.sendMessage((Message) new KeepaliveMessageBuilder().build()); - synchronized (this.serverListener) { - while (!this.serverListener.up) { - try { - this.serverListener.wait(); - } catch (final InterruptedException e) { - e.printStackTrace(); - } - } - } - assertTrue(this.serverListener.up); + public void testSessionCharsAccBoth() throws Exception { + this.serverSession.channelActive(null); + assertEquals(1, this.receivedMsgs.size()); + assertTrue(this.receivedMsgs.get(0) instanceof Open); + this.serverSession.handleMessage(this.openmsg); + assertEquals(2, this.receivedMsgs.size()); + assertTrue(this.receivedMsgs.get(1) instanceof Keepalive); + this.serverSession.handleMessage(this.kamsg); + assertEquals(this.serverSession.getState(), DefaultPCEPSessionNegotiator.State.Finished); // Thread.sleep(PCEPSessionImpl.KEEP_ALIVE_TIMER_VALUE * 1000); // assertEquals(3, this.client.getListMsg().size()); // assertTrue(this.client.getListMsg().get(2) instanceof PCEPKeepAliveMessage); // test of keepalive timer @@ -78,62 +126,53 @@ public class FiniteStateMachineTest { /** * Mock PCE does not accept session characteristics the first time. * - * @throws InterruptedException + * @throws Exception */ @Test - @Ignore - public void testSessionCharsAccMe() throws InterruptedException { - // this.serverSession.startSession(); - // this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(4, 9, 2))); - assertEquals(2, this.client.getListMsg().size()); - assertTrue(this.client.getListMsg().get(0) instanceof OpenMessage); - assertTrue(this.client.getListMsg().get(1) instanceof KeepaliveMessage); - // this.client.sendErrorMessage(PCEPErrors.NON_ACC_NEG_SESSION_CHAR, new PCEPOpenObject(3, 7, 2, null)); - assertEquals(3, this.client.getListMsg().size()); - assertTrue(this.client.getListMsg().get(2) instanceof OpenMessage); - this.client.sendMessage((Message) new KeepaliveMessageBuilder().build()); - synchronized (this.serverListener) { - while (!this.serverListener.up) { - try { - this.serverListener.wait(); - } catch (final InterruptedException e) { - e.printStackTrace(); - } - } - } - assertTrue(this.serverListener.up); + public void testSessionCharsAccMe() throws Exception { + this.serverSession.channelActive(null); + assertEquals(1, this.receivedMsgs.size()); + assertTrue(this.receivedMsgs.get(0) instanceof Open); + this.serverSession.handleMessage(this.openmsg); + assertEquals(2, this.receivedMsgs.size()); + assertTrue(this.receivedMsgs.get(1) instanceof Keepalive); + this.serverSession.handleMessage(createErrorMessageWOpen(PCEPErrors.NON_ACC_NEG_SESSION_CHAR)); + assertEquals(3, this.receivedMsgs.size()); + assertTrue(this.receivedMsgs.get(2) instanceof Open); + this.serverSession.handleMessage(this.kamsg); + assertEquals(this.serverSession.getState(), DefaultPCEPSessionNegotiator.State.Finished); + } + + private Pcerr createErrorMessageWOpen(PCEPErrors e) { + final PCEPErrorMapping maping = PCEPErrorMapping.getInstance(); + return new PcerrBuilder().setPcerrMessage( + new PcerrMessageBuilder().setErrorType( + new SessionBuilder().setOpen( + new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setKeepalive( + (short) 1).build()).build()).setErrors( + Arrays.asList(new ErrorsBuilder().setErrorObject( + new ErrorObjectBuilder().setType(maping.getFromErrorsEnum(e).type).setValue( + maping.getFromErrorsEnum(e).value).build()).build())).build()).build(); } /** * Sending different PCEP Message than Open in session establishment phase. * - * @throws InterruptedException + * @throws Exception */ @Test - @Ignore - public void testErrorOneOne() throws InterruptedException { - // this.serverSession.startSession(); - assertEquals(1, this.client.getListMsg().size()); - // assertTrue(this.client.getListMsg().get(0) instanceof OpenMessage); - // this.client.sendMessage(new PCEPNotificationMessage(new ArrayList() { - // private static final long serialVersionUID = 1L; - // - // { - // this.add(new CompositeNotifyObject(new ArrayList() { - // private static final long serialVersionUID = 1L; - // - // { - // this.add(new PCEPNotificationObject((short) 1, (short) 1)); - // } - // })); - // } - // })); - // for (final Message m : this.client.getListMsg()) { - // if (m instanceof PCEPErrorMessage) { - // final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0); - // assertEquals(PCEPErrors.NON_OR_INVALID_OPEN_MSG, obj.getError()); - // } - // } + public void testErrorOneOne() throws Exception { + this.serverSession.channelActive(null); + assertEquals(1, this.receivedMsgs.size()); + assertTrue(this.receivedMsgs.get(0) instanceof Open); + this.serverSession.handleMessage(this.kamsg); + for (final Notification m : this.receivedMsgs) { + if (m instanceof Pcerr) { + final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0); + assertEquals(new Short((short) 1), obj.getErrorObject().getType()); + assertEquals(new Short((short) 1), obj.getErrorObject().getValue()); + } + } } /************* Tests commented because of their long duration (tested timers) **************/ @@ -147,8 +186,8 @@ public class FiniteStateMachineTest { @Ignore public void testErrorOneTwo() throws InterruptedException { // this.serverSession.startSession(); - assertEquals(1, this.client.getListMsg().size()); - assertTrue(this.client.getListMsg().get(0) instanceof OpenMessage); + assertEquals(1, this.receivedMsgs.size()); + assertTrue(this.receivedMsgs.get(0) instanceof OpenMessage); // Thread.sleep(60 * 1000); // for (final Message m : this.client.getListMsg()) { // if (m instanceof PcerrMessage) { @@ -182,45 +221,44 @@ public class FiniteStateMachineTest { @Test @Ignore public void testUnknownMessage() throws InterruptedException { - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(1, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(10000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(2, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(10000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(3, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(20000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(4, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(30000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(3, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(10000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(3, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(5000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(4, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(1000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - assertEquals(5, this.serverSession.unknownMessagesTimes.size()); - Thread.sleep(1000); - this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - synchronized (this.client) { - while (!this.client.down) { - try { - this.client.wait(); - } catch (final InterruptedException e) { - e.printStackTrace(); - } - } - } - assertTrue(this.client.down); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(1, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(10000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(2, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(10000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(3, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(20000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(4, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(30000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(3, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(10000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(3, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(5000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(4, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(1000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // assertEquals(5, this.serverSession.unknownMessagesTimes.size()); + // Thread.sleep(1000); + // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + // synchronized (this.client) { + // while (!this.client.down) { + // try { + // this.client.wait(); + // } catch (final InterruptedException e) { + // e.printStackTrace(); + // } + // } + // } + // assertTrue(this.client.down); } @After public void tearDown() { - this.serverSession.close(); } } diff --git a/pcep/pom.xml b/pcep/pom.xml index aaf0c694b3..3fd5ca0632 100644 --- a/pcep/pom.xml +++ b/pcep/pom.xml @@ -23,6 +23,8 @@ testtool topology-api topology-provider + api-config + impl-config topology-spi tunnel-api tunnel-provider diff --git a/pom.xml b/pom.xml index 4c1843d4b3..3ccc6c03d5 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,7 @@ 5.0.0 0.5.9-SNAPSHOT + 0.2.2-SNAPSHOT 0.6.0-SNAPSHOT 2010.09.24.1 @@ -149,6 +150,7 @@ target/generated-sources/sal + target/generated-sources/config