import org.opendaylight.protocol.bgp.rib.spi.IdentifierUtils;
import org.opendaylight.protocol.bgp.rib.spi.RibSupportUtils;
import org.opendaylight.protocol.bgp.rib.spi.RouterIds;
+import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPAfiSafiState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPErrorHandlingState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPSessionState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.Peer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.PeerKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.AdjRibIn;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.Tables;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
* peer needs to have a BGP-ID that is configurable.
*/
public class ApplicationPeer extends BGPPeerStateImpl implements org.opendaylight.protocol.bgp.rib.spi.Peer,
- ClusteredDOMDataTreeChangeListener, TransactionChainListener {
+ BGPRouteEntryImportParameters, ClusteredDOMDataTreeChangeListener, TransactionChainListener {
private static final Logger LOG = LoggerFactory.getLogger(ApplicationPeer.class);
private final YangInstanceIdentifier adjRibsInId;
private final Ipv4Address ipAddress;
private final RIB rib;
- private final YangInstanceIdentifier peerIId;
+ private final KeyedInstanceIdentifier<Peer, PeerKey> peerIId;
+ private final YangInstanceIdentifier peerYIId;
private DOMTransactionChain chain;
private DOMTransactionChain writerChain;
private EffectiveRibInWriter effectiveRibInWriter;
private ListenerRegistration<ApplicationPeer> registration;
private final Set<NodeIdentifierWithPredicates> supportedTables = new HashSet<>();
private final BGPSessionStateImpl bgpSessionState = new BGPSessionStateImpl();
- private PeerId peerId;
+ private final PeerId peerId;
private AbstractRegistration trackerRegistration;
@FunctionalInterface
final RIB targetRib = requireNonNull(rib);
this.rawIdentifier = InetAddresses.forString(ipAddress.getValue()).getAddress();
final NodeIdentifierWithPredicates peerIId = IdentifierUtils.domPeerId(RouterIds.createPeerId(ipAddress));
- this.peerIId = targetRib.getYangRibId().node(Peer.QNAME).node(peerIId);
- this.adjRibsInId = this.peerIId.node(AdjRibIn.QNAME).node(Tables.QNAME);
+ this.peerYIId = targetRib.getYangRibId().node(Peer.QNAME).node(peerIId);
+ this.adjRibsInId = this.peerYIId.node(AdjRibIn.QNAME).node(Tables.QNAME);
this.rib = targetRib;
this.ipAddress = ipAddress;
+ this.peerId = RouterIds.createPeerId(ipAddress);
+ this.peerIId = getInstanceIdentifier().child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .yang.bgp.rib.rev171207.bgp.rib.rib.Peer.class, new PeerKey(this.peerId));
}
public synchronized void instantiateServiceInstance(final DOMDataTreeChangeService dataTreeChangeService,
final DOMDataTreeIdentifier appPeerDOMId) {
setActive(true);
- this.chain = this.rib.createPeerChain(this);
- this.writerChain = this.rib.createPeerChain(this);
+ this.chain = this.rib.createPeerDOMChain(this);
+ this.writerChain = this.rib.createPeerDOMChain(this);
- this.peerId = RouterIds.createPeerId(this.ipAddress);
final Set<TablesKey> localTables = this.rib.getLocalTablesKeys();
localTables.forEach(tablesKey -> {
final ExportPolicyPeerTracker exportTracker = this.rib.getExportPolicyPeerTracker(tablesKey);
if (exportTracker != null) {
- exportTracker.registerPeer(this.peerId, null, this.peerIId, PeerRole.Internal);
+ exportTracker.registerPeer(this.peerId, null, this.peerYIId, PeerRole.Internal);
}
this.supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey));
});
this.adjRibInWriter = this.adjRibInWriter.transform(this.peerId, context, localTables, Collections.emptyMap(),
registerAppPeerListener);
this.effectiveRibInWriter = EffectiveRibInWriter
- .create(this.rib, this.rib.createPeerChain(this), this.peerIId, localTables);
+ .create(this, this.rib, this.rib.createPeerChain(this), this.peerIId, localTables);
this.bgpSessionState.registerMessagesCounter(this);
this.trackerRegistration = this.rib.getPeerTracker().registerPeer(this);
}
@Override
public YangInstanceIdentifier getPeerRibInstanceIdentifier() {
- return this.peerIId;
+ return this.peerYIId;
}
@Override
public BGPTransportState getBGPTransportState() {
return this.bgpSessionState;
}
+
+
+ @Override
+ public PeerRole getFromPeerRole() {
+ return getRole();
+ }
+
+ @Override
+ public PeerId getFromPeerId() {
+ return getPeerId();
+ }
}