Once Peer session is closed. Listener needs to be removed.
Change-Id: Ie3575bdd42e9b0924e48f110652d0c595b42804c
Signed-off-by: Claudio D. Gasparini <cgaspari@cisco.com>
@Override
public void operationComplete(final ChannelFuture f) {
if (!f.isSuccess()) {
- LOG.info("Failed to send message {}", msg, f.cause());
+ LOG.warn("Failed to send message {}", msg, f.cause());
negotiationFailedCloseChannel(f.cause());
} else {
LOG.trace("Message {} sent to socket", msg);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.bgp.rib.rib.peer.AdjRibOut;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.TablesKey;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
private final Codecs codecs;
private final RIBSupport support;
private final boolean mpSupport;
+ private final ListenerRegistration<AdjRibOutListener> registerDataTreeChangeListener;
private AdjRibOutListener(final PeerId peerId, final TablesKey tablesKey, final YangInstanceIdentifier ribId,
final CodecsRegistry registry, final RIBSupport support, final DOMDataTreeChangeService service,
this.codecs = registry.getCodecs(this.support);
this.mpSupport = mpSupport;
final YangInstanceIdentifier adjRibOutId = ribId.node(Peer.QNAME).node(IdentifierUtils.domPeerId(peerId)).node(AdjRibOut.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(tablesKey));
- service.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, adjRibOutId), this);
+ this.registerDataTreeChangeListener = service.registerDataTreeChangeListener(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, adjRibOutId), this);
}
static AdjRibOutListener create(@Nonnull final PeerId peerId, @Nonnull final TablesKey tablesKey, @Nonnull final YangInstanceIdentifier ribId, @Nonnull final CodecsRegistry registry, @Nonnull final RIBSupport support, @Nonnull final DOMDataTreeChangeService service, @Nonnull final ChannelOutputLimiter session, @Nonnull final boolean mpSupport) {
}
return prefs;
}
+
+ public void close() {
+ this.registerDataTreeChangeListener.close();
+ }
}
private BGPPeerRuntimeRegistrator registrator;
private BGPPeerRuntimeRegistration runtimeReg;
private long sessionEstablishedCounter = 0L;
+ private AdjRibOutListener adjRibOutListener;
public BGPPeer(final String name, final RIB rib) {
this(name, rib, PeerRole.Ibgp);
// not particularly nice
if (context != null && this.session instanceof BGPSessionImpl) {
- AdjRibOutListener.create(peerId, key, this.rib.getYangRibId(), this.rib.getCodecsRegistry(), context.getRibSupport(), ((RIBImpl) this.rib).getService(),
- ((BGPSessionImpl) this.session).getLimiter(), mpSupport);
+ this.adjRibOutListener = AdjRibOutListener.create(peerId, key, this.rib.getYangRibId(), this.rib.getCodecsRegistry(), context.getRibSupport(),
+ ((RIBImpl) this.rib).getService(), ((BGPSessionImpl) this.session).getLimiter(), mpSupport);
}
}
private synchronized void cleanup() {
- // FIXME: BUG-196: support graceful restart
+ // FIXME: BUG-196: support graceful
+ this.adjRibOutListener.close();
this.ribWriter.cleanTables(this.tables);
this.tables.clear();
}
@Override
public void operationComplete(final ChannelFuture f) {
if (!f.isSuccess()) {
- LOG.info("Failed to send message {} to socket {}", msg, f.cause(), BGPSessionImpl.this.channel);
+ LOG.warn("Failed to send message {} to socket {}", msg, f.cause(), BGPSessionImpl.this.channel);
} else {
LOG.trace("Message {} sent to socket {}", msg, BGPSessionImpl.this.channel);
}
import org.opendaylight.yangtools.binding.data.codec.gen.impl.DataObjectSerializerGenerator;
import org.opendaylight.yangtools.binding.data.codec.gen.impl.StreamWriterGenerator;
import org.opendaylight.yangtools.binding.data.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
private void mockedMethods() throws Exception {
MockitoAnnotations.initMocks(this);
final ReadOnlyTransaction readTx = Mockito.mock(ReadOnlyTransaction.class);
- Mockito.doReturn(null).when(this.service).registerDataTreeChangeListener(Mockito.any(DOMDataTreeIdentifier.class), Mockito.any(DOMDataTreeChangeListener.class));
+ Mockito.doReturn(new listenerRegistration()).when(this.service).registerDataTreeChangeListener(Mockito.any(DOMDataTreeIdentifier.class), Mockito.any(DOMDataTreeChangeListener.class));
final Map<Class<? extends DOMDataBrokerExtension>, DOMDataBrokerExtension> map = new HashMap<>();
map.put(DOMDataTreeChangeService.class, this.service);
Mockito.doNothing().when(readTx).close();
public void tearDown() {
this.a1.close();
}
+
+ private class listenerRegistration implements ListenerRegistration {
+ @Override
+ public Object getInstance() {
+ return null;
+ }
+
+ public void close() {
+ }
+ }
}