Search in sources :

Example 26 with LogicalDatastoreType

use of org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType in project genius by opendaylight.

the class SingleTransactionDataBroker method syncDelete.

public static <T extends DataObject> void syncDelete(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, int maxRetries) throws TransactionCommitFailedException {
    RetryingManagedNewTransactionRunner runner = new RetryingManagedNewTransactionRunner(broker, maxRetries);
    ListenableFutures.checkedGet(runner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.delete(datastoreType, path)), SUBMIT_MAPPER);
}
Also used : Logger(org.slf4j.Logger) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) LoggerFactory(org.slf4j.LoggerFactory) ReadTransaction(org.opendaylight.controller.md.sal.binding.api.ReadTransaction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) RetryingManagedNewTransactionRunner(org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Optional(com.google.common.base.Optional) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Objects.requireNonNull(java.util.Objects.requireNonNull) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Nonnull(javax.annotation.Nonnull) SUBMIT_MAPPER(org.opendaylight.genius.datastoreutils.TransactionCommitFailedExceptionMapper.SUBMIT_MAPPER) RetryingManagedNewTransactionRunner(org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner)

Example 27 with LogicalDatastoreType

use of org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType in project genius by opendaylight.

the class SingleTransactionDataBroker method syncWrite.

public static <T extends DataObject> void syncWrite(DataBroker broker, LogicalDatastoreType datastoreType, InstanceIdentifier<T> path, T data, int maxRetries) throws TransactionCommitFailedException {
    RetryingManagedNewTransactionRunner runner = new RetryingManagedNewTransactionRunner(broker, maxRetries);
    ListenableFutures.checkedGet(runner.callWithNewWriteOnlyTransactionAndSubmit(tx -> tx.put(datastoreType, path, data, true)), SUBMIT_MAPPER);
}
Also used : Logger(org.slf4j.Logger) LogicalDatastoreType(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType) LoggerFactory(org.slf4j.LoggerFactory) ReadTransaction(org.opendaylight.controller.md.sal.binding.api.ReadTransaction) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) RetryingManagedNewTransactionRunner(org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner) DataBroker(org.opendaylight.controller.md.sal.binding.api.DataBroker) ListenableFutures(org.opendaylight.infrautils.utils.concurrent.ListenableFutures) ReadOnlyTransaction(org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) Optional(com.google.common.base.Optional) ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) Objects.requireNonNull(java.util.Objects.requireNonNull) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) Nonnull(javax.annotation.Nonnull) SUBMIT_MAPPER(org.opendaylight.genius.datastoreutils.TransactionCommitFailedExceptionMapper.SUBMIT_MAPPER) RetryingManagedNewTransactionRunner(org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner)

Aggregations

LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)27 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)12 Optional (com.google.common.base.Optional)11 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)11 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)8 DOMStore (org.opendaylight.controller.sal.core.spi.data.DOMStore)7 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)6 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)6 TestExec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec)6 OuterList (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.test.exec.OuterList)6 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)6 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 InMemoryDOMDataStore (org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore)5 Nonnull (javax.annotation.Nonnull)4 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 QName (org.opendaylight.yangtools.yang.common.QName)4 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3