BUG-139: PCEP capabilities refactor 85/24585/18
authorIveta Halanova <iveta.halanova@pantheon.sk>
Wed, 29 Jul 2015 12:14:04 +0000 (14:14 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 6 Aug 2015 10:06:47 +0000 (10:06 +0000)
Created pcep-capability indentity in exchange for factory of stateful07 session proposal.
PCEPCapability is implemented for stateful07 as PCEPStatefulCapability and for segment
routing as PCEPSegmentRoutingCapability.
Capabilities are add via TLVs to Open message.
Code preparation for including LS DB version number in Open message.
Unit tests updates and corretion of other influenced code.

Change-Id: Id9a6cf7f6cd24823430084dcaf10f60a70ea42f2
Signed-off-by: Milos Fabian <milfabia@cisco.com>
Signed-off-by: Iveta Halanova <iveta.halanova@pantheon.sk>
42 files changed:
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java [new file with mode: 0644]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPDispatcher.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java [new file with mode: 0644]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionProposalFactory.java
pcep/api/src/main/yang/odl-pcep-api-cfg.yang
pcep/controller-config/src/main/resources/initial/32-pcep.xml
pcep/controller-config/src/main/resources/initial/33-pcep-segment-routing.xml
pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/PCEPStatefulCapabilityModule.java [new file with mode: 0644]
pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/PCEPStatefulCapabilityModuleFactory.java [moved from pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/Stateful07PCEPSessionProposalFactoryModuleFactory.java with 53% similarity]
pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/Stateful07PCEPSessionProposalFactoryModule.java [deleted file]
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/PCEPStatefulCapability.java [moved from pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/initiated00/Stateful07SessionProposalFactory.java with 53% similarity]
pcep/ietf-stateful07/src/main/yang/odl-pcep-ietf-stateful07-cfg.yang
pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPStatefulCapabilityModuleTest.java [new file with mode: 0644]
pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPStatefulCapabilityTest.java [moved from pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/Stateful07SessionProposalFactoryTest.java with 62% similarity]
pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/Stateful07SessionProposalFactoryModuleTest.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPDispatcherImplModule.java
pcep/impl/src/main/java/org/opendaylight/controller/config/yang/pcep/impl/PCEPSessionProposalFactoryImplModule.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiatorFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/BasePCEPSessionProposalFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/DefaultPCEPSessionNegotiatorFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionNegotiator.java
pcep/impl/src/main/yang/odl-pcep-impl-cfg.yang
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImplTest.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/Main.java
pcep/pcc-mock/src/main/java/org/opendaylight/protocol/pcep/pcc/mock/PCCDispatcher.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCMockTest.java
pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/PCEPSegmentRoutingCapabilityModule.java [new file with mode: 0644]
pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/PCEPSegmentRoutingCapabilityModuleFactory.java [moved from pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SrPCEPSessionProposalFactoryModuleFactory.java with 69% similarity]
pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SrPCEPSessionProposalFactoryModule.java [deleted file]
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapability.java [moved from pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SegmentRoutingSessionProposalFactory.java with 64% similarity]
pcep/segment-routing/src/main/yang/odl-pcep-segment-routing-cfg.yang
pcep/segment-routing/src/test/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/PCEPSegmentRoutingCapabilityModuleTest.java [new file with mode: 0644]
pcep/segment-routing/src/test/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SrPCEPSessionProposalFactoryModuleTest.java [deleted file]
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapabilityTest.java [new file with mode: 0644]
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/SegmentRouting02SessionProposalTest.java [deleted file]
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/Main.java
pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/PCCMock.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPTopologyProvider.java
pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/PCEPTopologyProviderModuleTest.java
pcep/tunnel-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/tunnel/provider/PCEPTunnelTopologyProviderModuleTest.java

diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java
new file mode 100644 (file)
index 0000000..a78d076
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.pcep;
+
+import java.net.InetSocketAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+
+/**
+ * Stores usability for available capabilities
+ */
+public interface PCEPCapability {
+
+    /**
+     * Sets stateful capabilities tlv in incoming builder
+     *
+     * @param address
+     * @param builder for TLVs included in PCEPOpenObject
+     */
+    void setCapabilityProposal(InetSocketAddress address, TlvsBuilder builder);
+
+}
index b522a256f105794ad38a94bb9fb5a377b1d750e7..aadbbdcac54c713e2225440f7c3fdca60207413d 100644 (file)
@@ -8,9 +8,7 @@
 package org.opendaylight.protocol.pcep;
 
 import io.netty.channel.ChannelFuture;
-
 import java.net.InetSocketAddress;
-
 import org.opendaylight.tcpmd5.api.KeyMapping;
 
 /**
@@ -22,9 +20,10 @@ public interface PCEPDispatcher {
      *
      * @param address to be bound with the server
      * @param listenerFactory to create listeners for clients
+     * @param peerProposal information used in our Open message
      * @return instance of PCEPServer
      */
-    ChannelFuture createServer(InetSocketAddress address, PCEPSessionListenerFactory listenerFactory);
+    ChannelFuture createServer(InetSocketAddress address, PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal);
 
     /**
      * Creates server. Each server needs three factories to pass their instances to client sessions.
@@ -32,7 +31,8 @@ public interface PCEPDispatcher {
      * @param address to be bound with the server
      * @param keys RFC2385 key mapping
      * @param listenerFactory to create listeners for clients
+     * @param peerProposal information used in our Open message
      * @return instance of PCEPServer
      */
-    ChannelFuture createServer(InetSocketAddress address, KeyMapping keys, PCEPSessionListenerFactory listenerFactory);
+    ChannelFuture createServer(InetSocketAddress address, KeyMapping keys, PCEPSessionListenerFactory listenerFactory, PCEPPeerProposal peerProposal);
 }
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPPeerProposal.java
new file mode 100644 (file)
index 0000000..9906d67
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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.pcep;
+
+import java.net.InetSocketAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+
+/**
+ * Proposal from peer for establishment of PCEP session
+ */
+public interface PCEPPeerProposal {
+
+    /**
+     * Sets specific TLVs into incoming builder
+     *
+     * @param address
+     * @param openBuilder
+     */
+    void setPeerSpecificProposal(InetSocketAddress address, TlvsBuilder openBuilder);
+
+}
index c0ee7e1da7f0abc1f138ab2cf5f676742cfc9b29..01e55ddb82b6ed0d613e6c581b27723030a2806e 100644 (file)
@@ -10,6 +10,21 @@ package org.opendaylight.protocol.pcep;
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
 
+/**
+ * Factory for creating PCEP session negotiator
+ *
+ * @param <S>
+ */
 public interface PCEPSessionNegotiatorFactory<S extends PCEPSession> {
-    SessionNegotiator getSessionNegotiator(PCEPSessionListenerFactory sessionListenerFactory, Channel channel, Promise<S> promise);
+
+    /**
+     * Creates PCEPSessionNegotiator instance for income attributes
+     *
+     * @param sessionListenerFactory
+     * @param channel
+     * @param promise
+     * @param peerProposal for including information from peer to our Open message
+     * @return PCEPSessionNegotiator instance
+     */
+    SessionNegotiator getSessionNegotiator(PCEPSessionListenerFactory sessionListenerFactory, Channel channel, Promise<S> promise, final PCEPPeerProposal peerProposal);
 }
index 612a66e7913fc097722dfb7aae51ff46bd7903be..894f5a6c2b4021850faf34deee49cd2551ed6591 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.protocol.pcep;
 
 import java.net.InetSocketAddress;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 
 /**
@@ -25,4 +24,14 @@ public interface PCEPSessionProposalFactory {
      * @return specific session proposal
      */
     Open getSessionProposal(InetSocketAddress address, int sessionId);
+
+    /**
+     *
+     * @param address serves as constraint, so that factory is able to return different proposals for different
+     *        addresses
+     * @param sessionId is used for creation of PCEPOpenObject
+     * @param peerProposal for including information from peer to our Open message
+     * @return specific session proposal
+     */
+    Open getSessionProposal(InetSocketAddress address, int sessionId, PCEPPeerProposal peerProposal);
 }
index 48acfabd6bfd3bc32e2ca310774ceb74c6c788b1..dd5e2ba888590202adf586c5f71ebe8742f51af2 100644 (file)
@@ -43,5 +43,12 @@ module odl-pcep-api-cfg {
         base "config:service-type";
         config:java-class "org.opendaylight.protocol.pcep.PCEPSessionProposalFactory";
     }
+
+    identity pcep-capability {
+        description "Service for storing usability of specific capabilities during
+            opened PCEP session.";
+        base "config:service-type";
+        config:java-class "org.opendaylight.protocol.pcep.PCEPCapability";
+    }
 }
 
index 5c369e189e42b95dbcfe88e6b94b0c0ff0b7248a..9bb51fc20222c73b9db77fa02b80f857addd6122 100644 (file)
                     <name>pcep-parser-sync-optimizations</name>
                 </module>
                 <module>
-                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-session-proposal-factory-impl</type>
-                    <name>global-pcep-session-proposal-factory</name>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:stateful07:cfg">prefix:stateful-capability</type>
+                    <name>stateful-capability</name>
                 </module>
                 <module>
-                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:stateful07:cfg">prefix:pcep-session-proposal-factory-stateful07</type>
-                    <name>stateful07-prop</name>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-session-proposal-factory-impl</type>
+                    <name>global-pcep-session-proposal-factory</name>
+                    <capability>
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep">prefix:pcep-capability</type>
+                        <name>stateful-capability</name>
+                    </capability>
                 </module>
                 <module>
                     <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-dispatcher-impl</type>
@@ -75,7 +79,7 @@
                     </pcep-extensions>
                     <pcep-session-proposal-factory>
                         <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
-                        <name>stateful07-proposal</name>
+                        <name>global-pcep-session-proposal-factory</name>
                     </pcep-session-proposal-factory>
                     <boss-group>
                         <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
                     </instance>
                 </service>
                 <service>
-                    <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep">prefix:pcep-capability</type>
                     <instance>
-                        <name>stateful07-proposal</name>
-                        <provider>/config/modules/module[name='pcep-session-proposal-factory-stateful07']/instance[name='stateful07-prop']</provider>
+                        <name>stateful-capability</name>
+                        <provider>/config/modules/module[name='stateful-capability']/instance[name='stateful-capability']</provider>
                     </instance>
                 </service>
 
                         <provider>/config/modules/module[name='pcep-dispatcher-impl']/instance[name='global-pcep-dispatcher']</provider>
                     </instance>
                 </service>
+                <service>
+                    <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
+                    <instance>
+                        <name>global-pcep-session-proposal-factory</name>
+                        <provider>/config/modules/module[name='pcep-session-proposal-factory-impl']/instance[name='global-pcep-session-proposal-factory']</provider>
+                    </instance>
+                </service>
             </services>
         </data>
 
index c30655e1dc5313da8c041fa830eb47fe7329681f..bb8dd75f0cb863eccd07d017feac9372bbf029d4 100644 (file)
                     <name>pcep-parser-segment-routing</name>
                 </module>
                 <module>
-                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg">prefix:pcep-session-proposal-factory-sr</type>
-                    <name>pcep-session-proposal-factory-sr</name>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:sr:cfg">prefix:pcep-segment-routing-capability</type>
+                    <name>pcep-segment-routing-capability</name>
                 </module>
                 <module>
