From d73b2dd19bbc0989f1c9fdc44419657d176f26cd Mon Sep 17 00:00:00 2001 From: Oleksii Mozghovyi Date: Thu, 25 Mar 2021 19:58:00 +0200 Subject: [PATCH] Instantiate BgpPeer only once 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 --- .../opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java index 84e78b7b7d..5006b36d5f 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/BgpPeer.java @@ -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(); -- 2.36.6