Class DataBrokerFailuresImpl
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- org.opendaylight.mdsal.binding.spi.ForwardingDataBroker
-
- org.opendaylight.genius.datastoreutils.testutils.DataBrokerFailuresImpl
-
- All Implemented Interfaces:
DataBrokerFailures
,org.opendaylight.mdsal.binding.api.BindingService
,org.opendaylight.mdsal.binding.api.DataBroker
,org.opendaylight.mdsal.binding.api.DataTreeChangeService
,org.opendaylight.mdsal.binding.api.TransactionFactory
public class DataBrokerFailuresImpl extends org.opendaylight.mdsal.binding.spi.ForwardingDataBroker implements DataBrokerFailures
DataBroker with methods to simulate failures, useful for tests.If you use this from a Guice-based component test, consider just binding it via the
DataBrokerFailuresModule
.- Author:
- Michael Vorburger.ch
-
-
Constructor Summary
Constructors Constructor Description DataBrokerFailuresImpl(org.opendaylight.mdsal.binding.api.DataBroker delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.opendaylight.mdsal.binding.api.DataBroker
delegate()
void
failButSubmitsAnyways()
To simulate scenarios where even though the transaction throws a TransactionCommitFailedException (caused by akka.pattern.AskTimeoutException) it eventually succeeds.void
failReads(int howManyTimes, org.opendaylight.mdsal.common.api.ReadFailedException exception)
Fails N future reads.void
failReads(org.opendaylight.mdsal.common.api.ReadFailedException exception)
Fails all future reads.void
failSubmits(int howManyTimes, org.opendaylight.mdsal.common.api.TransactionCommitFailedException exception)
Fails N future Transaction submits.void
failSubmits(org.opendaylight.mdsal.common.api.TransactionCommitFailedException exception)
Fails all future Transaction submits.<T extends org.opendaylight.yangtools.yang.binding.DataObject>
com.google.common.util.concurrent.FluentFuture<java.util.Optional<T>>handleRead(java.util.function.BiFunction<org.opendaylight.mdsal.common.api.LogicalDatastoreType,org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T>,com.google.common.util.concurrent.FluentFuture<java.util.Optional<T>>> readMethod, org.opendaylight.mdsal.common.api.LogicalDatastoreType store, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
org.opendaylight.mdsal.binding.api.ReadWriteTransaction
newReadWriteTransaction()
org.opendaylight.mdsal.binding.api.WriteTransaction
newWriteOnlyTransaction()
void
unfailReads()
void
unfailSubmits()
-
-
-
Method Detail
-
delegate
protected org.opendaylight.mdsal.binding.api.DataBroker delegate()
- Specified by:
delegate
in classorg.opendaylight.mdsal.binding.spi.ForwardingDataBroker
-
failReads
public void failReads(org.opendaylight.mdsal.common.api.ReadFailedException exception)
Description copied from interface:DataBrokerFailures
Fails all future reads.- Specified by:
failReads
in interfaceDataBrokerFailures
- Parameters:
exception
- aReadFailedException
to throw from aReadOperations.read(LogicalDatastoreType, InstanceIdentifier)
call.
-
failReads
public void failReads(int howManyTimes, org.opendaylight.mdsal.common.api.ReadFailedException exception)
Description copied from interface:DataBrokerFailures
Fails N future reads.- Specified by:
failReads
in interfaceDataBrokerFailures
- Parameters:
howManyTimes
- how many times to throw the passed exception, until it resets.exception
- aReadFailedException
to throw from aReadOperations.read(LogicalDatastoreType, InstanceIdentifier)
call.
-
failSubmits
public void failSubmits(org.opendaylight.mdsal.common.api.TransactionCommitFailedException exception)
Description copied from interface:DataBrokerFailures
Fails all future Transaction submits.- Specified by:
failSubmits
in interfaceDataBrokerFailures
- Parameters:
exception
- an Exception to throw from aWriteTransaction.commit()
(alsoWriteTransaction.commit()
) method
-
failSubmits
public void failSubmits(int howManyTimes, org.opendaylight.mdsal.common.api.TransactionCommitFailedException exception)
Description copied from interface:DataBrokerFailures
Fails N future Transaction submits.- Specified by:
failSubmits
in interfaceDataBrokerFailures
- Parameters:
howManyTimes
- how many times to throw the passed exception, until it resetsexception
- an Exception to throw from aWriteTransaction.commit()
(alsoWriteTransaction.commit()
method
-
unfailReads
public void unfailReads()
Description copied from interface:DataBrokerFailures
Resets any earlierDataBrokerFailures.failReads(ReadFailedException)
orDataBrokerFailures.failReads(int, ReadFailedException)
.- Specified by:
unfailReads
in interfaceDataBrokerFailures
-
unfailSubmits
public void unfailSubmits()
Description copied from interface:DataBrokerFailures
Resets any earlierDataBrokerFailures.failSubmits(TransactionCommitFailedException)
orDataBrokerFailures.failSubmits(int, TransactionCommitFailedException)
.- Specified by:
unfailSubmits
in interfaceDataBrokerFailures
-
failButSubmitsAnyways
public void failButSubmitsAnyways()
Description copied from interface:DataBrokerFailures
To simulate scenarios where even though the transaction throws a TransactionCommitFailedException (caused by akka.pattern.AskTimeoutException) it eventually succeeds. These timeouts are typically seen in scaled cluster environments under load. The new tell-based protocol, which will soon be enabled by default (c/61002), adds internal retries for transactions, making the application not to handle such scenarios.- Specified by:
failButSubmitsAnyways
in interfaceDataBrokerFailures
-
handleRead
public <T extends org.opendaylight.yangtools.yang.binding.DataObject> com.google.common.util.concurrent.FluentFuture<java.util.Optional<T>> handleRead(java.util.function.BiFunction<org.opendaylight.mdsal.common.api.LogicalDatastoreType,org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T>,com.google.common.util.concurrent.FluentFuture<java.util.Optional<T>>> readMethod, org.opendaylight.mdsal.common.api.LogicalDatastoreType store, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
-
newReadWriteTransaction
public org.opendaylight.mdsal.binding.api.ReadWriteTransaction newReadWriteTransaction()
- Specified by:
newReadWriteTransaction
in interfaceorg.opendaylight.mdsal.binding.api.TransactionFactory
- Overrides:
newReadWriteTransaction
in classorg.opendaylight.mdsal.binding.spi.ForwardingDataBroker
-
newWriteOnlyTransaction
public org.opendaylight.mdsal.binding.api.WriteTransaction newWriteOnlyTransaction()
- Specified by:
newWriteOnlyTransaction
in interfaceorg.opendaylight.mdsal.binding.api.TransactionFactory
- Overrides:
newWriteOnlyTransaction
in classorg.opendaylight.mdsal.binding.spi.ForwardingDataBroker
-
-