-                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-dispatcher-impl</type>
-                    <name>global-pcep-dispatcher</name>
-                    <pcep-extensions>
-                        <type xmlns:pcepspi="urn:opendaylight:params:xml:ns:yang:controller:pcep:spi">pcepspi:extensions</type>
-                        <name>global-pcep-extensions</name>
-                    </pcep-extensions>
-                    <pcep-session-proposal-factory>
-                        <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
-                        <name>pcep-session-proposal-factory-sr</name>
-                    </pcep-session-proposal-factory>
-                    <boss-group>
-                        <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
-                        <name>global-boss-group</name>
-                    </boss-group>
-                    <worker-group>
-                        <type xmlns:netty="urn:opendaylight:params:xml:ns:yang:controller:netty">netty:netty-threadgroup</type>
-                        <name>global-worker-group</name>
-                    </worker-group>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep:impl">prefix:pcep-session-proposal-factory-impl</type>
+                    <name>global-pcep-session-proposal-factory</name>
+                    <capability>
+                        <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep">prefix:pcep-capability</type>
+                        <name>pcep-segment-routing-capability</name>
+                    </capability>
                 </module>
             </modules>
             <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
                     </instance>
                 </service>
                 <service>
-                    <type xmlns:pcep="urn:opendaylight:params:xml:ns:yang:controller:pcep">pcep:pcep-session-proposal-factory</type>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:pcep">prefix:pcep-capability</type>
                     <instance>
-                        <name>pcep-session-proposal-factory-sr</name>
-                        <provider>/config/modules/module[name='pcep-session-proposal-factory-sr']/instance[name='pcep-session-proposal-factory-sr']</provider>
+                        <name>pcep-segment-routing-capability</name>
+                        <provider>/config/modules/module[name='pcep-segment-routing-capability']/instance[name='pcep-segment-routing-capability']</provider>
                     </instance>
                 </service>
            </services>
diff --git a/pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/PCEPStatefulCapabilityModule.java b/pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/PCEPStatefulCapabilityModule.java
new file mode 100644 (file)
index 0000000..b123edf
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.controller.config.yang.pcep.stateful07.cfg;
+
+import com.google.common.base.Preconditions;
+import java.net.InetSocketAddress;
+import org.opendaylight.protocol.pcep.PCEPCapability;
+import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+
+public class PCEPStatefulCapabilityModule extends org.opendaylight.controller.config.yang.pcep.stateful07.cfg.AbstractPCEPStatefulCapabilityModule {
+
+    public PCEPStatefulCapabilityModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public PCEPStatefulCapabilityModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            final PCEPStatefulCapabilityModule oldModule, final java.lang.AutoCloseable oldInstance) {
+
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    protected void customValidation() {
+        if ((getActive() || getTriggeredInitialSync() || getTriggeredResync() || getDeltaLspSyncCapability() || getIncludeDbVersion()) && !getStateful()) {
+            setStateful(true);
+        }
+        if ((getTriggeredInitialSync() || getDeltaLspSyncCapability()) && !getIncludeDbVersion()) {
+            setIncludeDbVersion(true);
+        }
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        final PCEPStatefulCapability capabilityImpl = new PCEPStatefulCapability(getStateful(), getActive(), getInitiated(),
+            getTriggeredInitialSync(), getTriggeredResync(), getDeltaLspSyncCapability(), getIncludeDbVersion());
+        return new PCEPCapabilityImplCloseable(capabilityImpl);
+    }
+
+    private static final class PCEPCapabilityImplCloseable implements PCEPCapability, AutoCloseable {
+        private final PCEPStatefulCapability innerCapabilityImpl;
+        public PCEPCapabilityImplCloseable(final PCEPStatefulCapability capabilityImpl) {
+            this.innerCapabilityImpl = Preconditions.checkNotNull(capabilityImpl);
+        }
+        @Override
+        public void close() {
+        }
+        @Override
+        public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
+            this.innerCapabilityImpl.setCapabilityProposal(address, builder);
+        }
+    }
+}
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 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,
@@ -7,10 +7,6 @@
  */
 package org.opendaylight.controller.config.yang.pcep.stateful07.cfg;
 
-/**
- *
- */
-public class Stateful07PCEPSessionProposalFactoryModuleFactory extends
-        org.opendaylight.controller.config.yang.pcep.stateful07.cfg.AbstractStateful07PCEPSessionProposalFactoryModuleFactory {
+public class PCEPStatefulCapabilityModuleFactory extends AbstractPCEPStatefulCapabilityModuleFactory {
 
 }
diff --git a/pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/Stateful07PCEPSessionProposalFactoryModule.java b/pcep/ietf-stateful07/src/main/java/org/opendaylight/controller/config/yang/pcep/stateful07/cfg/Stateful07PCEPSessionProposalFactoryModule.java
deleted file mode 100644 (file)
index 59d9a2e..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2014 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.controller.config.yang.pcep.stateful07.cfg;
-
-import com.google.common.base.Preconditions;
-import java.net.InetSocketAddress;
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.ietf.initiated00.Stateful07SessionProposalFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- *
- */
-public final class Stateful07PCEPSessionProposalFactoryModule extends
-        org.opendaylight.controller.config.yang.pcep.stateful07.cfg.AbstractStateful07PCEPSessionProposalFactoryModule {
-    private static final Logger LOG = LoggerFactory.getLogger(Stateful07PCEPSessionProposalFactoryModule.class);
-
-    private static final String VALUE_IS_NOT_SET = "value is not set.";
-
-    private static final int DT_KA_RATIO = 4;
-
-    public Stateful07PCEPSessionProposalFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public Stateful07PCEPSessionProposalFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier,
-            final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            final Stateful07PCEPSessionProposalFactoryModule oldModule, final java.lang.AutoCloseable oldInstance) {
-
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    protected void customValidation() {
-        JmxAttributeValidationException.checkNotNull(getActive(), VALUE_IS_NOT_SET, activeJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getInitiated(), VALUE_IS_NOT_SET, initiatedJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getDeadTimerValue(), VALUE_IS_NOT_SET, deadTimerValueJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getKeepAliveTimerValue(), VALUE_IS_NOT_SET, keepAliveTimerValueJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getTriggeredInitialSync(), VALUE_IS_NOT_SET, triggeredInitialSyncJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getTriggeredResync(), VALUE_IS_NOT_SET, triggeredResyncJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getDeltaLspSyncCapability(), VALUE_IS_NOT_SET, deltaLspSyncCapabilityJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getIncludeDbVersion(), VALUE_IS_NOT_SET, includeDbVersionJmxAttribute);
-        validateTimers();
-        if ((getActive() || getTriggeredInitialSync() || getTriggeredResync() || getDeltaLspSyncCapability() || getIncludeDbVersion()) && !getStateful()) {
-            setStateful(true);
-        }
-        if ((getTriggeredInitialSync() || getDeltaLspSyncCapability()) && !getIncludeDbVersion()) {
-            setIncludeDbVersion(true);
-        }
-        JmxAttributeValidationException.checkNotNull(getStateful(), VALUE_IS_NOT_SET, statefulJmxAttribute);
-    }
-
-    private void validateTimers() {
-        if (getKeepAliveTimerValue() != 0) {
-            JmxAttributeValidationException.checkCondition(getKeepAliveTimerValue() >= 1, "minimum value is 1.",
-                    keepAliveTimerValueJmxAttribute);
-            if (getDeadTimerValue() != 0 && (getDeadTimerValue() / getKeepAliveTimerValue() != DT_KA_RATIO)) {
-                LOG.warn("DeadTimerValue should be 4 times greater than KeepAliveTimerValue");
-            }
-        }
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final Stateful07SessionProposalFactory inner = new Stateful07SessionProposalFactory(getDeadTimerValue(), getKeepAliveTimerValue(), getStateful(), getActive(), getInitiated(),
-            getTriggeredInitialSync(), getTriggeredResync(), getDeltaLspSyncCapability(), getIncludeDbVersion());
-        return new PCEPSessionProposalFactoryCloseable(inner);
-    }
-
-    private static final class PCEPSessionProposalFactoryCloseable implements PCEPSessionProposalFactory, AutoCloseable {
-        private final Stateful07SessionProposalFactory inner;
-
-        public PCEPSessionProposalFactoryCloseable(final Stateful07SessionProposalFactory inner) {
-            this.inner = Preconditions.checkNotNull(inner);
-        }
-
-        @Override
-        public void close() {
-        }
-
-        @Override
-        public Open getSessionProposal(final InetSocketAddress inetSocketAddress, final int sessionId) {
-            return this.inner.getSessionProposal(inetSocketAddress, sessionId);
-        }
-    }
-}
@@ -1,14 +1,14 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ * 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.pcep.ietf.initiated00;
+package org.opendaylight.protocol.pcep.ietf.stateful07;
 
 import java.net.InetSocketAddress;
-import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
@@ -16,13 +16,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.iet
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
 
-public class Stateful07SessionProposalFactory extends BasePCEPSessionProposalFactory {
+public class PCEPStatefulCapability implements PCEPCapability {
 
     private final boolean stateful, active, instant, triggeredSync, triggeredResync, deltaLspSync, includeDbVersion;
 
-    public Stateful07SessionProposalFactory(final int deadTimer, final int keepAlive, final boolean stateful, final boolean active,
-            final boolean instant, final boolean triggeredSync, final boolean triggeredResync, final boolean deltaLspSync, final boolean includeDbVersion) {
-        super(deadTimer, keepAlive);
+    public PCEPStatefulCapability(final boolean stateful, final boolean active, final boolean instant,
+        final boolean triggeredSync, final boolean triggeredResync, final boolean deltaLspSync, final boolean includeDbVersion){
         this.stateful = stateful;
         this.active = active;
         this.instant = instant;
@@ -33,20 +32,20 @@ public class Stateful07SessionProposalFactory extends BasePCEPSessionProposalFac
     }
 
     @Override
-    protected void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
-        if (Stateful07SessionProposalFactory.this.stateful) {
+    public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
+        if (this.stateful) {
             builder.addAugmentation(
-                    Tlvs1.class,
-                    new Tlvs1Builder().setStateful(
-                            new StatefulBuilder().setLspUpdateCapability(this.active)
-                            .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(this.instant).build())
-                            .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1Builder()
-                                .setTriggeredInitialSync(this.triggeredSync)
-                                .setTriggeredResync(this.triggeredResync)
-                                .setDeltaLspSyncCapability(this.deltaLspSync)
-                                .setIncludeDbVersion(this.includeDbVersion)
-                                .build())
-                            .build()).build()).build();
+                Tlvs1.class, new Tlvs1Builder()
+                    .setStateful( new StatefulBuilder().setLspUpdateCapability(this.active)
+                        .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(this.instant).build())
+                        .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1Builder()
+                            .setTriggeredInitialSync(this.triggeredSync)
+                            .setTriggeredResync(this.triggeredResync)
+                            .setDeltaLspSyncCapability(this.deltaLspSync)
+                            .setIncludeDbVersion(this.includeDbVersion)
+                            .build())
+                        .build())
+                    .build());
         }
     }
 
index 9e0d22b644ba95666b440dafe2466db32ea78aed..74e5a95222c3de74ece5ec8c00359503316afe5f 100644 (file)
@@ -33,10 +33,10 @@ module odl-pcep-ietf-stateful07-cfg {
             "Updated revision dates for imports.";
     }
 
