Search in sources :

Example 31 with CommitInfo

use of org.opendaylight.mdsal.common.api.CommitInfo in project controller by opendaylight.

the class OpendaylightToaster method close.

/**
 * Implemented from the AutoCloseable interface.
 */
@Override
public void close() {
    LOG.info("Closing...");
    // Unregister our MXBean.
    unregister();
    // When we close this service we need to shutdown our executor!
    executor.shutdown();
    if (dataTreeChangeListenerRegistration != null) {
        dataTreeChangeListenerRegistration.close();
    }
    if (dataBroker != null) {
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        tx.delete(OPERATIONAL, TOASTER_IID);
        Futures.addCallback(tx.commit(), new FutureCallback<CommitInfo>() {

            @Override
            public void onSuccess(final CommitInfo result) {
                LOG.debug("Successfully deleted the operational Toaster");
            }

            @Override
            public void onFailure(final Throwable failure) {
                LOG.error("Delete of the operational Toaster failed", failure);
            }
        }, MoreExecutors.directExecutor());
    }
}
Also used : ReadWriteTransaction(org.opendaylight.mdsal.binding.api.ReadWriteTransaction) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 32 with CommitInfo

use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.

the class BmpRibInWriter method removeRoutes.

private synchronized 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 DOMDataTreeWriteTransaction tx = this.chain.newWriteOnlyTransaction();
    ctx.removeRoutes(tx, nlri);
    tx.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Successful commit");
        }

        @Override
        public void onFailure(final Throwable trw) {
            LOG.error("Failed commit", trw);
        }
    }, MoreExecutors.directExecutor());
}
Also used : TablesKey(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 33 with CommitInfo

use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.

the class BmpRouterPeerImpl method onPeerDown.

private synchronized void onPeerDown() {
    final DOMDataTreeWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, this.peerYangIId);
    wTx.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Successful commit");
        }

        @Override
        public void onFailure(final Throwable trw) {
            LOG.error("Failed commit", trw);
        }
    }, MoreExecutors.directExecutor());
    close();
}
Also used : DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Example 34 with CommitInfo

use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.

the class BmpMonitoringStationImpl method closeServiceInstance.

@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
    LOG.info("BMP Monitor Singleton Service {} instance closed, Monitor Id {}", getIdentifier().getName(), monitorId.getValue());
    if (channel != null) {
        channel.close().addListener((ChannelFutureListener) future -> {
            Preconditions.checkArgument(future.isSuccess(), "Channel failed to close: %s", future.cause());
            BmpMonitoringStationImpl.this.sessionManager.close();
        });
    }
    final DOMDataTreeWriteTransaction wTx = domDataBroker.newWriteOnlyTransaction();
    wTx.delete(LogicalDatastoreType.OPERATIONAL, yangMonitorId);
    LOG.info("BMP monitoring station {} closed.", monitorId.getValue());
    return wTx.commit();
}
Also used : DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) MonitoredRouter(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.config.rev200120.odl.bmp.monitors.bmp.monitor.config.MonitoredRouter) BindingCodecTree(org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree) BmpMonitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.BmpMonitor) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) Rfc2385Key(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.rfc2385.cfg.rev160324.Rfc2385Key) Monitor(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.bmp.monitor.Monitor) InetAddress(java.net.InetAddress) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) IetfInetUtil(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil) Objects.requireNonNull(java.util.Objects.requireNonNull) ChannelFutureListener(io.netty.channel.ChannelFutureListener) Map(java.util.Map) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo) ClusterSingletonServiceProvider(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider) MonitorId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.MonitorId) Logger(org.slf4j.Logger) Collection(java.util.Collection) KeyMapping(org.opendaylight.protocol.concepts.KeyMapping) InetSocketAddress(java.net.InetSocketAddress) QName(org.opendaylight.yangtools.yang.common.QName) ChannelFuture(io.netty.channel.ChannelFuture) Channel(io.netty.channel.Channel) ExecutionException(java.util.concurrent.ExecutionException) Ipv4Util(org.opendaylight.protocol.util.Ipv4Util) BmpMonitoringStation(org.opendaylight.protocol.bmp.impl.spi.BmpMonitoringStation) DOMDataBroker(org.opendaylight.mdsal.dom.api.DOMDataBroker) BmpDispatcher(org.opendaylight.protocol.bmp.api.BmpDispatcher) ImmutableNodes(org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Preconditions(com.google.common.base.Preconditions) InetAddresses(com.google.common.net.InetAddresses) RIBExtensionConsumerContext(org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext) Router(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev200120.routers.Router) FluentFuture(com.google.common.util.concurrent.FluentFuture) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)

Example 35 with CommitInfo

use of org.opendaylight.mdsal.common.api.CommitInfo in project bgpcep by opendaylight.

the class BmpRouterImpl method onInitiate.

private synchronized void onInitiate(final InitiationMessage initiation) {
    Preconditions.checkState(isDatastoreWritable());
    final DOMDataTreeWriteTransaction wTx = this.domTxChain.newWriteOnlyTransaction();
    wTx.merge(LogicalDatastoreType.OPERATIONAL, this.routerYangIId, Builders.mapEntryBuilder().withNodeIdentifier(NodeIdentifierWithPredicates.of(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.commit().addCallback(new FutureCallback<CommitInfo>() {

        @Override
        public void onSuccess(final CommitInfo result) {
            LOG.trace("Successful commit");
        }

        @Override
        public void onFailure(final Throwable trw) {
            LOG.error("Failed commit", trw);
        }
    }, MoreExecutors.directExecutor());
}
Also used : DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) CommitInfo(org.opendaylight.mdsal.common.api.CommitInfo)

Aggregations

CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)59 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)26 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)23 ReadWriteTransaction (org.opendaylight.mdsal.binding.api.ReadWriteTransaction)12 ExecutionException (java.util.concurrent.ExecutionException)10 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)8 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)7 TablesKey (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey)5 TransactionChain (org.opendaylight.mdsal.binding.api.TransactionChain)4 DOMTransactionChain (org.opendaylight.mdsal.dom.api.DOMTransactionChain)4 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)4 FluentFuture (com.google.common.util.concurrent.FluentFuture)3 FutureCallback (com.google.common.util.concurrent.FutureCallback)3 Collection (java.util.Collection)3 Stopwatch (com.google.common.base.Stopwatch)2 Futures (com.google.common.util.concurrent.Futures)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2