Instantiate BgpPeer only once 34/96034/1
authorOleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
Thu, 25 Mar 2021 17:58:00 +0000 (19:58 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 10 May 2021 11:52:12 +0000 (11:52 +0000)
For some reason in clustered configuration BgpPeer might be instantiated
twice and this leads to service failure, this patch introduce additional
check to avoid this.

JIRA: BGPCEP-948
Change-Id: Icb355abf89ba1dee0281c32d6dd60c95fcdfdb61
Signed-off-by: Oleksii Mozghovyi <oleksii.mozghovyi@pantheon.tech>
(cherry picked from commit d73b2dd19bbc0989f1c9fdc44419657d176f26cd)

bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java

index 84e78b7b7d7dad59d6839cfa8a5201afdccdac7b..5006b36d5fd3879f3af11659d98c269bd907bae0 100644 (file)
@@ -166,6 +166,7 @@ public class BgpPeer implements PeerBean, BGPPeerStateConsumer {
     @Override
     public void close() {
         if (this.bgpPeerSingletonService != null) {
+            this.bgpPeerSingletonService.closeServiceInstance();
             this.bgpPeerSingletonService = null;
         }
         if (this.serviceRegistration != null) {
@@ -331,6 +332,10 @@ public class BgpPeer implements PeerBean, BGPPeerStateConsumer {
         }
 
         synchronized void instantiateServiceInstance() {
+            if (isServiceInstantiated) {
+                LOG.warn("Peer {} has already been instantiated", this.neighborAddress);
+                return;
+            }
             this.isServiceInstantiated = true;
             LOG.info("Peer instantiated {}", this.neighborAddress);
             this.bgpPeer.instantiateServiceInstance();