Search in sources :

Example 1 with SUBMIT_MAPPER

use of org.opendaylight.genius.datastoreutils.TransactionCommitFailedExceptionMapper.SUBMIT_MAPPER in project genius by opendaylight.

the class SingleTransactionDataBroker method syncUpdate.

public static <T extends DataObject> void syncUpdate(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.merge(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)

Example 2 with SUBMIT_MAPPER

use of org.opendaylight.genius.datastoreutils.TransactionCommitFailedExceptionMapper.SUBMIT_MAPPER 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 3 with SUBMIT_MAPPER

use of org.opendaylight.genius.datastoreutils.TransactionCommitFailedExceptionMapper.SUBMIT_MAPPER 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

Optional (com.google.common.base.Optional)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 Nonnull (javax.annotation.Nonnull)3 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)3 ReadOnlyTransaction (org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction)3 ReadTransaction (org.opendaylight.controller.md.sal.binding.api.ReadTransaction)3 LogicalDatastoreType (org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType)3 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)3 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)3 SUBMIT_MAPPER (org.opendaylight.genius.datastoreutils.TransactionCommitFailedExceptionMapper.SUBMIT_MAPPER)3 RetryingManagedNewTransactionRunner (org.opendaylight.genius.infra.RetryingManagedNewTransactionRunner)3 ListenableFutures (org.opendaylight.infrautils.utils.concurrent.ListenableFutures)3 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)3 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3