-    identity pcep-session-proposal-factory-stateful07 {
+    identity stateful-capability {
         base config:module-type;
-        config:java-name-prefix "Stateful07PCEPSessionProposalFactory";
-        config:provided-service pcep:pcep-session-proposal-factory;
+        config:java-name-prefix "PCEPStatefulCapability";
+        config:provided-service pcep:pcep-capability;
     }
 
     grouping stateful-capabilities {
@@ -87,8 +87,8 @@ module odl-pcep-ietf-stateful07-cfg {
     }
 
     augment "/config:modules/config:module/config:configuration" {
-        case pcep-session-proposal-factory-stateful07 {
-            when "/config:modules/config:module/config:type = 'pcep-session-proposal-factory-stateful07'";
+        case stateful-capability {
+            when "/config:modules/config:module/config:type = 'stateful-capability'";
             uses stateful-capabilities;
         }
     }
diff --git a/pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPStatefulCapabilityModuleTest.java b/pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPStatefulCapabilityModuleTest.java
new file mode 100644 (file)
index 0000000..ae29374
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * 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.pcep.ietf;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.PCEPStatefulCapabilityModuleFactory;
+import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.PCEPStatefulCapabilityModuleMXBean;
+
+public class PCEPStatefulCapabilityModuleTest extends AbstractConfigTest {
+
+    private static final String INSTANCE_NAME = "stateful-capability";
+    private static final String FACTORY_NAME = PCEPStatefulCapabilityModuleFactory.NAME;
+
+    @Before
+    public void setUp() throws Exception {
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new PCEPStatefulCapabilityModuleFactory()));
+    }
+
+    @Test
+    public void testStatefulAfterCommitted() throws Exception {
+        createInstance(false, true, true, true, false, true, true);
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        final PCEPStatefulCapabilityModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
+                FACTORY_NAME, INSTANCE_NAME), PCEPStatefulCapabilityModuleMXBean.class);
+        assertTrue(mxBean.getStateful());
+    }
+
+    @Test
+    public void testNotStatefulAfterCommitted() throws Exception {
+        createInstance(false, false, false, false, false, false, false);
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        final PCEPStatefulCapabilityModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
+                FACTORY_NAME, INSTANCE_NAME), PCEPStatefulCapabilityModuleMXBean.class);
+        assertFalse(mxBean.getStateful());
+    }
+
+    @Test
+    public void testIncludeDbVersionAfterCommitted() throws Exception {
+        createInstance(false, false, false, false, false, true, false);
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        final PCEPStatefulCapabilityModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
+                FACTORY_NAME, INSTANCE_NAME), PCEPStatefulCapabilityModuleMXBean.class);
+        assertTrue(mxBean.getIncludeDbVersion());
+    }
+
+    @Test
+    public void testNotIncludeDbVersionAfterCommitted() throws Exception {
+        createInstance(false, false, false, false, false, false, false);
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        final PCEPStatefulCapabilityModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
+                FACTORY_NAME, INSTANCE_NAME), PCEPStatefulCapabilityModuleMXBean.class);
+        assertFalse(mxBean.getIncludeDbVersion());
+    }
+
+    @Test
+    public void testCreateBean() throws Exception {
+        final CommitStatus status = createInstance();
+        assertBeanCount(1, FACTORY_NAME);
+        assertStatus(status, 1, 0, 0);
+    }
+
+    @Test
+    public void testReusingOldInstance() throws Exception {
+        createInstance();
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        assertBeanCount(1, FACTORY_NAME);
+        final CommitStatus status = transaction.commit();
+        assertBeanCount(1, FACTORY_NAME);
+        assertStatus(status, 0, 0, 1);
+    }
+
+    @Test
+    public void testReconfigure() throws Exception {
+        createInstance();
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        assertBeanCount(1, FACTORY_NAME);
+        transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
+            PCEPStatefulCapabilityModuleMXBean.class);
+        final CommitStatus status = transaction.commit();
+        assertBeanCount(1, FACTORY_NAME);
+        assertStatus(status, 0, 0, 1);
+    }
+
+    private CommitStatus createInstance(final Boolean stateful, final Boolean active, final Boolean instant,
+        final Boolean triggeredInitialSync, final Boolean triggeredResync, final Boolean deltaLspSyncCapability,
+        final Boolean includeDbVersion) throws Exception {
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        createInstance(transaction, stateful, active, instant, triggeredInitialSync, triggeredResync, deltaLspSyncCapability, includeDbVersion);
+        return transaction.commit();
+    }
+
+    private CommitStatus createInstance() throws Exception {
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        createPCEPCapabilityInstance(transaction);
+        return transaction.commit();
+    }
+
+    public static ObjectName createPCEPCapabilityInstance(final ConfigTransactionJMXClient transaction) throws Exception {
+        return createInstance(transaction, true, true, true, true, true, true, true);
+    }
+
+    private static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Boolean stateful, final Boolean active, final Boolean instant,
+            final Boolean triggeredInitialSync, final Boolean triggeredResync, final Boolean deltaLspSyncCapability, final Boolean includeDbVersion) throws InstanceAlreadyExistsException {
+        final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+        final PCEPStatefulCapabilityModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
+            PCEPStatefulCapabilityModuleMXBean.class);
+        mxBean.setActive(active);
+        mxBean.setInitiated(instant);
+        mxBean.setStateful(stateful);
+        mxBean.setTriggeredInitialSync(triggeredInitialSync);
+        mxBean.setTriggeredResync(triggeredResync);
+        mxBean.setDeltaLspSyncCapability(deltaLspSyncCapability);
+        mxBean.setIncludeDbVersion(includeDbVersion);
+        return nameCreated;
+    }
+}
similarity index 62%
rename from pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/Stateful07SessionProposalFactoryTest.java
rename to pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/PCEPStatefulCapabilityTest.java
index 498724baf8ea6f4bf95cda1a85628e05b36e7e35..197d1adc6522f79f6c79f8a3480ec1ee3a1078a7 100644 (file)
@@ -1,36 +1,29 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * 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.pcep.ietf;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.opendaylight.protocol.pcep.ietf.initiated00.Stateful07SessionProposalFactory;
+import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
 
