@Override public WriteTransaction newWriteOnlyTransaction() { final DOMDataWriteTransaction delegateTx = delegate.newWriteOnlyTransaction(); return new BindingDOMWriteTransactionAdapter<DOMDataWriteTransaction>(delegateTx, codec) { @Override public CheckedFuture<Void,TransactionCommitFailedException> submit() { return listenForFailure(this,super.submit()); } }; }
@Override public DOMDataTreeWriteTransaction newWriteOnlyTransaction() { final DOMDataWriteTransaction tx = delegate.newWriteOnlyTransaction(); return track(tx, new DOMDataTreeWriteTransactionAdapter(tx) { @Override public boolean cancel() { untrack(delegate()); return super.cancel(); } }); }
@Override public DOMDataWriteTransaction newWriteOnlyTransaction() { return delegate().newWriteOnlyTransaction(); } }
@Override public DOMDataWriteTransaction newWriteOnlyTransaction() { return delegate().newWriteOnlyTransaction(); } }
private BmpRibInWriter(final YangInstanceIdentifier tablesRoot, final DOMTransactionChain chain, final RIBExtensionConsumerContext ribExtensions, final Set<TablesKey> tableTypes, final BindingCodecTree tree) { this.chain = chain; final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); this.tables = createTableInstance(tableTypes, tablesRoot, tx, ribExtensions, tree).build(); LOG.debug("New RIB table {} structure installed.", tablesRoot.toString()); tx.submit(); }
void removePeer() { if(this.peerPath != null) { final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); tx.delete(LogicalDatastoreType.OPERATIONAL, this.peerPath); try { tx.submit().checkedGet(); } catch (final TransactionCommitFailedException e) { LOG.debug("Failed to remove Peer {}", this.peerPath, e); } } }
void removeRoutes(final MpUnreachNlri nlri) { final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi()); final TableContext ctx = this.tables.get(key); if (ctx == null) { LOG.debug("No table for {}, not accepting NLRI {}", key, nlri); return; } LOG.trace("Removing routes {}", nlri); final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); ctx.removeRoutes(tx, nlri); tx.submit(); }
@Override public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) { LOG.trace("Received data change {} to LocRib {}", changes, this); final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); try { /* * We use two-stage processing here in hopes that we avoid duplicate * calculations when multiple peers have changed a particular entry. */ final Map<RouteUpdateKey, RouteEntry> toUpdate = update(tx, changes); // Now walk all updated entries walkThrough(tx, toUpdate); } catch (final Exception e) { LOG.error("Failed to completely propagate updates {}, state is undefined", changes, e); } finally { tx.submit(); } }
void updateRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev130919.path.attributes.Attributes attributes) { final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi()); final TableContext ctx = this.tables.get(key); if (ctx == null) { LOG.debug("No table for {}, not accepting NLRI {}", key, nlri); return; } final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); ctx.writeRoutes(tx, nlri, attributes); LOG.trace("Write routes {}", nlri); tx.submit(); }
private void removeRoutes(final MpUnreachNlri nlri) { final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi()); final TableContext ctx = this.tables.get(key); if (ctx == null) { LOG.debug("No table for {}, not accepting NLRI {}", key, nlri); return; } LOG.trace("Removing routes {}", nlri); final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); ctx.removeRoutes(tx, nlri); tx.submit(); }
private void addRoutes(final MpReachNlri nlri, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang .bgp.message.rev130919.path.attributes.Attributes attributes) { final TablesKey key = new TablesKey(nlri.getAfi(), nlri.getSafi()); final TableContext ctx = this.tables.get(key); if (ctx == null) { LOG.debug("No table for {}, not accepting NLRI {}", key, nlri); return; } final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); ctx.writeRoutes(tx, nlri, attributes); LOG.trace("Write routes {}", nlri); tx.submit(); }
private void onPeerDown() { final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.delete(LogicalDatastoreType.OPERATIONAL, this.peerYangIId); wTx.submit(); close(); }
private void markTableUptodated(final TablesKey tableTypes) { final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); final TableContext ctxPre = this.tables.get(tableTypes); tx.merge(LogicalDatastoreType.OPERATIONAL, ctxPre.getTableId().node(BMP_ATTRIBUTES_QNAME).node(ATTRIBUTES_UPTODATE_TRUE.getNodeType()), ATTRIBUTES_UPTODATE_TRUE); tx.submit(); } }
void markTableUptodate(final TablesKey tableTypes) { final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); final TableContext ctx = this.tables.get(tableTypes); tx.merge(LogicalDatastoreType.OPERATIONAL, ctx.getTableId().node(Attributes.QNAME).node(ATTRIBUTES_UPTODATE_TRUE.getNodeType()), ATTRIBUTES_UPTODATE_TRUE); tx.submit(); }
/** * Transform this writer to a new writer, which is in charge of specified tables. * Empty tables are created for new entries and old tables are deleted. Once this * method returns, the old instance must not be reasonably used. * * @param newPeerId new peer BGP identifier * @param registry RIB extension registry * @param tableTypes New tables, must not be null * @param addPathTablesType * @return New writer */ AdjRibInWriter transform(final PeerId newPeerId, final RIBSupportContextRegistry registry, final Set<TablesKey> tableTypes, final List<AddressFamilies> addPathTablesType) { final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction(); final YangInstanceIdentifier newPeerPath; newPeerPath = createEmptyPeerStructure(newPeerId, tx); final ImmutableMap<TablesKey, TableContext> tb = createNewTableInstances(newPeerPath, registry, tableTypes, addPathTablesType, tx); tx.submit(); return new AdjRibInWriter(this.ribPath, this.chain, this.role, this.simpleRoutingPolicy, newPeerPath, tb); }
private void onRouteMirror(final RouteMirroringMessage mirror) { final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.merge(LogicalDatastoreType.OPERATIONAL, this.peerYangIId.node(Mirrors.QNAME), createMirrors(mirror, mirror.getPeerHeader().getTimestampSec())); wTx.submit(); }
private void onStatsReports(final StatsReportsMessage statsReports) { if (this.up) { final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.merge(LogicalDatastoreType.OPERATIONAL, this.peerYangIId.node(Stats.QNAME), createStats(statsReports, statsReports.getPeerHeader().getTimestampSec())); wTx.submit(); } }
private void createRouterEntry() { Preconditions.checkState(isDatastoreWritable()); final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(Router.QNAME, ROUTER_ID_QNAME, this.routerIp)) .withChild(ImmutableNodes.leafNode(ROUTER_ID_QNAME, routerIp)) .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, DOWN)) .withChild(ImmutableNodes.mapNodeBuilder(Peer.QNAME).build()).build()); wTx.submit(); }
private BmpRouterPeerImpl(final DOMTransactionChain domTxChain, final YangInstanceIdentifier peersYangIId, final PeerId peerId, final RIBExtensionConsumerContext extensions, final PeerUpNotification peerUp, final BindingCodecTree tree) { this.domTxChain = Preconditions.checkNotNull(domTxChain); this.peerId = peerId; this.peerYangIId = YangInstanceIdentifier.builder(peersYangIId).nodeWithKey(Peer.QNAME, PEER_ID_QNAME, this.peerId.getValue()).build(); this.sentOpenCodec = tree.getSubtreeCodec(SENT_OPEN_IID); this.receivedOpenCodec = tree.getSubtreeCodec(RECEIVED_OPEN_IID); final Set<TablesKey> peerTables = setPeerTables(peerUp.getReceivedOpen()); final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.OPERATIONAL, this.peerYangIId, createPeerEntry(peerUp)); wTx.submit(); this.prePolicyWriter = BmpRibInWriter.create(this.peerYangIId.node(PrePolicyRib.QNAME).node(BMP_TABLES_QNAME), this.domTxChain, extensions, peerTables, tree); this.postPolicyWriter = BmpRibInWriter.create(this.peerYangIId.node(PostPolicyRib.QNAME).node(BMP_TABLES_QNAME), this.domTxChain, extensions, peerTables, tree); }
private void onInitiate(final InitiationMessage initiation) { Preconditions.checkState(isDatastoreWritable()); final DOMDataWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction(); wTx.merge(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder() .withNodeIdentifier(new NodeIdentifierWithPredicates(Router.QNAME, ROUTER_ID_QNAME, this.routerIp)) .withChild(ImmutableNodes.leafNode(ROUTER_NAME_QNAME, initiation.getTlvs().getNameTlv().getName())) .withChild(ImmutableNodes.leafNode(ROUTER_DESCRIPTION_QNAME, initiation.getTlvs().getDescriptionTlv().getDescription())) .withChild(ImmutableNodes.leafNode(ROUTER_INFO_QNAME, getStringInfo(initiation.getTlvs().getStringInformation()))) .withChild(ImmutableNodes.leafNode(ROUTER_STATUS_QNAME, UP)).build()); wTx.submit(); }