public class DataBrokerFailuresImpl extends ForwardingDataBroker implements DataBrokerFailures
Constructor and Description |
---|
DataBrokerFailuresImpl(DataBroker delegate) |
Modifier and Type | Method and Description |
---|---|
protected DataBroker |
delegate() |
void |
failButCommitAnyway()
To simulate scenarios where even though the transaction throws a
TransactionCommitFailedException (caused by
akka.pattern.AskTimeoutException) it eventually succeeds.
|
void |
failCommits(int howManyTimes,
TransactionCommitFailedException exception)
Fails N future Transaction commits.
|
void |
failCommits(TransactionCommitFailedException exception)
Fails all future Transaction commits.
|
void |
failReads(int howManyTimes,
ReadFailedException exception)
Fails N future reads.
|
void |
failReads(ReadFailedException exception)
Fails all future reads.
|
<T extends DataObject> |
handleRead(BiFunction<LogicalDatastoreType,InstanceIdentifier<T>,com.google.common.util.concurrent.FluentFuture<Optional<T>>> readMethod,
LogicalDatastoreType store,
InstanceIdentifier<T> path) |
ReadWriteTransaction |
newReadWriteTransaction()
Allocates new read-write transaction which provides a mutable view of the data tree.
|
WriteTransaction |
newWriteOnlyTransaction()
Allocates new write-only transaction based on latest state of data tree.
|
void |
unfailCommits()
|
void |
unfailReads()
|
createTransactionChain, newReadOnlyTransaction, registerDataTreeChangeListener
public DataBrokerFailuresImpl(DataBroker delegate)
protected DataBroker delegate()
delegate
in class ForwardingDataBroker
public void failReads(ReadFailedException exception)
DataBrokerFailures
failReads
in interface DataBrokerFailures
exception
- a ReadFailedException
to throw from a
ReadOperations.read(LogicalDatastoreType, InstanceIdentifier)
call.public void failReads(int howManyTimes, ReadFailedException exception)
DataBrokerFailures
failReads
in interface DataBrokerFailures
howManyTimes
- how many times to throw the passed exception, until it resets.exception
- a ReadFailedException
to throw from a
ReadOperations.read(LogicalDatastoreType, InstanceIdentifier)
call.public void failCommits(TransactionCommitFailedException exception)
DataBrokerFailures
failCommits
in interface DataBrokerFailures
exception
- an Exception to throw from a WriteTransaction.commit()
method.public void failCommits(int howManyTimes, TransactionCommitFailedException exception)
DataBrokerFailures
failCommits
in interface DataBrokerFailures
howManyTimes
- how many times to throw the passed exception, until it resetsexception
- an Exception to throw from a WriteTransaction.commit()
method.public void unfailReads()
DataBrokerFailures
DataBrokerFailures.failReads(ReadFailedException)
or DataBrokerFailures.failReads(int, ReadFailedException)
.unfailReads
in interface DataBrokerFailures
public void unfailCommits()
DataBrokerFailures
DataBrokerFailures.failCommits(TransactionCommitFailedException)
or
DataBrokerFailures.failCommits(int, TransactionCommitFailedException)
.unfailCommits
in interface DataBrokerFailures
public void failButCommitAnyway()
DataBrokerFailures
failButCommitAnyway
in interface DataBrokerFailures
public <T extends DataObject> com.google.common.util.concurrent.FluentFuture<Optional<T>> handleRead(BiFunction<LogicalDatastoreType,InstanceIdentifier<T>,com.google.common.util.concurrent.FluentFuture<Optional<T>>> readMethod, LogicalDatastoreType store, InstanceIdentifier<T> path)
public ReadWriteTransaction newReadWriteTransaction()
TransactionFactory
Preconditions for mutation of data tree are captured from the snapshot of data tree state, when the transaction
is allocated. If data was changed during transaction in an incompatible way then the commit of this transaction
will fail. See WriteTransaction.commit()
for more details about conflicting and non-conflicting
changes and failure scenarios.
newReadWriteTransaction
in interface TransactionFactory
newReadWriteTransaction
in class ForwardingDataBroker
public WriteTransaction newWriteOnlyTransaction()
TransactionFactory
Preconditions for mutation of data tree are captured from the snapshot of data tree state, when the transaction
is allocated. If data was changed during transaction in an incompatible way then the commit of this transaction
will fail. See WriteTransaction.commit()
for more details about conflicting and not-conflicting changes
and failure scenarios.
Since this transaction does not provide a view of the data it SHOULD BE used only by callers who are exclusive
writers (exporters of data) to the subtree they modify. This prevents optimistic lock failures as described in
WriteTransaction.commit()
.
Exclusivity of writers to particular subtree SHOULD BE enforced by external locking mechanism.
newWriteOnlyTransaction
in interface TransactionFactory
newWriteOnlyTransaction
in class ForwardingDataBroker
Copyright © 2019 OpenDaylight. All rights reserved.