-public class Stateful07SessionProposalFactoryTest {
+public class PCEPStatefulCapabilityTest {
 
-    private static final int DEAD_TIMER = 4;
-    private static final int KEEP_ALIVE = 1;
-    private static final int SESSION_ID = 1;
-    private static final Open OPEN_MSG = new OpenBuilder()
-            .setDeadTimer((short) DEAD_TIMER)
-            .setKeepalive((short) KEEP_ALIVE)
-            .setSessionId((short) SESSION_ID)
-            .setTlvs(new TlvsBuilder()
-                .addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(new StatefulBuilder()
+    private static final Tlvs EXPECTED_TLVS =
+        new TlvsBuilder().addAugmentation(
+            Tlvs1.class, new Tlvs1Builder()
+                .setStateful( new StatefulBuilder().setLspUpdateCapability(true)
                     .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(true).build())
                     .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1Builder()
                         .setTriggeredInitialSync(true)
@@ -38,15 +31,13 @@ public class Stateful07SessionProposalFactoryTest {
                         .setDeltaLspSyncCapability(true)
                         .setIncludeDbVersion(false)
                         .build())
-                    .setLspUpdateCapability(true).build()).build())
+                    .build())
                 .build())
             .build();
 
     @Test
-    public void testStateful07SessionProposalFactory() {
-        final Stateful07SessionProposalFactory sspf = new Stateful07SessionProposalFactory(DEAD_TIMER, KEEP_ALIVE, true, true, true, true, false, true, false);
-        Assert.assertEquals(DEAD_TIMER, sspf.getDeadTimer());
-        Assert.assertEquals(KEEP_ALIVE, sspf.getKeepAlive());
+    public void testPCEPStatefulCapability() {
+        final PCEPStatefulCapability sspf = new PCEPStatefulCapability(true, true, true, true, false, true, false);
         Assert.assertTrue(sspf.isActive());
         Assert.assertTrue(sspf.isInstant());
         Assert.assertTrue(sspf.isStateful());
@@ -54,6 +45,8 @@ public class Stateful07SessionProposalFactoryTest {
         Assert.assertTrue(sspf.isTriggeredSync());
         Assert.assertTrue(sspf.isDeltaLspSync());
         Assert.assertFalse(sspf.isIncludeDbVersion());
-        Assert.assertEquals(OPEN_MSG, sspf.getSessionProposal(null, SESSION_ID));
+        final TlvsBuilder builder = new TlvsBuilder();
+        sspf.setCapabilityProposal(null, builder);
+        Assert.assertEquals(EXPECTED_TLVS, builder.build());
     }
 }
diff --git a/pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/Stateful07SessionProposalFactoryModuleTest.java b/pcep/ietf-stateful07/src/test/java/org/opendaylight/protocol/pcep/ietf/Stateful07SessionProposalFactoryModuleTest.java
deleted file mode 100644 (file)
index 20e3755..0000000
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.ietf;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.Stateful07PCEPSessionProposalFactoryModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.Stateful07PCEPSessionProposalFactoryModuleMXBean;
-
-public class Stateful07SessionProposalFactoryModuleTest extends AbstractConfigTest {
-
-    private static final String INSTANCE_NAME = "pcep-stateful07-proposal";
-    private static final String FACTORY_NAME = Stateful07PCEPSessionProposalFactoryModuleFactory.NAME;
-
-    @Before
-    public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new Stateful07PCEPSessionProposalFactoryModuleFactory()));
-    }
-
-    @Test
-    public void testValidationExceptionDeadTimerValueNotSet() throws Exception {
-        try {
-            createInstance(null, (short) 100, true, true, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("DeadTimerValue value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionKeepAliveTimerNotSet() throws Exception {
-        try {
-            createInstance((short) 200, null, true, true, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("KeepAliveTimerValue value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionStatefulNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, null, false, false, false, false, false, false);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("Stateful value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionActiveNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, null, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("Active value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionInstantiatedNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, null, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("Initiated value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionTriggeredSyncNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, null, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("TriggeredInitialSync value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionTriggeredResyncNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, true, null, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("TriggeredResync value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionDeltaLspSyncNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, true, true, null, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("DeltaLspSyncCapability value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionIncludeDBVersionNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, true, true, true, null);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("IncludeDbVersion value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionKeepAliveTimerMinValue() throws Exception {
-        try {
-            createInstance((short) 200, (short) -10, true, true, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("minimum value is 1."));
-        }
-    }
-
-    @Test
-    public void testStatefulAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, true, true, true, false, true, true);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertTrue(mxBean.getStateful());
-    }
-
-    @Test
-    public void testNotStatefulAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, false, false, false, false, false, false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertFalse(mxBean.getStateful());
-    }
-
-    @Test
-    public void testIncludeDbVersionAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, false, false, false, false, true, false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertTrue(mxBean.getIncludeDbVersion());
-    }
-
-    @Test
-    public void testNotIncludeDbVersionAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, false, false, false, false, false, false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertFalse(mxBean.getIncludeDbVersion());
-    }
-
-    @Test
-    public void testCreateBean() throws Exception {
-        final CommitStatus status = createInstance();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 1, 0, 0);
-    }
-
-    @Test
-    public void testReusingOldInstance() throws Exception {
-        createInstance();
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 1);
-    }
-
-    @Test
-    public void testReconfigure() throws Exception {
-        createInstance();
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
-                Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 1);
-    }
-
-    private CommitStatus createInstance(final Short deadTimer, final Short keepAlive, final Boolean stateful, final Boolean active,
-            final Boolean instant, final Boolean triggeredInitialSync, final Boolean triggeredResync, final Boolean deltaLspSyncCapability, final Boolean includeDbVersion) throws Exception {
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        createInstance(transaction, deadTimer, keepAlive, stateful, active, instant, triggeredInitialSync, triggeredResync, deltaLspSyncCapability, includeDbVersion);
-        return transaction.commit();
-    }
-
-    private CommitStatus createInstance() throws Exception {
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        createStateful07SessionProposalInstance(transaction);
-        return transaction.commit();
-    }
-
-    public static ObjectName createStateful07SessionProposalInstance(final ConfigTransactionJMXClient transaction) throws Exception {
-        return createInstance(transaction, (short) 200, (short) 100, true, true, true, true, true, true, true);
-    }
-
-    private static ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Short deadTimer, final Short keepAlive,
-            final Boolean stateful, final Boolean active, final Boolean instant,
-            final Boolean triggeredInitialSync, final Boolean triggeredResync, final Boolean deltaLspSyncCapability, final Boolean includeDbVersion) throws InstanceAlreadyExistsException {
-        final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
-                Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        mxBean.setActive(active);
-        mxBean.setDeadTimerValue(deadTimer);
-        mxBean.setInitiated(instant);
-        mxBean.setKeepAliveTimerValue(keepAlive);
-        mxBean.setStateful(stateful);
-        mxBean.setTriggeredInitialSync(triggeredInitialSync);
-        mxBean.setTriggeredResync(triggeredResync);
-        mxBean.setDeltaLspSyncCapability(deltaLspSyncCapability);
-        mxBean.setIncludeDbVersion(includeDbVersion);
-        return nameCreated;
-    }
-
-}
index 53e1ad2493494c1a42d7178d506e33151f91b222..6c2ea01facce7a1142071a0936739a8070acf876 100644 (file)
@@ -19,7 +19,6 @@ package org.opendaylight.controller.config.yang.pcep.impl;
 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 
 /**
  *
@@ -66,8 +65,7 @@ public final class PCEPDispatcherImplModule extends org.opendaylight.controller.
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        Open localPrefs = getPcepSessionProposalFactoryDependency().getSessionProposal(null, 0);
-        DefaultPCEPSessionNegotiatorFactory negFactory = new DefaultPCEPSessionNegotiatorFactory(localPrefs, getMaxUnknownMessages(), getTls());
+        final DefaultPCEPSessionNegotiatorFactory negFactory = new DefaultPCEPSessionNegotiatorFactory(getPcepSessionProposalFactoryDependency(), getMaxUnknownMessages(), getTls());
 
         return new PCEPDispatcherImpl(getPcepExtensionsDependency().getMessageHandlerRegistry(), negFactory, getBossGroupDependency(), getWorkerGroupDependency(), getMd5ServerChannelFactoryDependency());
     }
index c94ec25a59622a5f8df26d13eb151cb2a1dca989..7fa261908ccacc1e86dd8b2b48910d4979710907 100644 (file)
@@ -18,6 +18,7 @@ package org.opendaylight.controller.config.yang.pcep.impl;
 
 import java.net.InetSocketAddress;
 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
@@ -60,7 +61,7 @@ public final class PCEPSessionProposalFactoryImplModule extends
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        final BasePCEPSessionProposalFactory inner = new BasePCEPSessionProposalFactory(getDeadTimerValue(), getKeepAliveTimerValue());
+        final BasePCEPSessionProposalFactory inner = new BasePCEPSessionProposalFactory(getDeadTimerValue(), getKeepAliveTimerValue(), getCapabilityDependency());
         return new PCEPSessionProposalFactoryCloseable(inner);
     }
 
@@ -81,5 +82,11 @@ public final class PCEPSessionProposalFactoryImplModule extends
         public Open getSessionProposal(final InetSocketAddress inetSocketAddress, final int i) {
             return this.inner.getSessionProposal(inetSocketAddress, i);
         }
+
+        @Override
+        public Open getSessionProposal(final InetSocketAddress address,
+                final int sessionId, final PCEPPeerProposal peerProposal) {
+            return this.inner.getSessionProposal(address, sessionId, peerProposal);
+        }
     }
 }
index a4abadcae89586613bdc022c65a1f6151d8cef7a..5be5d8cd59cbb4d5636f86d8291d1db374f6ab46 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.pcep.impl;
 
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
@@ -24,7 +25,7 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessio
 
     private static final Logger LOG = LoggerFactory.getLogger(AbstractPCEPSessionNegotiatorFactory.class);
 
-    private PCEPPeerRegistry sessionRegistry = new PCEPPeerRegistry();
+    private final PCEPPeerRegistry sessionRegistry = new PCEPPeerRegistry();
 
     /**
      * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
@@ -36,14 +37,14 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessio
      * @return a PCEP session negotiator
      */
     protected abstract AbstractPCEPSessionNegotiator createNegotiator(Promise<PCEPSessionImpl> promise, PCEPSessionListener listener,
-            Channel channel, short sessionId);
+            Channel channel, short sessionId, final PCEPPeerProposal peerProposal);
 
     @Override
     public final SessionNegotiator getSessionNegotiator(final PCEPSessionListenerFactory factory,
-            final Channel channel, final Promise<PCEPSessionImpl> promise) {
+            final Channel channel, final Promise<PCEPSessionImpl> promise, final PCEPPeerProposal peerProposal) {
 
         LOG.debug("Instantiating bootstrap negotiator for channel {}", channel);
-        return new PCEPSessionNegotiator(channel, promise, factory, this);
+        return new PCEPSessionNegotiator(channel, promise, factory, this, peerProposal);
     }
 
     public PCEPPeerRegistry getSessionRegistry() {
index 8eed88fe772576102fe21e43b34408719597f65a..dc187578d51e063f05338951a799b8f41346d0fb 100644 (file)
@@ -8,26 +8,39 @@
 package org.opendaylight.protocol.pcep.impl;
 
 import java.net.InetSocketAddress;
+import java.util.List;
+import org.opendaylight.protocol.pcep.PCEPCapability;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
 
-public class BasePCEPSessionProposalFactory implements PCEPSessionProposalFactory {
+final public class BasePCEPSessionProposalFactory implements PCEPSessionProposalFactory {
 
     private final int keepAlive, deadTimer;
+    private final List<PCEPCapability> capabilities;
 
-    public BasePCEPSessionProposalFactory(final int deadTimer, final int keepAlive) {
+    public BasePCEPSessionProposalFactory(final int deadTimer, final int keepAlive, final List<PCEPCapability> capabilities) {
         this.deadTimer = deadTimer;
         this.keepAlive = keepAlive;
+        this.capabilities = capabilities;
     }
 
-    protected void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
-        // No TLVs by default
+    private void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
+        for (final PCEPCapability capability : this.capabilities) {
+            capability.setCapabilityProposal(address, builder);
+        }
     }
 
     @Override
     public final Open getSessionProposal(final InetSocketAddress address, final int sessionId) {
+        return getSessionProposal(address, sessionId, null);
+    }
+
+    @Override
+    public Open getSessionProposal(final InetSocketAddress address, final int sessionId,
+            final PCEPPeerProposal peerProposal) {
         final OpenBuilder oBuilder = new OpenBuilder();
         oBuilder.setSessionId((short) sessionId);
         oBuilder.setKeepalive((short) BasePCEPSessionProposalFactory.this.keepAlive);
@@ -38,6 +51,9 @@ public class BasePCEPSessionProposalFactory implements PCEPSessionProposalFactor
         }
 
         final TlvsBuilder builder = new TlvsBuilder();
+        if (peerProposal != null) {
+            peerProposal.setPeerSpecificProposal(address, builder);
+        }
         addTlvs(address, builder);
         return oBuilder.setTlvs(builder.build()).build();
     }
@@ -49,4 +65,5 @@ public class BasePCEPSessionProposalFactory implements PCEPSessionProposalFactor
     public final int getDeadTimer() {
         return this.deadTimer;
     }
+
 }
index d32372c9eaae9e02f2620b145be89386f188f287..fb7196001a090705b001426271d84234f2089de3 100644 (file)
@@ -10,28 +10,31 @@ package org.opendaylight.protocol.pcep.impl;
 import com.google.common.base.Preconditions;
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
+import java.net.InetSocketAddress;
 import org.opendaylight.controller.config.yang.pcep.impl.Tls;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
+import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
 
 public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessionNegotiatorFactory {
-    private final Open localPrefs;
+    private final PCEPSessionProposalFactory spf;
     private final int maxUnknownMessages;
     private final Tls tlsConfiguration;
 
-    public DefaultPCEPSessionNegotiatorFactory(final Open localPrefs, final int maxUnknownMessages) {
-        this(localPrefs, maxUnknownMessages, null);
+    public DefaultPCEPSessionNegotiatorFactory(final PCEPSessionProposalFactory spf, final int maxUnknownMessages) {
+        this(spf, maxUnknownMessages, null);
     }
 
-    public DefaultPCEPSessionNegotiatorFactory(final Open localPrefs, final int maxUnknownMessages, final Tls tlsConfiguration) {
-        this.localPrefs = Preconditions.checkNotNull(localPrefs);
+    public DefaultPCEPSessionNegotiatorFactory(final PCEPSessionProposalFactory spf, final int maxUnknownMessages, final Tls tlsConfiguration) {
+        this.spf = Preconditions.checkNotNull(spf);
         this.maxUnknownMessages = maxUnknownMessages;
         this.tlsConfiguration = tlsConfiguration;
     }
 
     @Override
     protected AbstractPCEPSessionNegotiator createNegotiator(final Promise<PCEPSessionImpl> promise, final PCEPSessionListener listener,
-            final Channel channel, final short sessionId) {
-        return new DefaultPCEPSessionNegotiator(promise, channel, listener, sessionId, this.maxUnknownMessages, this.localPrefs, this.tlsConfiguration);
+            final Channel channel, final short sessionId, final PCEPPeerProposal peerProposal) {
+        return new DefaultPCEPSessionNegotiator(promise, channel, listener, sessionId, this.maxUnknownMessages,
+                this.spf.getSessionProposal((InetSocketAddress)channel.remoteAddress(), sessionId, peerProposal), this.tlsConfiguration);
     }
 }
index beea75a2713101e009ff1cde0e62f7a0ee7f4cab..94e36019e431705f34a428c63adc66fc7ea01335 100644 (file)
@@ -23,6 +23,7 @@ import io.netty.util.concurrent.Promise;
 import java.io.Closeable;
 import java.net.InetSocketAddress;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.spi.MessageRegistry;
@@ -85,20 +86,20 @@ public class PCEPDispatcherImpl implements PCEPDispatcher, Closeable {
 
     @Override
     public synchronized ChannelFuture createServer(final InetSocketAddress address,
-                                                   final PCEPSessionListenerFactory listenerFactory) {
-        return createServer(address, null, listenerFactory);
+                                                   final PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal) {
+        return createServer(address, null, listenerFactory, peerProposal);
     }
 
     @Override
     public synchronized ChannelFuture createServer(final InetSocketAddress address, final KeyMapping keys,
-                                                   final PCEPSessionListenerFactory listenerFactory) {
+                                                   final PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal) {
         this.keys = keys;
 
         final ChannelPipelineInitializer initializer = new ChannelPipelineInitializer() {
             @Override
             public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise) {
                 ch.pipeline().addLast(PCEPDispatcherImpl.this.hf.getDecoders());
-                ch.pipeline().addLast("negotiator", PCEPDispatcherImpl.this.snf.getSessionNegotiator(listenerFactory, ch, promise));
+                ch.pipeline().addLast("negotiator", PCEPDispatcherImpl.this.snf.getSessionNegotiator(listenerFactory, ch, promise, peerProposal));
                 ch.pipeline().addLast(PCEPDispatcherImpl.this.hf.getEncoders());
             }
         };
@@ -119,11 +120,11 @@ public class PCEPDispatcherImpl implements PCEPDispatcher, Closeable {
 
         try {
             b.channel(NioServerSocketChannel.class);
-        } catch (IllegalStateException e) {
+        } catch (final IllegalStateException e) {
             LOG.trace("Not overriding channelFactory on bootstrap {}", b, e);
         }
 
-        ChannelFuture f = b.bind(address);
+        final ChannelFuture f = b.bind(address);
         LOG.debug("Initiated server {} at {}.", f, address);
 
         this.keys = null;
index 82031af7de8e15f741c60710c2e33d8f76ee2fb6..8c01919f59ba53f31f244e4ee989768098917d33 100644 (file)
@@ -16,6 +16,7 @@ import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 import java.util.Comparator;
 import java.util.concurrent.ExecutionException;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPPeerRegistry.SessionReference;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -31,14 +32,17 @@ public class PCEPSessionNegotiator extends AbstractSessionNegotiator {
     private final PCEPSessionListenerFactory factory;
 
     private final AbstractPCEPSessionNegotiatorFactory negFactory;
+    private final PCEPPeerProposal peerProposal;
 
     public PCEPSessionNegotiator(final Channel channel, final Promise<PCEPSessionImpl> promise, final PCEPSessionListenerFactory factory,
-        final AbstractPCEPSessionNegotiatorFactory negFactory) {
+        final AbstractPCEPSessionNegotiatorFactory negFactory, final PCEPPeerProposal peerProposal) {
         super(promise, channel);
         this.factory = factory;
         this.negFactory = negFactory;
+        this.peerProposal = peerProposal;
     }
 
+    @Override
     protected void startNegotiation() throws ExecutionException {
         final Object lock = this;
 
@@ -71,7 +75,8 @@ public class PCEPSessionNegotiator extends AbstractSessionNegotiator {
             }
 
             final Short sessionId = sessionReg.nextSession(clientAddress);
-            final AbstractPCEPSessionNegotiator n = this.negFactory.createNegotiator(this.promise, this.factory.getSessionListener(), this.channel, sessionId);
+            final AbstractPCEPSessionNegotiator n = this.negFactory.createNegotiator(this.promise, this.factory.getSessionListener(),
+                    this.channel, sessionId, this.peerProposal);
 
             sessionReg.putSessionReference(clientAddress, new SessionReference() {
                 @Override
@@ -104,6 +109,7 @@ public class PCEPSessionNegotiator extends AbstractSessionNegotiator {
         }
     }
 
+    @Override
     protected void handleMessage(final Message msg) {
         throw new IllegalStateException("Bootstrap negotiator should have been replaced");
     }
index 6d531b45fde6e98f1a79b176827da2b58d2ff3c3..4a45bee5f772e426cc3a592e0911b58dd06315f5 100644 (file)
@@ -199,6 +199,15 @@ module odl-pcep-impl-cfg {
                 type uint8;
                 default 30;
             }
+
+            list capability {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity pcep:pcep-capability;
+                    }
+                }
+            }
         }
     }
 }
index a2c51d2cb508f1b099c905000f4ee510d8271266..2434d410845ec6540abe7e014dc146eaf7ced2e8 100644 (file)
@@ -25,6 +25,8 @@ import io.netty.util.concurrent.GlobalEventExecutor;
 import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 import java.nio.channels.Channel;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
 import org.junit.After;
 import org.junit.Assert;
@@ -35,18 +37,18 @@ import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
 import org.opendaylight.protocol.framework.NeverReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
+import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.spi.MessageRegistry;
 import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
 import org.opendaylight.tcpmd5.api.KeyAccess;
 import org.opendaylight.tcpmd5.api.KeyAccessFactory;
 import org.opendaylight.tcpmd5.api.KeyMapping;
 import org.opendaylight.tcpmd5.netty.MD5NioServerSocketChannelFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
 
 public class PCEPDispatcherImplTest {
 
@@ -68,21 +70,21 @@ public class PCEPDispatcherImplTest {
     @Before
     public void setUp() {
         MockitoAnnotations.initMocks(this);
-        final Open open = new OpenBuilder().setSessionId((short) 0).setDeadTimer(DEAD_TIMER).setKeepalive(KEEP_ALIVE)
-                .build();
+        final List<PCEPCapability> capList = new ArrayList<>();
+        final PCEPSessionProposalFactory sessionProposal = new BasePCEPSessionProposalFactory(DEAD_TIMER, KEEP_ALIVE, capList);
         final EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
         final MessageRegistry msgReg = ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance()
                 .getMessageHandlerRegistry();
-        this.dispatcher = new PCEPDispatcherImpl(msgReg, new DefaultPCEPSessionNegotiatorFactory(open, 0),
+        this.dispatcher = new PCEPDispatcherImpl(msgReg, new DefaultPCEPSessionNegotiatorFactory(sessionProposal, 0),
                 eventLoopGroup, eventLoopGroup);
 
         Mockito.doReturn("mockChannel").when(this.mockChannel).toString();
         Mockito.doReturn(this.mockKeyAccess).when(this.kaf).getKeyAccess(Mockito.any(Channel.class));
         final MD5NioServerSocketChannelFactory scf = new MD5NioServerSocketChannelFactory(this.kaf);
-        final PCEPDispatcherImpl dispatcher2 = new PCEPDispatcherImpl(msgReg, new DefaultPCEPSessionNegotiatorFactory(open, 0), eventLoopGroup, eventLoopGroup, scf);
+        final PCEPDispatcherImpl dispatcher2 = new PCEPDispatcherImpl(msgReg, new DefaultPCEPSessionNegotiatorFactory(sessionProposal, 0), eventLoopGroup, eventLoopGroup, scf);
         this.disp2Spy = Mockito.spy(dispatcher2);
 
-        this.pccMock = new PCCMock(new DefaultPCEPSessionNegotiatorFactory(open, 0),
+        this.pccMock = new PCCMock(new DefaultPCEPSessionNegotiatorFactory(sessionProposal, 0),
                 new PCEPHandlerFactory(msgReg), new DefaultPromise<PCEPSessionImpl>(
                     GlobalEventExecutor.INSTANCE));
     }
@@ -95,7 +97,7 @@ public class PCEPDispatcherImplTest {
                     public PCEPSessionListener getSessionListener() {
                         return new SimpleSessionListener();
                     }
-                });
+                }, null);
         final PCEPSessionImpl session1 = (PCEPSessionImpl) this.pccMock.createClient(CLIENT1_ADDRESS,
                 new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 500),
                 new PCEPSessionListenerFactory() {
@@ -136,7 +138,7 @@ public class PCEPDispatcherImplTest {
                     public PCEPSessionListener getSessionListener() {
                         return new SimpleSessionListener();
                     }
-                });
+                }, null);
         final PCEPSessionImpl session1 = (PCEPSessionImpl) this.pccMock.createClient(CLIENT1_ADDRESS,
             new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 500),
             new PCEPSessionListenerFactory() {
@@ -171,7 +173,7 @@ public class PCEPDispatcherImplTest {
                     public PCEPSessionListener getSessionListener() {
                         return new SimpleSessionListener();
                     }
-                });
+                }, null);
         final PCEPSessionImpl session1 = (PCEPSessionImpl) this.pccMock.createClient(CLIENT1_ADDRESS,
                 new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 500),
                 new PCEPSessionListenerFactory() {
@@ -214,7 +216,7 @@ public class PCEPDispatcherImplTest {
                 public PCEPSessionListener getSessionListener() {
                     return new SimpleSessionListener();
                 }
-            });
+            }, null);
         Mockito.verify(this.disp2Spy).customizeBootstrap(Mockito.any(ServerBootstrap.class));
     }
 
