PCEP Entity Identifier configurable 45/66345/11
authorClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Fri, 8 Dec 2017 19:23:11 +0000 (20:23 +0100)
committerClaudio D. Gasparini <claudio.gasparini@pantheon.tech>
Mon, 18 Dec 2017 13:05:39 +0000 (14:05 +0100)
- Reduce number of parameters for PCEP

Change-Id: I91190152b9307a9492091a0243492cc539e8862d
Signed-off-by: Claudio D. Gasparini <claudio.gasparini@pantheon.tech>
21 files changed:
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPDispatcherDependencies.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionState.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/SpeakerIdMapping.java [new file with mode: 0644]
pcep/config-example/src/main/resources/initial/network-topology-pcep-config.xml
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiatorFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionState.java
pcep/pcc-mock/src/test/java/org/opendaylight/protocol/pcep/pcc/mock/PCCMockCommon.java
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestToolPCEPDispatcherDependencies.java
pcep/topology/cli/src/main/java/org/opendaylight/protocol/pcep/cli/utils/PcepStateUtils.java
pcep/topology/cli/src/test/java/org/opendaylight/protocol/pcep/cli/utils/PcepStateUtilsTest.java
pcep/topology/cli/src/test/resources/node.txt
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPDispatcherDependenciesImpl.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPStatefulPeerProposal.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/ServerSessionManager.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/config/PCEPTopologyConfiguration.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/config/PCEPTopologyDeployerImpl.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/config/PCEPTopologyProviderUtil.java
pcep/topology/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/session/stats/SessionStateImpl.java
pcep/topology/topology-provider/src/test/java/org/opendaylight/bgpcep/pcep/topology/provider/AbstractPCEPSessionTest.java
pcep/topology/topology-provider/src/test/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPStatefulPeerProposalTest.java

index b4de6fd46bdc37fc7cb9d4af8fac463c39bc36c5..73bf8e6a0829ac67d5b883d6b915d09e5ed9b28f 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.protocol.pcep;
 
 import java.net.InetSocketAddress;
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import org.opendaylight.protocol.concepts.KeyMapping;
 
 /**
@@ -32,4 +31,12 @@ public interface PCEPDispatcherDependencies extends PCEPSessionNegotiatorFactory
      */
     @Nonnull
     KeyMapping getKeys();
+
+    /**
+     * PCEP Speaker Id mapping.
+     *
+     * @return map containing Keys
+     */
+    @Nonnull
+    SpeakerIdMapping getSpeakerIdMapping();
 }
index 449b6dfc2890f3d049e05d028e2b8a45b74077ae..f8d593baa6eed1fe61204f7668e94bfc16042cf1 100644 (file)
@@ -11,6 +11,7 @@ import javax.annotation.Nonnull;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerPref;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 
 /**
  * Exposes Session state.
@@ -36,4 +37,11 @@ public interface PCEPSessionState {
      * @return peer preferences
      */
     @Nonnull PeerPref getPeerPref();
+
+    /**
+     * The local (PCE) Open Message.
+     *
+     * @return Open
+     */
+    @Nonnull Open getLocalOpen();
 }
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/SpeakerIdMapping.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/SpeakerIdMapping.java
new file mode 100644 (file)
index 0000000..f317362
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2017 AT&T Intellectual Property. 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.InetAddress;
+import java.util.HashMap;
+
+public final class SpeakerIdMapping extends HashMap<InetAddress, byte[]> {
+    private static final long serialVersionUID = 1L;
+
+    private SpeakerIdMapping() {
+        super();
+    }
+
+    public static SpeakerIdMapping getSpeakerIdMap() {
+        return new SpeakerIdMapping();
+    }
+}
\ No newline at end of file
index 9b7cdcaa4417031fda831b18385d2efe6f8e8366..bb9d02350202fe12835d9650506f2809c89adfcd 100644 (file)
@@ -23,6 +23,7 @@
             <node-id>43.43.43.43</node-id>
             <session-config xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep:config">
                 <password>topsecret</password>
