this.clusterId = clusterId;
this.localAs = localAs;
this.rib = rib;
- this.domChain = this.rib.createPeerDOMChain(this);
+ createDomChain();
}
AbstractPeer(
}
}
+ final synchronized void createDomChain() {
+ if (this.domChain == null) {
+ LOG.info("Creating DOM peer chain {}", getPeerId());
+ this.domChain = this.rib.createPeerDOMChain(this);
+ }
+ }
+
final synchronized void closeDomChain() {
if (this.domChain != null) {
LOG.info("Closing DOM peer chain {}", getPeerId());
localTables.forEach(tablesKey -> this.supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey)));
setAdvertizedGracefulRestartTableTypes(Collections.emptyList());
+ createDomChain();
this.adjRibInWriter = AdjRibInWriter.create(this.rib.getYangRibId(), PeerRole.Internal, this);
final RIBSupportContextRegistry context = this.rib.getRibSupportContext();
final RegisterAppPeerListener registerAppPeerListener = () -> {
}
public synchronized void instantiateServiceInstance() {
+ createDomChain();
this.ribWriter = AdjRibInWriter.create(this.rib.getYangRibId(), this.peerRole, this);
setActive(true);
}
@Override
public void close() {
+ if (this.bgpPeerSingletonService != null) {
+ this.bgpPeerSingletonService = null;
+ }
if (this.serviceRegistration != null) {
this.serviceRegistration.unregister();
this.serviceRegistration = null;
@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
if (this.bgpPeerSingletonService != null) {
- final FluentFuture<? extends CommitInfo> fut = this.bgpPeerSingletonService.closeServiceInstance();
- this.bgpPeerSingletonService = null;
- return fut;
+ return this.bgpPeerSingletonService.closeServiceInstance();
}
return CommitInfo.emptyFluentFuture();
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.internal.verification.VerificationModeFactory.times;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.opendaylight.mdsal.dom.api.DOMTransactionChainListener;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ConfigBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder;
APP_PEER.start(this.rib, this.neighbor, null, this.peerGroupLoader, this.tableTypeRegistry);
Mockito.verify(this.rib).getYangRibId();
Mockito.verify(this.rib).getService();
+ Mockito.verify(this.rib).createPeerDOMChain(any(DOMTransactionChainListener.class));
Mockito.verify(this.rib, times(1)).getLocalTablesKeys();
APP_PEER.instantiateServiceInstance();
Mockito.verify(this.rib, times(3)).getYangRibId();
Mockito.verify(this.rib, times(2)).getRibSupportContext();
Mockito.verify(this.rib, times(2)).getLocalTablesKeys();
+ Mockito.verify(this.rib, times(2)).createPeerDOMChain(any(DOMTransactionChainListener.class));
Mockito.verify(this.domTx).newWriteOnlyTransaction();
APP_PEER.closeServiceInstance();
+ Mockito.verify(this.domTx, times(2)).close();
APP_PEER.close();
APP_PEER.restart(this.rib, null, this.peerGroupLoader, this.tableTypeRegistry);
APP_PEER.instantiateServiceInstance();
Mockito.verify(this.rib, times(6)).getYangRibId();
Mockito.verify(this.rib, times(4)).getService();
+ Mockito.verify(this.rib, times(4)).createPeerDOMChain(any(DOMTransactionChainListener.class));
Mockito.verify(this.listener, times(2)).close();
assertTrue(APP_PEER.containsEqualConfiguration(this.neighbor));
assertFalse(APP_PEER.containsEqualConfiguration(new NeighborBuilder()
.setNeighborAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build()));
APP_PEER.closeServiceInstance();
+ Mockito.verify(this.domTx, times(4)).close();
+
+ APP_PEER.instantiateServiceInstance();
+ Mockito.verify(this.rib, times(6)).createPeerDOMChain(any(DOMTransactionChainListener.class));
+ APP_PEER.closeServiceInstance();
+ Mockito.verify(this.domTx, times(6)).close();
APP_PEER.close();
}
-}
\ No newline at end of file
+}
}
this.bgpPeer.setServiceRegistration(this.serviceRegistration);
this.bgpPeer.closeServiceInstance();
- this.bgpPeer.close();
+ verify(this.bgpPeerRegistry).removePeer(any());
verify(this.future).cancel(true);
+ this.bgpPeer.close();
+ verify(this.serviceRegistration).unregister();
this.bgpPeer.restart(this.rib, null, this.peerGroupLoader, this.tableTypeRegistry);
this.bgpPeer.instantiateServiceInstance();
verify(this.bgpPeerRegistry).removePeer(any(IpAddress.class));
this.bgpPeer.closeServiceInstance();
+ verify(this.bgpPeerRegistry, times(2)).removePeer(any());
+ verify(this.future, times(2)).cancel(true);
+
+ this.bgpPeer.instantiateServiceInstance();
+ verify(this.bgpPeerRegistry, times(3)).addPeer(any(), any(), any());
+ verify(this.dispatcher, times(3)).createReconnectingClient(any(InetSocketAddress.class),
+ any(), anyInt(), any(KeyMapping.class));
+
+ this.bgpPeer.closeServiceInstance();
+ verify(this.bgpPeerRegistry, times(3)).removePeer(any());
+ verify(this.future, times(3)).cancel(true);
this.bgpPeer.close();
verify(this.serviceRegistration).unregister();
- verify(this.future, times(2)).cancel(true);
final Neighbor neighborDiffConfig = new NeighborBuilder().setNeighborAddress(NEIGHBOR_ADDRESS)
.setAfiSafis(createAfiSafi()).build();
assertTrue(this.bgpPeer.containsEqualConfiguration(neighborDiffConfig));
this.bgpPeer.close();
}
-}
\ No newline at end of file
+}