@@ -246,18 +248,18 @@ public class PCEPDispatcherImplTest {
                 @Override
                 public void initializeChannel(final SocketChannel ch, final Promise promise) {
                     ch.pipeline().addLast(PCCMock.this.factory.getDecoders());
-                    ch.pipeline().addLast("negotiator", PCCMock.this.negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
+                    ch.pipeline().addLast("negotiator", PCCMock.this.negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise, null));
                     ch.pipeline().addLast(PCCMock.this.factory.getEncoders());
                 }
             });
         }
 
-        Future<PCEPSession> createClient(InetSocketAddress address, ReconnectStrategy strategy, final PCEPDispatcherImpl.ChannelPipelineInitializer initializer) {
-            Bootstrap b = new Bootstrap();
+        Future<PCEPSession> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final PCEPDispatcherImpl.ChannelPipelineInitializer initializer) {
+            final Bootstrap b = new Bootstrap();
             final PCEPProtocolSessionPromise p = new PCEPProtocolSessionPromise(this.executor, address, strategy, b);
             (b.option(ChannelOption.SO_KEEPALIVE, Boolean.valueOf(true))).handler(new ChannelInitializer<SocketChannel>() {
                 @Override
-                protected void initChannel(SocketChannel ch) {
+                protected void initChannel(final SocketChannel ch) {
                     initializer.initializeChannel(ch, p);
                 }
             });
@@ -268,15 +270,15 @@ public class PCEPDispatcherImplTest {
             return p;
         }
 
-        private void setChannelFactory(Bootstrap b) {
+        private void setChannelFactory(final Bootstrap b) {
             try {
                 b.channel(NioSocketChannel.class);
-            } catch (IllegalStateException ignored) {
+            } catch (final IllegalStateException ignored) {
             }
 
         }
 
-        private void setWorkerGroup(Bootstrap b) {
+        private void setWorkerGroup(final Bootstrap b) {
             if (b.group() == null) {
                 b.group(this.workerGroup);
             }
index d5d0eb08e550906ffce039d0366ef1d6a14bb137..b24f34a5b1d96e1b33a4cb5f7cf4653a19f85760 100644 (file)
@@ -23,6 +23,7 @@ import io.netty.util.concurrent.GlobalEventExecutor;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
@@ -30,11 +31,14 @@ import org.opendaylight.protocol.framework.NeverReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 import org.opendaylight.protocol.framework.TimedReconnectStrategy;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
+import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator;
 import org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator;
+import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.pcc.mock.api.PccTunnelManager;
 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
@@ -149,7 +153,9 @@ public final class Main {
     }
 
     private static PCEPSessionNegotiatorFactory getSessionNegotiatorFactory(final Open openMessage) {
-        return new DefaultPCEPSessionNegotiatorFactory(openMessage, 0);
+        final List<PCEPCapability> capabilities = new ArrayList<>();
+        final PCEPSessionProposalFactory proposal = new BasePCEPSessionProposalFactory(openMessage.getDeadTimer(), openMessage.getKeepalive(), capabilities);
+        return new DefaultPCEPSessionNegotiatorFactory(proposal, 0);
     }
 
     private static ch.qos.logback.classic.Logger getRootLogger(final LoggerContext lc) {
index a94c2b807432773484130551c2071231e7f8897e..8e48d895cd5f5f4ffef6f818266fc2572372079a 100644 (file)
@@ -21,6 +21,7 @@ import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
+import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPHandlerFactory;
@@ -82,7 +83,7 @@ public final class PCCDispatcher extends AbstractPCCDispatcher implements PCEPDi
             public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise) {
                 ch.pipeline().addLast(PCCDispatcher.this.factory.getDecoders());
                 ch.pipeline().addLast("negotiator",
-                        negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
+                        negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise, null));
                 ch.pipeline().addLast(PCCDispatcher.this.factory.getEncoders());
             }
         });
@@ -91,9 +92,8 @@ public final class PCCDispatcher extends AbstractPCCDispatcher implements PCEPDi
     }
 
     @Override
-    public synchronized ChannelFuture createServer(final InetSocketAddress address,
-                                                   final PCEPSessionListenerFactory listenerFactory) {
-        return createServer(address, null, listenerFactory);
+    public synchronized ChannelFuture createServer(final InetSocketAddress address, final PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal) {
+        return createServer(address, null, listenerFactory, peerProposal);
     }
 
     @Override
@@ -114,13 +114,13 @@ public final class PCCDispatcher extends AbstractPCCDispatcher implements PCEPDi
 
     @Override
     public synchronized ChannelFuture createServer(final InetSocketAddress address, final KeyMapping keys,
-                                                   final PCEPSessionListenerFactory listenerFactory) {
+                                                   final PCEPSessionListenerFactory listenerFactory, final PCEPPeerProposal peerProposal) {
         this.keys = keys;
         final ChannelFuture ret = super.createServer(address, new ChannelPipelineInitializer() {
             @Override
             public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise) {
                 ch.pipeline().addLast(PCCDispatcher.this.hf.getDecoders());
-                ch.pipeline().addLast("negotiator", PCCDispatcher.this.snf.getSessionNegotiator(listenerFactory, ch, promise));
+                ch.pipeline().addLast("negotiator", PCCDispatcher.this.snf.getSessionNegotiator(listenerFactory, ch, promise, peerProposal));
                 ch.pipeline().addLast(PCCDispatcher.this.hf.getEncoders());
             }
         });
@@ -138,7 +138,7 @@ public final class PCCDispatcher extends AbstractPCCDispatcher implements PCEPDi
 
             try {
                 factory = NativeKeyAccessFactory.getInstance();
-            } catch (NativeSupportUnavailableException e) {
+            } catch (final NativeSupportUnavailableException e) {
                 LOG.debug("Native key access not available, using no-op fallback", e);
                 factory = DummyKeyAccessFactory.getInstance();
             }
index 01826b4746d248cc145fe5e5cf3be149bc0823f4..b7db74fa40a389d1e13b11672c3b2e934ce9ce44 100644 (file)
@@ -15,18 +15,20 @@ import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
 import org.opendaylight.protocol.pcep.PCEPSession;
+import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
 import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
 
 public class PCCMockTest {
 
@@ -43,11 +45,12 @@ public class PCCMockTest {
     private static final String LOCAL_ADDRESS2 = "127.0.0.2";
 
     private PCEPDispatcher pceDispatcher;
+    private static final List<PCEPCapability> CAPS = new ArrayList<>();
+    private static final PCEPSessionProposalFactory PROPOSAL = new BasePCEPSessionProposalFactory(DEAD_TIMER, KEEP_ALIVE, CAPS);
 
     @Before
     public void setUp() {
-        final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(
-                new OpenBuilder().setKeepalive(KEEP_ALIVE).setDeadTimer(DEAD_TIMER).setSessionId((short) 0).build(), 0);
+        final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(PROPOSAL, 0);
         this.pceDispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(),
                 nf, new NioEventLoopGroup(), new NioEventLoopGroup());
     }
@@ -55,7 +58,7 @@ public class PCCMockTest {
     @Test
     public void testSessionEstablishment() throws UnknownHostException, InterruptedException, ExecutionException {
         final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
-        final Channel channel = this.pceDispatcher.createServer(new InetSocketAddress(REMOTE_ADDRESS, 4567), factory).channel();
+        final Channel channel = this.pceDispatcher.createServer(new InetSocketAddress(REMOTE_ADDRESS, 4567), factory, null).channel();
         Main.main(new String[] {"--local-address", LOCAL_ADDRESS, "--remote-address", REMOTE_ADDRESS + ":4567", "--pcc", "1", "--lsp", "3",
             "--log-level", "DEBUG", "-ka", "10", "-d", "40"});
         Thread.sleep(1000);
@@ -67,26 +70,24 @@ public class PCCMockTest {
         Assert.assertNotNull(session);
         Assert.assertEquals(40, session.getPeerPref().getDeadtimer().shortValue());
         Assert.assertEquals(10, session.getPeerPref().getKeepalive().shortValue());
-        Assert.assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
+//        Assert.assertTrue(session.getRemoteTlvs().getAugmentation(Tlvs1.class).getStateful().getAugmentation(Stateful1.class).isInitiation());
         channel.close().get();
     }
 
     @Test
     public void testMockPCCToManyPCE() throws InterruptedException, ExecutionException, UnknownHostException {
-        final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(
-                new OpenBuilder().setKeepalive(KEEP_ALIVE).setDeadTimer(DEAD_TIMER).setSessionId((short) 0).build(), 0);
-        PCEPDispatcher dispatcher2 = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(),
+        final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(PROPOSAL, 0);
+        final PCEPDispatcher dispatcher2 = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(),
                 nf, new NioEventLoopGroup(), new NioEventLoopGroup());
-        final DefaultPCEPSessionNegotiatorFactory nf2 = new DefaultPCEPSessionNegotiatorFactory(
-                new OpenBuilder().setKeepalive(KEEP_ALIVE).setDeadTimer(DEAD_TIMER).setSessionId((short) 0).build(), 0);
-        PCEPDispatcher dispatcher3 = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(),
+        final DefaultPCEPSessionNegotiatorFactory nf2 = new DefaultPCEPSessionNegotiatorFactory(PROPOSAL, 0);
+        final PCEPDispatcher dispatcher3 = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(),
                 nf2, new NioEventLoopGroup(), new NioEventLoopGroup());
         final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
         final TestingSessionListenerFactory factory2 = new TestingSessionListenerFactory();
         final TestingSessionListenerFactory factory3 = new TestingSessionListenerFactory();
-        final Channel channel = pceDispatcher.createServer(SERVER_ADDRESS2, factory).channel();
-        final Channel channel2 = dispatcher2.createServer(SERVER_ADDRESS3, factory2).channel();
-        final Channel channel3 = dispatcher3.createServer(SERVER_ADDRESS4, factory3).channel();
+        final Channel channel = this.pceDispatcher.createServer(SERVER_ADDRESS2, factory, null).channel();
+        final Channel channel2 = dispatcher2.createServer(SERVER_ADDRESS3, factory2, null).channel();
+        final Channel channel3 = dispatcher3.createServer(SERVER_ADDRESS4, factory3, null).channel();
 
         Main.main(new String[] {"--local-address", LOCAL_ADDRESS, "--remote-address", REMOTE_ADDRESS2 + "," + REMOTE_ADDRESS3 + "," + REMOTE_ADDRESS4,
             "--pcc", "2"});
@@ -130,7 +131,7 @@ public class PCCMockTest {
         c.setAccessible(true);
         try {
             c.newInstance();
-        } catch (InvocationTargetException e) {
+        } catch (final InvocationTargetException e) {
             throw e.getCause();
         }
     }
diff --git a/pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/PCEPSegmentRoutingCapabilityModule.java b/pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/PCEPSegmentRoutingCapabilityModule.java
new file mode 100644 (file)
index 0000000..91b634e
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 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.controller.config.yang.pcep.sr.cfg;
+
+import com.google.common.base.Preconditions;
+import java.net.InetSocketAddress;
+import org.opendaylight.protocol.pcep.PCEPCapability;
+import org.opendaylight.protocol.pcep.segment.routing.PCEPSegmentRoutingCapability;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+
+public class PCEPSegmentRoutingCapabilityModule extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractPCEPSegmentRoutingCapabilityModule {
+
+    public PCEPSegmentRoutingCapabilityModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public PCEPSegmentRoutingCapabilityModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.pcep.sr.cfg.PCEPSegmentRoutingCapabilityModule oldModule, final java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        final PCEPSegmentRoutingCapability inner = new PCEPSegmentRoutingCapability(getSrCapable());
+        return new PCEPSegmentRoutingCapabilityCloseable(inner);
+    }
+
+    private static final class PCEPSegmentRoutingCapabilityCloseable implements PCEPCapability, AutoCloseable {
+        private final PCEPSegmentRoutingCapability inner;
+
+        public PCEPSegmentRoutingCapabilityCloseable(final PCEPSegmentRoutingCapability inner) {
+            this.inner = Preconditions.checkNotNull(inner);
+        }
+
+        @Override
+        public void close() {
+        }
+
+        @Override
+        public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
+            this.inner.setCapabilityProposal(address, builder);
+        }
+
+    }
+
+}
@@ -8,6 +8,6 @@
  */
 
 package org.opendaylight.controller.config.yang.pcep.sr.cfg;
-public class SrPCEPSessionProposalFactoryModuleFactory extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractSrPCEPSessionProposalFactoryModuleFactory {
+public class PCEPSegmentRoutingCapabilityModuleFactory extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractPCEPSegmentRoutingCapabilityModuleFactory {
 
 }
diff --git a/pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SrPCEPSessionProposalFactoryModule.java b/pcep/segment-routing/src/main/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SrPCEPSessionProposalFactoryModule.java
deleted file mode 100644 (file)
index e713460..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2014 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.controller.config.yang.pcep.sr.cfg;
-
-import com.google.common.base.Preconditions;
-import java.net.InetSocketAddress;
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.segment.routing.SegmentRoutingSessionProposalFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class SrPCEPSessionProposalFactoryModule extends org.opendaylight.controller.config.yang.pcep.sr.cfg.AbstractSrPCEPSessionProposalFactoryModule {
-
-    private static final String VALUE_IS_NOT_SET = "value is not set.";
-
-    private static final int DEADTIMER_KEEPALIVE_RATIO = 4;
-
-    private static final Logger LOG = LoggerFactory.getLogger(SrPCEPSessionProposalFactoryModule.class);
-
-    public SrPCEPSessionProposalFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public SrPCEPSessionProposalFactoryModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.pcep.sr.cfg.SrPCEPSessionProposalFactoryModule oldModule, final java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        JmxAttributeValidationException.checkNotNull(getActive(), VALUE_IS_NOT_SET, activeJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getInitiated(), VALUE_IS_NOT_SET, initiatedJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getDeadTimerValue(), VALUE_IS_NOT_SET, deadTimerValueJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getKeepAliveTimerValue(), VALUE_IS_NOT_SET, keepAliveTimerValueJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getTriggeredInitialSync(), VALUE_IS_NOT_SET, triggeredInitialSyncJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getTriggeredResync(), VALUE_IS_NOT_SET, triggeredResyncJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getDeltaLspSyncCapability(), VALUE_IS_NOT_SET, deltaLspSyncCapabilityJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getIncludeDbVersion(), VALUE_IS_NOT_SET, includeDbVersionJmxAttribute);
-        validateTimers();
-        if ((getActive() || getTriggeredInitialSync() || getTriggeredResync() || getDeltaLspSyncCapability() || getIncludeDbVersion()) && !getStateful()) {
-            setStateful(true);
-        }
-        if ((getTriggeredInitialSync() || getDeltaLspSyncCapability()) && !getIncludeDbVersion()) {
-            setIncludeDbVersion(true);
-        }
-        JmxAttributeValidationException.checkNotNull(getStateful(), VALUE_IS_NOT_SET, statefulJmxAttribute);
-        JmxAttributeValidationException.checkNotNull(getSrCapable(), VALUE_IS_NOT_SET, srCapableJmxAttribute);
-    }
-
-    private void validateTimers() {
-        if (getKeepAliveTimerValue() != 0) {
-            JmxAttributeValidationException.checkCondition(getKeepAliveTimerValue() >= 1, "minimum value is 1.", keepAliveTimerValueJmxAttribute);
-            if (getDeadTimerValue() != 0 && (getDeadTimerValue() / getKeepAliveTimerValue() != DEADTIMER_KEEPALIVE_RATIO)) {
-                LOG.warn("DeadTimerValue should be 4 times greater than KeepAliveTimerValue");
-            }
-        }
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        final SegmentRoutingSessionProposalFactory inner = new SegmentRoutingSessionProposalFactory(getDeadTimerValue(), getKeepAliveTimerValue(), getStateful(), getActive(), getInitiated(), getSrCapable(),
-            getTriggeredInitialSync(), getTriggeredResync(), getDeltaLspSyncCapability(), getIncludeDbVersion());
-        return new PCEPSessionProposalFactoryCloseable(inner);
-    }
-
-    private static final class PCEPSessionProposalFactoryCloseable implements PCEPSessionProposalFactory, AutoCloseable {
-        private final SegmentRoutingSessionProposalFactory inner;
-
-        public PCEPSessionProposalFactoryCloseable(final SegmentRoutingSessionProposalFactory inner) {
-            this.inner = Preconditions.checkNotNull(inner);
-        }
-
-        @Override
-        public void close() {
-        }
-
-        @Override
-        public Open getSessionProposal(final InetSocketAddress inetSocketAddress, final int sessionId) {
-            return this.inner.getSessionProposal(inetSocketAddress, sessionId);
-        }
-    }
-
-}
@@ -9,25 +9,22 @@
 package org.opendaylight.protocol.pcep.segment.routing;
 
 import java.net.InetSocketAddress;
-import org.opendaylight.protocol.pcep.ietf.initiated00.Stateful07SessionProposalFactory;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
 
-public class SegmentRoutingSessionProposalFactory extends Stateful07SessionProposalFactory {
+public class PCEPSegmentRoutingCapability implements PCEPCapability {
 
     private final boolean isSegmentRoutingCapable;
 
-    public SegmentRoutingSessionProposalFactory(final int deadTimer, final int keepAlive, final boolean stateful, final boolean active,
-            final boolean instant, final boolean isSegmentRoutingCapable, final boolean triggeredSync, final boolean triggeredResync, final boolean deltaLspSync, final boolean includeDbVersion) {
-        super(deadTimer, keepAlive, stateful, active, instant, triggeredSync, triggeredResync, deltaLspSync, includeDbVersion);
+    public PCEPSegmentRoutingCapability(final boolean isSegmentRoutingCapable) {
         this.isSegmentRoutingCapable = isSegmentRoutingCapable;
     }
 
     @Override
-    protected void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
-        super.addTlvs(address, builder);
+    public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
         if (this.isSegmentRoutingCapable) {
             builder.addAugmentation(Tlvs1.class,
                     new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 0).build())
@@ -38,5 +35,4 @@ public class SegmentRoutingSessionProposalFactory extends Stateful07SessionPropo
     public boolean isSegmentRoutingCapable() {
         return this.isSegmentRoutingCapable;
     }
-
 }
index 314ffbc003a3ea02a1f4703d687d10c6c4666c57..04203a1b3e37febae3c331dff3d7264e63ec9a40 100644 (file)
@@ -41,15 +41,15 @@ module odl-pcep-segment-routing-cfg {
         }
     }
 
-    identity pcep-session-proposal-factory-sr {
+    identity pcep-segment-routing-capability {
         base config:module-type;
-        config:java-name-prefix "SrPCEPSessionProposalFactory";
-        config:provided-service pcep:pcep-session-proposal-factory;
+        config:java-name-prefix "PCEPSegmentRoutingCapability";
+        config:provided-service pcep:pcep-capability;
     }
 
     augment "/config:modules/config:module/config:configuration" {
-        case pcep-session-proposal-factory-sr {
-            when "/config:modules/config:module/config:type = 'pcep-session-proposal-factory-sr'";
+        case pcep-segment-routing-capability {
+            when "/config:modules/config:module/config:type = 'pcep-segment-routing-capability'";
             uses pcep-stateful07:stateful-capabilities;
             leaf sr-capable {
                 type boolean;
diff --git a/pcep/segment-routing/src/test/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/PCEPSegmentRoutingCapabilityModuleTest.java b/pcep/segment-routing/src/test/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/PCEPSegmentRoutingCapabilityModuleTest.java
new file mode 100644 (file)
index 0000000..6e80842
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2014 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.controller.config.yang.pcep.sr.cfg;
+
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.ObjectName;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
+import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
+import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
+
+public class PCEPSegmentRoutingCapabilityModuleTest extends AbstractConfigTest {
+
+    private static final String INSTANCE_NAME = "sr02-session-proposal";
+    private static final String FACTORY_NAME = PCEPSegmentRoutingCapabilityModuleFactory.NAME;
+
+    @Before
+    public void setUp() throws Exception {
+        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new PCEPSegmentRoutingCapabilityModuleFactory()));
+    }
+
+    @Test
+    public void testCreateBean() throws Exception {
+        final CommitStatus status = createInstance();
+        assertBeanCount(1, FACTORY_NAME);
+        assertStatus(status, 1, 0, 0);
+    }
+
+    @Test
+    public void testReusingOldInstance() throws Exception {
+        createInstance();
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        assertBeanCount(1, FACTORY_NAME);
+        final CommitStatus status = transaction.commit();
+        assertBeanCount(1, FACTORY_NAME);
+        assertStatus(status, 0, 0, 1);
+    }
+
+    @Test
+    public void testReconfigure() throws Exception {
+        createInstance();
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        assertBeanCount(1, FACTORY_NAME);
+        transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME), PCEPSegmentRoutingCapabilityModuleMXBean.class);
+        final CommitStatus status = transaction.commit();
+        assertBeanCount(1, FACTORY_NAME);
+        assertStatus(status, 0, 0, 1);
+    }
+
+    private CommitStatus createInstance() throws Exception {
+        return createInstance(true);
+    }
+
+    private CommitStatus createInstance(final Boolean srCapable) throws Exception {
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
+        createInstance(transaction, srCapable);
+        return transaction.commit();
+    }
+
+    private ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Boolean srCapable) throws InstanceAlreadyExistsException {
+        final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
+        final PCEPSegmentRoutingCapabilityModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated, PCEPSegmentRoutingCapabilityModuleMXBean.class);
+        mxBean.setSrCapable(srCapable);
+        return nameCreated;
+    }
+}
diff --git a/pcep/segment-routing/src/test/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SrPCEPSessionProposalFactoryModuleTest.java b/pcep/segment-routing/src/test/java/org/opendaylight/controller/config/yang/pcep/sr/cfg/SrPCEPSessionProposalFactoryModuleTest.java
deleted file mode 100644 (file)
index f5fae1f..0000000
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (c) 2014 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.controller.config.yang.pcep.sr.cfg;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.ObjectName;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
-import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
-import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
-import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.Stateful07PCEPSessionProposalFactoryModuleMXBean;
-
-public class SrPCEPSessionProposalFactoryModuleTest extends AbstractConfigTest {
-
-    private static final String INSTANCE_NAME = "sr02-session-proposal";
-    private static final String FACTORY_NAME = SrPCEPSessionProposalFactoryModuleFactory.NAME;
-
-    @Before
-    public void setUp() throws Exception {
-        super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(this.mockedContext, new SrPCEPSessionProposalFactoryModuleFactory()));
-    }
-
-    @Test
-    public void testValidationExceptionDeadTimerValueNotSet() throws Exception {
-        try {
-            createInstance(null, (short) 100, true, true, true, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("DeadTimerValue value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionKeepAliveTimerNotSet() throws Exception {
-        try {
-            createInstance((short) 200, null, true, true, true, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("KeepAliveTimerValue value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionStatefulNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, null, false, false, false, false, false, false, false);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("Stateful value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionActiveNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, null, true, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("Active value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionInstantiatedNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, null, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("Initiated value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionKeepAliveTimerMinValue() throws Exception {
-        try {
-            createInstance((short) 200, (short) -10, true, true, true, true, true, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("minimum value is 1."));
-        }
-    }
-
-    @Test
-    public void testStatefulAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, true, true, true, true, true, true, true);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertTrue(mxBean.getStateful());
-    }
-
-    @Test
-    public void testNotStatefulAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, false, false, false, false, false, false, false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertFalse(mxBean.getStateful());
-    }
-
-    @Test
-    public void testIncludeDbVersionAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, false, false, false, false, false, true, false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertTrue(mxBean.getIncludeDbVersion());
-    }
-
-    @Test
-    public void testNotIncludeDbVersionAfterCommitted() throws Exception {
-        createInstance((short) 200, (short) 100, false, false, false, false, false, false, false, false);
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        final Stateful07PCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(transaction.lookupConfigBean(
-                FACTORY_NAME, INSTANCE_NAME), Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        assertFalse(mxBean.getIncludeDbVersion());
-    }
-
-    @Test
-    public void testValidationExceptionSrCapableValueNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, null, false, false, false, false);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("SrCapable value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionTriggeredSyncNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, true, null, true, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("TriggeredInitialSync value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionTriggeredResyncNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, true, true, null, true, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("TriggeredResync value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionDeltaLspSyncNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, true, true, true, null, true);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("DeltaLspSyncCapability value is not set"));
-        }
-    }
-
-    @Test
-    public void testValidationExceptionIncludeDBVersionNotSet() throws Exception {
-        try {
-            createInstance((short) 200, (short) 100, true, true, true, true, true, true, true, null);
-            fail();
-        } catch (final ValidationException e) {
-            assertTrue(e.getMessage().contains("IncludeDbVersion value is not set"));
-        }
-    }
-
-    @Test
-    public void testCreateBean() throws Exception {
-        final CommitStatus status = createInstance();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 1, 0, 0);
-    }
-
-    @Test
-    public void testReusingOldInstance() throws Exception {
-        createInstance();
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 1);
-    }
-
-    @Test
-    public void testReconfigure() throws Exception {
-        createInstance();
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        assertBeanCount(1, FACTORY_NAME);
-        transaction.newMXBeanProxy(transaction.lookupConfigBean(FACTORY_NAME, INSTANCE_NAME),
-                Stateful07PCEPSessionProposalFactoryModuleMXBean.class);
-        final CommitStatus status = transaction.commit();
-        assertBeanCount(1, FACTORY_NAME);
-        assertStatus(status, 0, 0, 1);
-    }
-
-    private CommitStatus createInstance() throws Exception {
-        return createInstance((short) 200, (short) 100, true, true, true, true, true, true, true, true);
-    }
-
-    private CommitStatus createInstance(final Short deadTimer, final Short keepAlive,
-            final Boolean stateful, final Boolean active, final Boolean instant, final Boolean srCapable,
-            final Boolean triggeredInitialSync, final Boolean triggeredResync, final Boolean deltaLspSyncCapability, final Boolean includeDbVersion) throws Exception {
-        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
-        createInstance(transaction, deadTimer, keepAlive, stateful, active, instant, srCapable, triggeredInitialSync, triggeredResync, deltaLspSyncCapability, includeDbVersion);
-        return transaction.commit();
-    }
-
-    private ObjectName createInstance(final ConfigTransactionJMXClient transaction, final Short deadTimer, final Short keepAlive,
-            final Boolean stateful, final Boolean active, final Boolean instant, final Boolean srCapable,
-            final Boolean triggeredInitialSync, final Boolean triggeredResync, final Boolean deltaLspSyncCapability, final Boolean includeDbVersion) throws InstanceAlreadyExistsException {
-        final ObjectName nameCreated = transaction.createModule(FACTORY_NAME, INSTANCE_NAME);
-        final SrPCEPSessionProposalFactoryModuleMXBean mxBean = transaction.newMXBeanProxy(nameCreated,
-                SrPCEPSessionProposalFactoryModuleMXBean.class);
-        mxBean.setActive(active);
-        mxBean.setDeadTimerValue(deadTimer);
-        mxBean.setInitiated(instant);
-        mxBean.setKeepAliveTimerValue(keepAlive);
-        mxBean.setStateful(stateful);
-        mxBean.setSrCapable(srCapable);
-        mxBean.setTriggeredInitialSync(triggeredInitialSync);
-        mxBean.setTriggeredResync(triggeredResync);
-        mxBean.setDeltaLspSyncCapability(deltaLspSyncCapability);
-        mxBean.setIncludeDbVersion(includeDbVersion);
-        return nameCreated;
-    }
-}
diff --git a/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapabilityTest.java b/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapabilityTest.java
new file mode 100644 (file)
index 0000000..dcae1b8
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.protocol.pcep.segment.routing;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
+
+public class PCEPSegmentRoutingCapabilityTest {
+
+    private static final Tlvs EXPECTED_TLVS =
+        new TlvsBuilder()
+            .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1.class,
+                    new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder()
+                    .setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 0).build()).build())
+            .build();
+
+    @Test
+    public void testSegmentRoutingCapability() {
+        final PCEPSegmentRoutingCapability sspf = new PCEPSegmentRoutingCapability(true);
+        Assert.assertTrue(sspf.isSegmentRoutingCapable());
+        final TlvsBuilder builder = new TlvsBuilder();
+        sspf.setCapabilityProposal(null, builder);
+        Assert.assertEquals(EXPECTED_TLVS, builder.build());
+    }
+}
diff --git a/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/SegmentRouting02SessionProposalTest.java b/pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/SegmentRouting02SessionProposalTest.java
deleted file mode 100644 (file)
index b4d2998..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.protocol.pcep.segment.routing;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
-
-public class SegmentRouting02SessionProposalTest {
-
-    private static final int DEAD_TIMER = 4;
-    private static final int KEEP_ALIVE = 1;
-    private static final int SESSION_ID = 1;
-    private static final Open OPEN_MSG = new OpenBuilder()
-            .setDeadTimer((short) DEAD_TIMER)
-            .setKeepalive((short) KEEP_ALIVE)
-            .setSessionId((short) SESSION_ID)
-            .setTlvs(new TlvsBuilder()
-                .addAugmentation(Tlvs1.class, new Tlvs1Builder().setStateful(new StatefulBuilder()
-                    .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(true).build())
-                    .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1Builder()
-                        .setTriggeredInitialSync(true)
-                        .setTriggeredResync(false)
-                        .setDeltaLspSyncCapability(true)
-                        .setIncludeDbVersion(false)
-                        .build())
-                    .setLspUpdateCapability(true).build()).build())
-                .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1.class,
-                        new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder()
-                        .setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 0).build()).build())
-                .build())
-            .build();
-
-    @Test
-    public void testSegmentRouting02SessionProposalFactory() {
-        final SegmentRoutingSessionProposalFactory sspf = new SegmentRoutingSessionProposalFactory(DEAD_TIMER, KEEP_ALIVE, true, true, true, true, true, false, true, false);
-        Assert.assertEquals(DEAD_TIMER, sspf.getDeadTimer());
-        Assert.assertEquals(KEEP_ALIVE, sspf.getKeepAlive());
-        Assert.assertTrue(sspf.isActive());
-        Assert.assertTrue(sspf.isInstant());
-        Assert.assertTrue(sspf.isStateful());
-        Assert.assertTrue(sspf.isSegmentRoutingCapable());
-        Assert.assertFalse(sspf.isTriggeredResync());
-        Assert.assertTrue(sspf.isTriggeredSync());
-        Assert.assertTrue(sspf.isDeltaLspSync());
-        Assert.assertFalse(sspf.isIncludeDbVersion());
-        Assert.assertEquals(OPEN_MSG, sspf.getSessionProposal(null, SESSION_ID));
-    }
-}
index 8d7168c873a34674029a7e39390f31a168659f26..8e3d0c30e86a87724d746d23c0ad37bf7ec5bb33 100644 (file)
@@ -11,14 +11,17 @@ import io.netty.channel.nio.NioEventLoopGroup;
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
-import org.opendaylight.protocol.pcep.ietf.initiated00.Stateful07SessionProposalFactory;
+import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
 import org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator;