+                <speaker-entity-id-value xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep:sync:optimizations:config">AQIDBA==</speaker-entity-id-value>
             </session-config>
         </node>
     </topology>
index 7fbf5fab865ae46b624149a554815d533c58ea8e..8f1e3a3d79d6dfc559f993ee491014931abb4b0c 100644 (file)
@@ -9,9 +9,6 @@ package org.opendaylight.protocol.pcep.impl;
 
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
-import javax.annotation.Nonnull;
-import org.opendaylight.protocol.pcep.PCEPPeerProposal;
-import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
 import org.opendaylight.protocol.pcep.SessionNegotiator;
@@ -31,13 +28,14 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessio
     /**
      * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
      *
+     * @param snd       PCEP Session Negotiator dependencies
      * @param promise   Session promise to be completed by the negotiator
      * @param channel   Associated channel
      * @param sessionId Session ID assigned to the resulting session
      * @return a PCEP session negotiator
      */
     protected abstract AbstractPCEPSessionNegotiator createNegotiator(
-            @Nonnull PCEPSessionNegotiatorFactoryDependencies sessionNegotiatorDependencies,
+            PCEPSessionNegotiatorFactoryDependencies snd,
             Promise<PCEPSessionImpl> promise,
             Channel channel, short sessionId);
 
index dc565823722da1e99dda4d6f54fc4650d1c77fcf..1a415e0f2e96d686d44f9ff183c55e28b286f741 100644 (file)
@@ -63,8 +63,7 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler<Message> implem
     /**
      * System.nanoTime value about when was sent the last message Protected to be updated also in tests.
      */
-    @VisibleForTesting
-    protected volatile long lastMessageSentAt;
+    private volatile long lastMessageSentAt;
 
     /**
      * System.nanoTime value about when was received the last message
@@ -345,7 +344,8 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler<Message> implem
              * session DOWN event.
              */
             close();
