Search in sources :

Example 36 with DOMDataWriteTransaction

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);
}
Also used : DataTreeIdentifier(org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 37 with DOMDataWriteTransaction

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;
}
Also used : DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 38 with DOMDataWriteTransaction

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);
}
Also used : TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 39 with DOMDataWriteTransaction

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());
}
Also used : DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Example 40 with DOMDataWriteTransaction

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);
}
Also used : DOMDataWriteTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)

Aggregations

DOMDataWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction)42 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)14 Test (org.junit.Test)11 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)11 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)9 CountDownLatch (java.util.concurrent.CountDownLatch)7 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)7 DataTreeCandidate (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)7 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode)7 DOMDataTreeChangeService (org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService)6 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)5 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey)5 DOMTransactionChain (org.opendaylight.controller.md.sal.dom.api.DOMTransactionChain)4 QName (org.opendaylight.yangtools.yang.common.QName)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 DOMDataReadOnlyTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction)3 DOMDataReadWriteTransaction (org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction)3 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)3 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)3 InetSocketAddress (java.net.InetSocketAddress)2