+import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
 import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -117,15 +120,15 @@ public final class Main {
             deadTimerValue = keepAliveValue * KA_TO_DEADTIMER_RATIO;
         }
 
-        final PCEPSessionProposalFactory spf = new Stateful07SessionProposalFactory(deadTimerValue, keepAliveValue, stateful, active, instant, false, false, false, false);
-
-        final Open prefs = spf.getSessionProposal(address, 0);
+        final List<PCEPCapability> caps = new ArrayList<>();
+        caps.add(new PCEPStatefulCapability(stateful, active, instant, false, false, false, false));
+        final PCEPSessionProposalFactory spf = new BasePCEPSessionProposalFactory(deadTimerValue, keepAliveValue, caps);
 
         try (final StatefulActivator activator07 = new StatefulActivator()) {
             activator07.start(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance());
 
-            try (final PCEPDispatcherImpl dispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(), new DefaultPCEPSessionNegotiatorFactory(prefs, MAX_UNKNOWN_MESSAGES), new NioEventLoopGroup(), new NioEventLoopGroup())) {
-                dispatcher.createServer(address, new TestingSessionListenerFactory()).get();
+            try (final PCEPDispatcherImpl dispatcher = new PCEPDispatcherImpl(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry(), new DefaultPCEPSessionNegotiatorFactory(spf, MAX_UNKNOWN_MESSAGES), new NioEventLoopGroup(), new NioEventLoopGroup())) {
+                dispatcher.createServer(address, new TestingSessionListenerFactory(), null).get();
             }
         }
     }