-            this.listener.onSessionTerminated(this, new PCEPCloseTermination(TerminationReason.forValue(((CloseMessage) msg).getCCloseMessage().getCClose().getReason())));
+            this.listener.onSessionTerminated(this, new PCEPCloseTermination(TerminationReason
+                    .forValue(((CloseMessage) msg).getCCloseMessage().getCClose().getReason())));
         } else {
             // This message needs to be handled by the user
             if (msg instanceof PcerrMessage) {
@@ -397,6 +397,11 @@ public class PCEPSessionImpl extends SimpleChannelInboundHandler<Message> implem
         return this.sessionState.getPeerPref();
     }
 
+    @Override
+    public Open getLocalOpen() {
+        return this.sessionState.getLocalOpen();
+    }
+
     @Override
     public final void channelInactive(final ChannelHandlerContext ctx) {
         LOG.debug("Channel {} inactive.", ctx.channel());
index debe87db6421406ec77f27419c6f9d8dcada0567..cf0d95418922cce736cc6bc6093813e5f5116517 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObject;
 
 final class PCEPSessionState {
+    private final Open localOpen;
     private long sentMsgCount = 0;
     private long receivedMsgCount = 0;
     private long sentErrMsgCount = 0;
@@ -44,6 +45,7 @@ final class PCEPSessionState {
         requireNonNull(remoteOpen);
         requireNonNull(localOpen);
         requireNonNull(channel);
+        this.localOpen = localOpen;
         this.peerPref = getRemotePref(remoteOpen, channel);
         this.localPref = getLocalPref(localOpen, channel);
         this.lastReceivedErrorBuilder = new LastReceivedErrorBuilder();
@@ -120,4 +122,8 @@ final class PCEPSessionState {
         peerBuilder.setSessionId(open.getSessionId().intValue());
         return peerBuilder.build();
     }
+
+    public Open getLocalOpen() {
+        return localOpen;
+    }
 }
index f589e4f8f1927239dc4b9434836b715d89ae44d6..f6b42e46719ca3a526bab720d3242d6934b52a4f 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
+import org.opendaylight.protocol.pcep.SpeakerIdMapping;
 import org.opendaylight.protocol.pcep.ietf.stateful07.StatefulActivator;
 import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
@@ -231,6 +232,7 @@ public abstract class PCCMockCommon {
 
     private class DispatcherDependencies implements PCEPDispatcherDependencies {
         final KeyMapping keys = KeyMapping.getKeyMapping();
+        final SpeakerIdMapping ids = SpeakerIdMapping.getSpeakerIdMap();
         private final InetSocketAddress address;
         private final TestingSessionListenerFactory listenerFactory;
         private final PCEPPeerProposal peerProposal;
@@ -254,6 +256,11 @@ public abstract class PCCMockCommon {
             return keys;
         }
 
+        @Override
+        public SpeakerIdMapping getSpeakerIdMapping() {
+            return ids;
+        }
+
         @Override
         public PCEPSessionListenerFactory getListenerFactory() {
             return this.listenerFactory;
index 785e5517ca251ca2e87042a41ae64dabfd215652..af46e415d9f140aed1b96adc1483558756dacf25 100644 (file)
@@ -13,11 +13,13 @@ import javax.annotation.Nonnull;
 import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.protocol.pcep.PCEPDispatcherDependencies;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
+import org.opendaylight.protocol.pcep.SpeakerIdMapping;
 
 public final class TestToolPCEPDispatcherDependencies implements PCEPDispatcherDependencies {
     private final PCEPSessionListenerFactory listenerFactory = new TestingSessionListenerFactory();
     private final InetSocketAddress address;
     private final KeyMapping keys = KeyMapping.getKeyMapping();
+    private final SpeakerIdMapping speakerIds = SpeakerIdMapping.getSpeakerIdMap();
 
     TestToolPCEPDispatcherDependencies(@Nonnull final InetSocketAddress address) {
         this.address = address;
@@ -33,6 +35,11 @@ public final class TestToolPCEPDispatcherDependencies implements PCEPDispatcherD
         return this.keys;
     }
 
+    @Override
+    public SpeakerIdMapping getSpeakerIdMapping() {
+        return this.speakerIds;
+    }
+
     @Override
     public PCEPSessionListenerFactory getListenerFactory() {
         return this.listenerFactory;
index 446f319da3be2c311563a36a11936fae002e8517..ebb590cac0e977a3ac020a27269150d694aed95b 100644 (file)
@@ -8,12 +8,14 @@
 package org.opendaylight.protocol.pcep.cli.utils;
 
 import java.io.PrintStream;
+import java.util.Arrays;
 import java.util.concurrent.ExecutionException;
 import org.apache.karaf.shell.table.ShellTable;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.PcepEntityIdStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulCapabilitiesStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.Error;
@@ -88,6 +90,11 @@ public final class PcepStateUtils {
         addHeader(table, "Local preferences");
         final LocalPref localPref = pcepSessionState.getLocalPref();
         showPreferences(table, localPref);
+        final PcepEntityIdStatsAug entAug = localPref.getAugmentation(PcepEntityIdStatsAug.class);
+        if (entAug != null) {
+            table.addRow().addContent("Speaker Entity Identifier",
+                    Arrays.toString(entAug.getSpeakerEntityIdValue()));
+        }
 
         addHeader(table, "Peer preferences");
         final PeerPref peerPref = pcepSessionState.getPeerPref();
index 98a7fba5facf022684d0988d6826f41286ee89df..20a56060b12aa1fe06a7b0b610b4967d636283ec 100644 (file)
@@ -18,6 +18,8 @@ import org.junit.Test;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.PcepEntityIdStatsAug;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.PcepEntityIdStatsAugBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulCapabilitiesStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulCapabilitiesStatsAugBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAug;
@@ -53,6 +55,7 @@ public class PcepStateUtilsTest extends AbstractConcurrentDataBrokerTest {
     private static final String RIB_NOT_FOUND = "Node [pcc://" + IP_ADDRESS + "] not found\n";
     private static final String NODE_ID = "pcc://127.0.0.1";
     private static final String UTF8 = "UTF-8";
+    private static final byte[] SPEAKER_ID = {0x01, 0x02, 0x03, 0x04};
     private final ByteArrayOutputStream output = new ByteArrayOutputStream();
     private final PrintStream stream = new PrintStream(this.output);
 
@@ -93,6 +96,8 @@ public class PcepStateUtilsTest extends AbstractConcurrentDataBrokerTest {
                 .setDeadtimer((short) 120)
                 .setIpAddress(IP_ADDRESS)
                 .setSessionId(0)
+                .addAugmentation(PcepEntityIdStatsAug.class, new PcepEntityIdStatsAugBuilder()
+                        .setSpeakerEntityIdValue(SPEAKER_ID).build())
                 .build();
 
         final PeerCapabilities capa = new PeerCapabilitiesBuilder()
index 68dd6ec520b1612c1cf3b2cc2a0827a69bfcaf95..d11185c10e2ae94dd81ec3250f591f90ff2a9bb8 100644 (file)
@@ -15,6 +15,7 @@ Session id                     | 0
 Ip Address                     | 127.0.0.1      
 Dead Timer                     | 120            
 Keep Alive                     | 30             
+Speaker Entity Identifier      | [1, 2, 3, 4]   
                                |                
 Peer preferences               |                
 ======================         |                
index 53408124cb8d6242f471fdd02c0be1bf4ec0c594..cfb7c0a64a2699c3c82c1cf21b6b738c5172f657 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.protocol.pcep.PCEPDispatcherDependencies;
 import org.opendaylight.protocol.pcep.PCEPPeerProposal;
 import org.opendaylight.protocol.pcep.PCEPSessionListenerFactory;
+import org.opendaylight.protocol.pcep.SpeakerIdMapping;
 
 public final class PCEPDispatcherDependenciesImpl implements PCEPDispatcherDependencies {
     private final ServerSessionManager manager;
@@ -40,6 +41,11 @@ public final class PCEPDispatcherDependenciesImpl implements PCEPDispatcherDepen
         return this.topologyConfigDependencies.getKeys();
     }
 
+    @Override
+    public SpeakerIdMapping getSpeakerIdMapping() {
+        return this.topologyConfigDependencies.getSpeakerIds();
+    }
+
     @Override
     public PCEPSessionListenerFactory getListenerFactory() {
         return this.manager;
index 9594186b16f51f971c80ffd644bde86585ad9104..77593ce51390fdd3f31185ceca9f931c470314a0 100644 (file)
@@ -11,10 +11,8 @@ package org.opendaylight.bgpcep.pcep.topology.provider;
 import static java.util.Objects.requireNonNull;
 
 import com.google.common.base.Optional;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.MoreExecutors;
+import java.util.concurrent.ExecutionException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -23,6 +21,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.lsp.db.version.tlv.LspDbVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.speaker.entity.id.tlv.SpeakerEntityIdBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Tlvs1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.Node1;
@@ -35,7 +34,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class PCEPStatefulPeerProposal {
+final class PCEPStatefulPeerProposal {
 
     private static final Logger LOG = LoggerFactory.getLogger(PCEPStatefulPeerProposal.class);
 
@@ -52,30 +51,35 @@ public final class PCEPStatefulPeerProposal {
         return new PCEPStatefulPeerProposal(dataBroker, topologyId);
     }
 
-    void setPeerProposal(final NodeId nodeId, final TlvsBuilder openTlvsBuilder) {
+    void setPeerProposal(final NodeId nodeId, final TlvsBuilder openTlvsBuilder, final byte[] speakerId) {
         if (isSynOptimizationEnabled(openTlvsBuilder)) {
+            Optional<LspDbVersion> result = Optional.absent();
             try (final ReadOnlyTransaction rTx = this.dataBroker.newReadOnlyTransaction()) {
                 final ListenableFuture<Optional<LspDbVersion>> future = rTx.read(
-                    LogicalDatastoreType.OPERATIONAL,
-                    this.topologyId.child(Node.class, new NodeKey(nodeId)).augmentation(Node1.class)
-                    .child(PathComputationClient.class).augmentation(PathComputationClient1.class)
-                    .child(LspDbVersion.class));
-                Futures.addCallback(future, new FutureCallback<Optional<LspDbVersion>>() {
-                    @Override
-                    public void onSuccess(final Optional<LspDbVersion> result) {
-                        if (result.isPresent()) {
-                            openTlvsBuilder.addAugmentation(Tlvs3.class,
-                                new Tlvs3Builder().setLspDbVersion(result.get()).build());
-                        }
-                    }
+                        LogicalDatastoreType.OPERATIONAL,
+                        this.topologyId.child(Node.class, new NodeKey(nodeId)).augmentation(Node1.class)
+                                .child(PathComputationClient.class).augmentation(PathComputationClient1.class)
+                                .child(LspDbVersion.class));
+                try {
+                    result = future.get();
+                } catch (final InterruptedException | ExecutionException e) {
+                    LOG.warn("Failed to read toplogy {}.", InstanceIdentifier.keyOf(
+                            PCEPStatefulPeerProposal.this.topologyId), e);
 
-                    @Override
-                    public void onFailure(final Throwable t) {
-                        LOG.warn("Failed to read toplogy {}.", InstanceIdentifier.keyOf(
-                            PCEPStatefulPeerProposal.this.topologyId), t);
-                    }
-                }, MoreExecutors.directExecutor());
+                }
             }
+            if (speakerId == null && !result.isPresent()) {
+                return;
+            }
+            final Tlvs3Builder syncBuilder = new Tlvs3Builder();
+
+            if (result.isPresent()) {
+                syncBuilder.setLspDbVersion(result.get());
+            }
+            if (speakerId != null) {
+                syncBuilder.setSpeakerEntityId(new SpeakerEntityIdBuilder().setSpeakerEntityIdValue(speakerId).build());
+            }
+            openTlvsBuilder.addAugmentation(Tlvs3.class, syncBuilder.build()).build();
         }
     }
 
@@ -86,5 +90,4 @@ public final class PCEPStatefulPeerProposal {
         }
         return false;
     }
-
 }
index d047127c427fc6ff28ffbaad4a4370af7ee67c27..3ac8aacc00e34c71d37bdc8c6a2b10a376c570cb 100755 (executable)
@@ -258,7 +258,8 @@ final class ServerSessionManager implements PCEPSessionListenerFactory, Topology
     @Override
     public void setPeerSpecificProposal(final InetSocketAddress address, final TlvsBuilder openBuilder) {
         requireNonNull(address);
-        this.peerProposal.setPeerProposal(createNodeId(address.getAddress()), openBuilder);
+        final byte[] speakerId = this.pcepDispatcherDependencies.getSpeakerIdMapping().get(address.getAddress());
+        this.peerProposal.setPeerProposal(createNodeId(address.getAddress()), openBuilder, speakerId);
     }
 
     short getRpcTimeout() {
index 3f3fa031457ff117444db79c23214569fb6df78d..24da2b33bb2a3c7e0f1d0522428023437d088f96 100644 (file)
@@ -13,6 +13,7 @@ import java.net.InetSocketAddress;
 import javax.annotation.Nonnull;
 import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
 import org.opendaylight.protocol.concepts.KeyMapping;
+import org.opendaylight.protocol.pcep.SpeakerIdMapping;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
@@ -25,16 +26,19 @@ public final class PCEPTopologyConfiguration {
     private final InstructionScheduler scheduler;
     private final TopologyId topologyId;
     private final short rpcTimeout;
+    private final SpeakerIdMapping speakerIds;
     private final InstanceIdentifier<Topology> topology;
 
     public PCEPTopologyConfiguration(
             @Nonnull final InetSocketAddress address,
             @Nonnull final KeyMapping keys,
+            @Nonnull final SpeakerIdMapping speakerIds,
             @Nonnull final InstructionScheduler scheduler,
             @Nonnull final TopologyId topologyId,
             final short rpcTimeout) {
         this.address = checkNotNull(address);
         this.keys = checkNotNull(keys);
+        this.speakerIds = checkNotNull(speakerIds);
         this.scheduler = checkNotNull(scheduler);
         this.topologyId = checkNotNull(topologyId);
         this.rpcTimeout = rpcTimeout;
@@ -70,4 +74,9 @@ public final class PCEPTopologyConfiguration {
     public KeyMapping getKeys() {
         return this.keys;
     }
+
+    @Nonnull
+    public SpeakerIdMapping getSpeakerIds() {
+        return this.speakerIds;
+    }
 }
index 4436a582db235eb838dab4d6ae466169f76ba9e4..dd5898bbf9e2d0138fb09fb580222b09132a25df 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.protocol.concepts.KeyMapping;
+import org.opendaylight.protocol.pcep.SpeakerIdMapping;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev171025.pcep.config.SessionConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.config.rev171025.PcepTopologyTypeConfig;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
@@ -115,8 +116,9 @@ public class PCEPTopologyDeployerImpl implements ClusteredDataTreeChangeListener
                 .getInetSocketAddress(config.getListenAddress(), config.getListenPort());
 
         final KeyMapping keys = PCEPTopologyProviderUtil.contructKeys(topology);
+        final SpeakerIdMapping speakerIds = PCEPTopologyProviderUtil.contructSpeakersId(topology);
         final PCEPTopologyConfiguration dependencies = new PCEPTopologyConfiguration(
-                inetAddress, keys, instructionScheduler, topology.getTopologyId(),
+                inetAddress, keys, speakerIds, instructionScheduler, topology.getTopologyId(),
                 config.getRpcTimeout());
 
         final PCEPTopologyProviderBean pcepTopologyProviderBean = (PCEPTopologyProviderBean) this.container
index 888d2836c94e2125091694a51ec57ecc512f25ba..10159feb66f90ab79d289191b0d4ed4e3f9637b4 100644 (file)
@@ -16,12 +16,14 @@ import java.util.concurrent.TimeUnit;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 import org.opendaylight.protocol.concepts.KeyMapping;
+import org.opendaylight.protocol.pcep.SpeakerIdMapping;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.config.rev171025.PcepNodeConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.TopologyTypes1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.sync.optimizations.config.rev171025.PcepNodeSyncConfig;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypes;
@@ -79,4 +81,23 @@ final class PCEPTopologyProviderUtil {
             topology.close();
         }
     }
+
+    static SpeakerIdMapping contructSpeakersId(final Topology topology) {
+        final SpeakerIdMapping ret = SpeakerIdMapping.getSpeakerIdMap();
+        topology.getNode().stream()
+                .filter(Objects::nonNull)
+                .filter(node -> node.getAugmentation(PcepNodeConfig.class) != null)
+                .filter(node -> node.getAugmentation(PcepNodeConfig.class).getSessionConfig() != null)
+                .filter(node -> node.getAugmentation(PcepNodeConfig.class).getSessionConfig()
+                        .getAugmentation(PcepNodeSyncConfig.class) != null)
+                .forEach(node -> {
+                    final PcepNodeConfig config = node.getAugmentation(PcepNodeConfig.class);
+                    final PcepNodeSyncConfig nodeSyncConfig = config.getSessionConfig()
+                            .getAugmentation(PcepNodeSyncConfig.class);
+                    final InetAddress address = InetAddresses.forString(node.getNodeId().getValue());
+                    ret.put(address, nodeSyncConfig.getSpeakerEntityIdValue());
+                });
+
+        return ret;
+    }
 }
index 7bd31ba78c4a9133ac14ca7a444124f028654134..6350c7e094228d9c95bfa72ffc4d79d56542d515 100644 (file)
@@ -15,14 +15,19 @@ import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.LongAdder;
 import org.opendaylight.protocol.pcep.PCEPSessionState;
 import org.opendaylight.protocol.util.StatisticsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.Tlvs3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev171025.speaker.entity.id.tlv.SpeakerEntityId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev171025.Pcinitiate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.Pcupd;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.PcepEntityIdStatsAug;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.PcepEntityIdStatsAugBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulCapabilitiesStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulCapabilitiesStatsAugBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAug;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev171113.StatefulMessagesStatsAugBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.PcepSessionState;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPref;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.LocalPrefBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.Messages;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.PeerCapabilities;
@@ -31,6 +36,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.sta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTime;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.reply.time.grouping.ReplyTimeBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
 
 public final class SessionStateImpl implements PcepSessionState {
@@ -57,7 +63,19 @@ public final class SessionStateImpl implements PcepSessionState {
     public synchronized void init(final PCEPSessionState session) {
         requireNonNull(session);
         this.pcepSessionState = session;
-        this.localPref = session.getLocalPref();
+        final Open localOpen = session.getLocalOpen();
+
+        if (localOpen.getTlvs() != null && localOpen.getTlvs().getAugmentation(Tlvs3.class) != null) {
+            final SpeakerEntityId entityId = localOpen.getTlvs().getAugmentation(Tlvs3.class).getSpeakerEntityId();
+            if (entityId != null) {
+                this.localPref = new LocalPrefBuilder(session.getLocalPref())
+                        .addAugmentation(PcepEntityIdStatsAug.class,
+                                new PcepEntityIdStatsAugBuilder(entityId).build()).build();
+            }
+        } else {
+            this.localPref = session.getLocalPref();
+        }
+
         this.peerPref = session.getPeerPref();
         this.sessionUpDuration.start();
     }
index 41d5ee6630478fb6646e20b9b1752c243a8e4a8f..ddde0d0df8a9740d7e34ab78d49b325a0d911103 100644 (file)
@@ -40,6 +40,7 @@ import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
 import org.opendaylight.protocol.concepts.KeyMapping;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
+import org.opendaylight.protocol.pcep.SpeakerIdMapping;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiator;
 import org.opendaylight.protocol.pcep.impl.PCEPSessionImpl;
 import org.opendaylight.protocol.util.InetSocketAddressUtil;
@@ -143,7 +144,7 @@ public abstract class AbstractPCEPSessionTest<T extends TopologySessionListenerF
                 .getActualTypeArguments()[0]).newInstance();
 
         final PCEPTopologyConfiguration configDep = new PCEPTopologyConfiguration(ra, KeyMapping.getKeyMapping(),
-                this.scheduler, TEST_TOPOLOGY_ID, RPC_TIMEOUT);
+                SpeakerIdMapping.getSpeakerIdMap(), this.scheduler, TEST_TOPOLOGY_ID, RPC_TIMEOUT);
         this.manager = new ServerSessionManager(this.topologyDependencies, listenerFactory, configDep);
         startSessionManager();
         this.neg = new DefaultPCEPSessionNegotiator(this.promise, this.clientListener,
index 3fa306d4f085db1d4e9fd3debbe50cce14218c0d..c53549112b2a157286349b5072f09ae7256ca202 100644 (file)
@@ -8,6 +8,7 @@
 
 package org.opendaylight.bgpcep.pcep.topology.provider;
 
+import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 import static org.mockito.Matchers.any;
@@ -52,6 +53,7 @@ public class PCEPStatefulPeerProposalTest {
     private static final NodeId NODE_ID = new NodeId("node");
     private static final LspDbVersion LSP_DB_VERSION = new LspDbVersionBuilder().setLspDbVersionValue(
             BigInteger.ONE).build();
+    private static final byte[] SPEAKER_ID = {0x01, 0x02, 0x03, 0x04};
 
     @Mock
     private DataBroker dataBroker;
@@ -85,27 +87,38 @@ public class PCEPStatefulPeerProposalTest {
     @Test
     public void testSetPeerProposalSuccess() throws InterruptedException, ExecutionException {
         doReturn(Optional.of(LSP_DB_VERSION)).when(this.listenableFutureMock).get();
-        final PCEPStatefulPeerProposal peerProposal = PCEPStatefulPeerProposal.createStatefulPeerProposal(this.dataBroker,
-                TOPOLOGY_IID);
-        peerProposal.setPeerProposal(NODE_ID, this.tlvsBuilder);
+        final PCEPStatefulPeerProposal peerProposal = PCEPStatefulPeerProposal
+                .createStatefulPeerProposal(this.dataBroker, TOPOLOGY_IID);
+        peerProposal.setPeerProposal(NODE_ID, this.tlvsBuilder, null);
         assertEquals(LSP_DB_VERSION, this.tlvsBuilder.getAugmentation(Tlvs3.class).getLspDbVersion());
     }
 
+    @Test
+    public void testSetPeerProposalWithEntityIdSuccess() throws InterruptedException, ExecutionException {
+        doReturn(Optional.of(LSP_DB_VERSION)).when(this.listenableFutureMock).get();
+        final PCEPStatefulPeerProposal peerProposal = PCEPStatefulPeerProposal
+                .createStatefulPeerProposal(this.dataBroker, TOPOLOGY_IID);
+        peerProposal.setPeerProposal(NODE_ID, this.tlvsBuilder, SPEAKER_ID);
+        final Tlvs3 aug = this.tlvsBuilder.getAugmentation(Tlvs3.class);
+        assertEquals(LSP_DB_VERSION, aug.getLspDbVersion());
+        assertArrayEquals(SPEAKER_ID, aug.getSpeakerEntityId().getSpeakerEntityIdValue());
+    }
+
     @Test
     public void testSetPeerProposalAbsent() throws InterruptedException, ExecutionException {
         doReturn(Optional.absent()).when(this.listenableFutureMock).get();
-        final PCEPStatefulPeerProposal peerProposal = PCEPStatefulPeerProposal.createStatefulPeerProposal(this.dataBroker,
-                TOPOLOGY_IID);
-        peerProposal.setPeerProposal(NODE_ID, this.tlvsBuilder);
+        final PCEPStatefulPeerProposal peerProposal = PCEPStatefulPeerProposal
+                .createStatefulPeerProposal(this.dataBroker, TOPOLOGY_IID);
+        peerProposal.setPeerProposal(NODE_ID, this.tlvsBuilder, null);
         assertNull(this.tlvsBuilder.getAugmentation(Tlvs3.class));
     }
 
     @Test
     public void testSetPeerProposalFailure() throws InterruptedException, ExecutionException {
-        doThrow(new RuntimeException()).when(this.listenableFutureMock).get();
-        final PCEPStatefulPeerProposal peerProposal = PCEPStatefulPeerProposal.createStatefulPeerProposal(this.dataBroker,
-                TOPOLOGY_IID);
-        peerProposal.setPeerProposal(NODE_ID, this.tlvsBuilder);
+        doThrow(new InterruptedException()).when(this.listenableFutureMock).get();
+        final PCEPStatefulPeerProposal peerProposal = PCEPStatefulPeerProposal
+                .createStatefulPeerProposal(this.dataBroker, TOPOLOGY_IID);
+        peerProposal.setPeerProposal(NODE_ID, this.tlvsBuilder, null);
         assertNull(this.tlvsBuilder.getAugmentation(Tlvs3.class));
     }