private final String name;
private final YangInstanceIdentifier adjRibsInId;
private final DOMTransactionChain chain;
+ private final DOMTransactionChain writerChain;
private AdjRibInWriter writer;
final NodeIdentifierWithPredicates peerId = IdentifierUtils.domPeerId(RouterIds.createPeerId(ipAddress));
this.adjRibsInId = this.targetRib.getYangRibId().node(Peer.QNAME).node(peerId).node(AdjRibIn.QNAME).node(Tables.QNAME);
this.chain = this.targetRib.createPeerChain(this);
- this.writer = AdjRibInWriter.create(this.targetRib.getYangRibId(), PeerRole.Ibgp, this.targetRib.createPeerChain(this));
+ this.writerChain = this.targetRib.createPeerChain(this);
+ this.writer = AdjRibInWriter.create(this.targetRib.getYangRibId(), PeerRole.Ibgp, this.writerChain);
// FIXME: set to true, once it's fixed how to skip advertising routes back to AppPeer
this.writer = this.writer.transform(RouterIds.createPeerId(ipAddress), this.targetRib.getRibSupportContext(), this.targetRib.getLocalTablesKeys(), false);
}
public void close() {
this.writer.cleanTables(this.targetRib.getLocalTablesKeys());
this.chain.close();
+ this.writerChain.close();
}
@Override
import org.opendaylight.controller.md.sal.common.api.data.TransactionChain;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
import org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain;
-import org.opendaylight.protocol.bgp.rib.impl.spi.AdjRIBsOutRegistration;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionStatistics;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIB;
import org.opendaylight.protocol.bgp.rib.impl.spi.ReusableBGPPeer;
@GuardedBy("this")
private final Set<TablesKey> tables = new HashSet<>();
- private final RIB rib;
- private final String name;
-
@GuardedBy("this")
private BGPSession session;
@GuardedBy("this")
private byte[] rawIdentifier;
@GuardedBy("this")
- private AdjRIBsOutRegistration reg;
+ private DOMTransactionChain chain;
+ @GuardedBy("this")
+ private AdjRibInWriter ribWriter;
+ private final RIB rib;
+ private final String name;
private BGPPeerRuntimeRegistrator registrator;
private BGPPeerRuntimeRegistration runtimeReg;
private long sessionEstablishedCounter = 0L;
- @GuardedBy("this")
- private AdjRibInWriter ribWriter;
-
public BGPPeer(final String name, final RIB rib) {
this.rib = Preconditions.checkNotNull(rib);
this.name = name;
+ this.chain = rib.createPeerChain(this);
- final DOMTransactionChain chain = rib.createPeerChain(this);
// FIXME: make this configurable
final PeerRole role = PeerRole.Ibgp;
-
- this.ribWriter = AdjRibInWriter.create(rib.getYangRibId(), role, chain);
+ this.ribWriter = AdjRibInWriter.create(rib.getYangRibId(), role, this.chain);
}
@Override
return;
}
final Update message = (Update) msg;
- //this.rib.updateTables(this, message);
+
// update AdjRibs
final Attributes attrs = message.getAttributes();
MpReachNlri mpReach = null;
@Override
public synchronized void onSessionUp(final BGPSession session) {
LOG.info("Session with peer {} went up with tables: {}", this.name, session.getAdvertisedTableTypes());
-
this.session = session;
this.rawIdentifier = InetAddresses.forString(session.getBgpId().getValue()).getAddress();
for (final BgpTableType t : session.getAdvertisedTableTypes()) {
final TablesKey key = new TablesKey(t.getAfi(), t.getSafi());
-
this.tables.add(key);
- this.rib.initTable(this, key);
// not particularly nice
if (session instanceof BGPSessionImpl) {
AdjRibOutListener.create(key, this.rib.getYangRibId(), ((RIBImpl)this.rib).getService(), this.rib.getRibSupportContext(), ((BGPSessionImpl) session).getLimiter());
}
}
-
this.ribWriter = this.ribWriter.transform(RouterIds.createPeerId(session.getBgpId()), this.rib.getRibSupportContext(), this.tables, false);
-
- // Not particularly nice, but what can
- if (session instanceof BGPSessionImpl) {
- this.reg = this.rib.registerRIBsOut(this, new SessionRIBsOut((BGPSessionImpl) session));
- }
this.sessionEstablishedCounter++;
if (this.registrator != null) {
this.runtimeReg = this.registrator.register(this);
private synchronized void cleanup() {
// FIXME: BUG-196: support graceful restart
this.ribWriter.cleanTables(this.tables);
- for (final TablesKey key : this.tables) {
- this.rib.clearTable(this, key);
- }
-
- if (this.reg != null) {
- this.reg.close();
- this.reg = null;
- }
-
+ this.chain.close();
this.tables.clear();
}
return this.name;
}
- protected RIB getRib() {
- return this.rib;
- }
-
@Override
public void releaseConnection() {
dropConnection();
@Override
public void onTransactionChainFailed(final TransactionChain<?, ?> chain, final AsyncTransaction<?, ?> transaction, final Throwable cause) {
- // TODO Auto-generated method stub
-
+ LOG.error("Transaction chain failed.", cause);
+ this.dropConnection();
+ this.chain = this.rib.createPeerChain(this);
}
@Override
public void onTransactionChainSuccessful(final TransactionChain<?, ?> chain) {
- // TODO Auto-generated method stub
+ LOG.debug("Transaction chain {} successfull.", chain);
}
}