Additional methods added to PCEPSession. 39/2039/2
authorMaros Marsalek <mmarsale@cisco.com>
Wed, 16 Oct 2013 13:31:47 +0000 (15:31 +0200)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 21 Oct 2013 11:51:53 +0000 (11:51 +0000)
Added getters for remote address and remote PCEPTlvs in order for session listener to access this information.

+ Fixed bundle configuration issues for pcep-impl

Change-Id: Ibc59378de7b99912d4e3d5e54881e59e84514146
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Signed-off-by: Robert Varga <rovarga@cisco.com>
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSession.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java

index 74c1107529d9018d0bb76b93015bcd9727160bc8..caaa044d5778db40993f10f4521aa61d128821ff 100644 (file)
@@ -7,8 +7,11 @@
  */
 package org.opendaylight.protocol.pcep;
 
+import java.net.InetAddress;
+
 import org.opendaylight.protocol.framework.ProtocolSession;
 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.Tlvs;
 
 /**
  * PCEP Session represents the finite state machine in PCEP, including timers and its purpose is to create a PCEP
@@ -22,10 +25,14 @@ public interface PCEPSession extends ProtocolSession<Message> {
         * Sends message from user to PCE/PCC. If the user sends an Open Message, the session returns an error (open message
         * is only allowed, when a PCEP handshake is in progress). Close message will close the session and free all the
         * resources.
-        * 
+        *
         * @param message message to be sent
         */
        public void sendMessage(Message message);
 
        public void close(TerminationReason reason);
+
+       public Tlvs getRemoteTlvs();
+
+       public InetAddress getRemoteAddress();
 }
index 47cc916f8ba08d6f6915638c7eb3680bc31f7d93..bade1702dc186887a759a288775adda48ee8d178 100644 (file)
@@ -13,6 +13,7 @@ import io.netty.util.Timer;
 import io.netty.util.TimerTask;
 
 import java.io.IOException;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.util.Date;
 import java.util.LinkedList;
@@ -34,6 +35,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.close.message.CCloseMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.message.c.close.message.CCloseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -182,7 +184,7 @@ public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements
 
        /**
         * Sends message to serialization.
-        * 
+        *
         * @param msg to be sent
         */
        @Override
@@ -222,6 +224,16 @@ public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements
                this.channel.close();
        }
 
+       @Override
+       public Tlvs getRemoteTlvs() {
+               return remoteOpen.getTlvs();
+       }
+
+       @Override
+       public InetAddress getRemoteAddress() {
+               return ((InetSocketAddress) this.channel.remoteAddress()).getAddress();
+       }
+
        private synchronized void terminate(final TerminationReason reason) {
                this.listener.onSessionTerminated(this, new PCEPCloseTermination(reason));
                this.closed = true;
@@ -244,7 +256,7 @@ public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements
 
        /**
         * Sends PCEP Error Message with one PCEPError and Open Object.
-        * 
+        *
         * @param value
         * @param open
         */
@@ -257,7 +269,7 @@ public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements
         * sent (CAPABILITY_NOT_SUPPORTED) and the method checks if the MAX_UNKNOWN_MSG per minute wasn't overstepped.
         * Second, any other error occurred that is specified by rfc. In this case, the an error message is generated and
         * sent.
-        * 
+        *
         * @param error documented error in RFC5440 or draft
         */
        @VisibleForTesting
@@ -278,7 +290,7 @@ public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements
        /**
         * Handles incoming message. If the session is up, it notifies the user. The user is notified about every message
         * except KeepAlive.
-        * 
+        *
         * @param msg incoming message
         */
        @Override
@@ -362,10 +374,11 @@ public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements
 
        @Override
        public String getNodeIdentifier() {
-               if (this.remoteOpen.getTlvs() == null)
+               if (this.remoteOpen.getTlvs() == null) {
                        if (this.remoteOpen.getTlvs().getPredundancyGroupId() != null) {
                                return new String(this.remoteOpen.getTlvs().getPredundancyGroupId().getIdentifier());
                        }
+               }
                return "";
        }