use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class BmpDeployerImpl method init.
public synchronized void init() {
final DOMDataWriteTransaction wTx = this.bmpDeployerDependencies.getDomDataBroker().newWriteOnlyTransaction();
wTx.merge(LogicalDatastoreType.OPERATIONAL, BMP_MONITOR_YII, EMPTY_PARENT_NODE);
wTx.submit();
this.registration = this.bmpDeployerDependencies.getDataBroker().registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, ODL_BMP_MONITORS_IID), this);
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class RIBImpl method closeServiceInstance.
public synchronized ListenableFuture<Void> closeServiceInstance() {
if (!this.isServiceInstantiated) {
LOG.trace("RIB {} already closed", this.ribId.getValue());
return Futures.immediateFuture(null);
}
LOG.info("Close RIB {}", this.ribId.getValue());
this.isServiceInstantiated = false;
setActive(false);
this.txChainToLocRibWriter.values().forEach(LocRibWriter::close);
this.txChainToLocRibWriter.clear();
final DOMDataWriteTransaction t = this.domChain.newWriteOnlyTransaction();
t.delete(LogicalDatastoreType.OPERATIONAL, getYangRibId());
final ListenableFuture<Void> cleanFuture = t.submit();
this.domChain.close();
return cleanFuture;
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class RIBImpl method instantiateServiceInstance.
public synchronized void instantiateServiceInstance() {
this.isServiceInstantiated = true;
setActive(true);
this.domChain = this.domDataBroker.createTransactionChain(this);
LOG.debug("Instantiating RIB table {} at {}", this.ribId, this.yangRibId);
final ContainerNode bgpRib = Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(BgpRib.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Rib.QNAME).build()).build();
final MapEntryNode ribInstance = Builders.mapEntryBuilder().withNodeIdentifier(new NodeIdentifierWithPredicates(Rib.QNAME, RIB_ID_QNAME, this.ribId.getValue())).addChild(ImmutableNodes.leafNode(RIB_ID_QNAME, this.ribId.getValue())).addChild(ImmutableNodes.mapNodeBuilder(Peer.QNAME).build()).addChild(Builders.containerBuilder().withNodeIdentifier(new NodeIdentifier(LocRib.QNAME)).addChild(ImmutableNodes.mapNodeBuilder(Tables.QNAME).build()).build()).build();
final DOMDataWriteTransaction trans = this.domChain.newWriteOnlyTransaction();
// merge empty BgpRib + Rib, to make sure the top-level parent structure is present
trans.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().node(BgpRib.QNAME).build(), bgpRib);
trans.put(LogicalDatastoreType.OPERATIONAL, this.yangRibId, ribInstance);
try {
trans.submit().checkedGet();
} catch (final TransactionCommitFailedException e) {
LOG.error("Failed to initiate RIB {}", this.yangRibId, e);
}
LOG.debug("Effective RIB created.");
this.localTablesKeys.forEach(this::startLocRib);
this.localTablesKeys.forEach(this::createLocRibWriter);
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class AdjRibInWriter method markTableUptodate.
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);
Futures.addCallback(tx.submit(), new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.trace("Write Attributes uptodate, succeed");
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Write Attributes uptodate failed", throwable);
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction in project bgpcep by opendaylight.
the class AdjRibInWriter method removePeer.
synchronized ListenableFuture<Void> removePeer() {
if (this.peerPath != null) {
LOG.info("AdjRibInWriter closed per Peer {} removed", AdjRibInWriter.this.peerPath);
final DOMDataWriteTransaction tx = this.chain.newWriteOnlyTransaction();
tx.delete(LogicalDatastoreType.OPERATIONAL, this.peerPath);
final ListenableFuture<Void> future = tx.submit();
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
public void onSuccess(final Void result) {
LOG.debug("Peer {} removed", AdjRibInWriter.this.peerPath);
}
@Override
public void onFailure(final Throwable t) {
LOG.warn("Failed to remove Peer {}", AdjRibInWriter.this.peerPath, t);
}
}, MoreExecutors.directExecutor());
return future;
}
return Futures.immediateFuture(null);
}
Aggregations