index 36d838df7921c5e8de9192dd042c8539a8020092..2b8ef0ccdc8255e652ae2d0eeec37c0865553e7e 100644 (file)
@@ -15,17 +15,21 @@ import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.GlobalEventExecutor;
 import io.netty.util.concurrent.Promise;
 import java.net.InetSocketAddress;
+import java.util.ArrayList;
+import java.util.List;
 import org.opendaylight.protocol.framework.NeverReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
+import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPHandlerFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPSessionImpl;
 import org.opendaylight.protocol.pcep.pcc.mock.AbstractPCCDispatcher;
 import org.opendaylight.protocol.pcep.spi.pojo.ServiceLoaderPCEPExtensionProviderContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
 
 public class PCCMock extends AbstractPCCDispatcher {
 
@@ -45,15 +49,16 @@ public class PCCMock extends AbstractPCCDispatcher {
             @Override
             public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise) {
                 ch.pipeline().addLast(PCCMock.this.factory.getDecoders());
-                ch.pipeline().addLast("negotiator", PCCMock.this.negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
+                ch.pipeline().addLast("negotiator", PCCMock.this.negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise, null));
                 ch.pipeline().addLast(PCCMock.this.factory.getEncoders());
             }
         });
     }
 
     public static void main(final String[] args) throws Exception {
-        final PCEPSessionNegotiatorFactory snf = new DefaultPCEPSessionNegotiatorFactory(new OpenBuilder().setKeepalive(
-                (short) 30).setDeadTimer((short) 120).setSessionId((short) 0).build(), 0);
+        final List<PCEPCapability> caps = new ArrayList<>();
+        final PCEPSessionProposalFactory proposal = new BasePCEPSessionProposalFactory((short) 120, (short) 30, caps);
+        final PCEPSessionNegotiatorFactory snf = new DefaultPCEPSessionNegotiatorFactory(proposal, 0);
 
         final PCCMock pcc = new PCCMock(snf, new PCEPHandlerFactory(ServiceLoaderPCEPExtensionProviderContext.getSingletonInstance().getMessageHandlerRegistry()), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
 
index 4efccc8aac0a88e62cdf1e2bbf63a0600b1d1b5c..ef7e34da54b4d77c5a48364afeb323a86a4b4ff4 100644 (file)
@@ -60,7 +60,7 @@ public final class PCEPTopologyProvider extends DefaultTopologyReference impleme
         if (runtimeRootRegistrator.isPresent()) {
             manager.registerRuntimeRootRegistartion(runtimeRootRegistrator.get());
         }
-        final ChannelFuture f = dispatcher.createServer(address, keys, manager);
+        final ChannelFuture f = dispatcher.createServer(address, keys, manager, null);
         f.get();
 
         final BindingAwareBroker.RoutedRpcRegistration<NetworkTopologyPcepService> element = rpcRegistry.addRoutedRpcImplementation(
index 5ebee6f2b476f1d759e6f335a04e0d9f8dc91d6e..0ca09b10baa243a816bb2dc2fe8579967495281e 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.controller.config.yang.pcep.topology.provider;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import static org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleTest.createDispatcherInstance;
-
 import java.util.Arrays;
 import java.util.List;
 import java.util.Random;
@@ -26,7 +25,7 @@ import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModul
 import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleMXBean;
 import org.opendaylight.controller.config.yang.pcep.impl.PCEPSessionProposalFactoryImplModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.Stateful07PCEPSessionProposalFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.PCEPStatefulCapabilityModuleFactory;
 import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
 import org.opendaylight.controller.config.yang.tcpmd5.jni.cfg.NativeKeyAccessFactoryModuleFactory;
 import org.opendaylight.controller.config.yang.tcpmd5.netty.cfg.MD5ServerChannelFactoryModuleFactory;
@@ -136,9 +135,9 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
     }
 
     private CommitStatus createInstance(final String listenAddress, final PortNumber listenPort,
-                                        final TopologyId topologyId, boolean addMD5)
+                                        final TopologyId topologyId, final boolean addMD5)
             throws Exception {
-        ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
+        final ConfigTransactionJMXClient transaction = this.configRegistryClient.createTransaction();
         createPCEPTopologyProviderModuleInstance(transaction, listenAddress, listenPort, topologyId, addMD5);
         return transaction.commit();
     }
@@ -216,7 +215,7 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
         moduleFactories.add(new NettyThreadgroupModuleFactory());
         moduleFactories.add(new SimplePCEPExtensionProviderContextModuleFactory());
         moduleFactories.add(new Stateful07TopologySessionListenerModuleFactory());
-        moduleFactories.add(new Stateful07PCEPSessionProposalFactoryModuleFactory());
+        moduleFactories.add(new PCEPStatefulCapabilityModuleFactory());
         moduleFactories.add(new NativeKeyAccessFactoryModuleFactory());
         moduleFactories.add(new MD5ServerChannelFactoryModuleFactory());
         return moduleFactories;
index 236ac0128047df1dcc2c21d97550a24b1359564b..5fa6903dc98cb5388665b0a62292539b385c79e2 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.controller.config.yang.pcep.tunnel.provider;
 
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-
 import java.util.List;
 import javax.management.ObjectName;
 import org.junit.Test;
@@ -21,7 +20,7 @@ import org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgrou
 import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.impl.PCEPSessionProposalFactoryImplModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.spi.SimplePCEPExtensionProviderContextModuleFactory;
-import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.Stateful07PCEPSessionProposalFactoryModuleFactory;
+import org.opendaylight.controller.config.yang.pcep.stateful07.cfg.PCEPStatefulCapabilityModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleFactory;
 import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleMXBean;
 import org.opendaylight.controller.config.yang.pcep.topology.provider.PCEPTopologyProviderModuleTest;
@@ -118,7 +117,7 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
         moduleFactories.add(new NettyThreadgroupModuleFactory());
         moduleFactories.add(new SimplePCEPExtensionProviderContextModuleFactory());
         moduleFactories.add(new Stateful07TopologySessionListenerModuleFactory());
-        moduleFactories.add(new Stateful07PCEPSessionProposalFactoryModuleFactory());
+        moduleFactories.add(new PCEPStatefulCapabilityModuleFactory());
         return moduleFactories;
     }