Class DataBrokerFailuresImpl
- java.lang.Object
-
- com.google.common.collect.ForwardingObject
-
- org.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker
-
- org.opendaylight.genius.datastoreutils.testutils.DataBrokerFailuresImpl
-
- All Implemented Interfaces:
org.opendaylight.controller.md.sal.binding.api.BindingService
,org.opendaylight.controller.md.sal.binding.api.DataBroker
,org.opendaylight.controller.md.sal.binding.api.DataTreeChangeService
,org.opendaylight.controller.md.sal.binding.api.TransactionFactory
,org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,org.opendaylight.yangtools.yang.binding.DataObject>
,org.opendaylight.controller.md.sal.common.api.data.AsyncDataTransactionFactory<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,org.opendaylight.yangtools.yang.binding.DataObject>
,org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,org.opendaylight.yangtools.yang.binding.DataObject>
,org.opendaylight.controller.sal.binding.api.BindingAwareService
,DataBrokerFailures
public class DataBrokerFailuresImpl extends org.opendaylight.controller.md.sal.binding.api.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.controller.md.sal.binding.api.DataBroker delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.opendaylight.controller.md.sal.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.controller.md.sal.common.api.data.ReadFailedException exception)
Fails N future reads.void
failReads(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException exception)
Fails all future reads.void
failSubmits(int howManyTimes, org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException exception)
Fails N future Transaction submits.void
failSubmits(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException exception)
Fails all future Transaction submits.<T extends org.opendaylight.yangtools.yang.binding.DataObject>
com.google.common.util.concurrent.CheckedFuture<com.google.common.base.Optional<T>,org.opendaylight.controller.md.sal.common.api.data.ReadFailedException>handleRead(java.util.function.BiFunction<org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType,org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T>,com.google.common.util.concurrent.CheckedFuture<com.google.common.base.Optional<T>,org.opendaylight.controller.md.sal.common.api.data.ReadFailedException>> readMethod, org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType store, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction
newReadWriteTransaction()
org.opendaylight.controller.md.sal.binding.api.WriteTransaction
newWriteOnlyTransaction()
void
unfailReads()
void
unfailSubmits()
-
-
-
Method Detail
-
delegate
protected org.opendaylight.controller.md.sal.binding.api.DataBroker delegate()
- Specified by:
delegate
in classorg.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker
-
failReads
public void failReads(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException exception)
Description copied from interface:DataBrokerFailures
Fails all future reads.- Specified by:
failReads
in interfaceDataBrokerFailures
- Parameters:
exception
- aReadFailedException
to throw from aReadTransaction.read(LogicalDatastoreType, InstanceIdentifier)
call.
-
failReads
public void failReads(int howManyTimes, org.opendaylight.controller.md.sal.common.api.data.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 aReadTransaction.read(LogicalDatastoreType, InstanceIdentifier)
call.
-
failSubmits
public void failSubmits(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException exception)
Description copied from interface:DataBrokerFailures
Fails all future Transaction submits.- Specified by:
failSubmits
in interfaceDataBrokerFailures
- Parameters:
exception
- an Exception to throw from aAsyncWriteTransaction.submit()
(alsoAsyncWriteTransaction.submit()
) method
-
failSubmits
public void failSubmits(int howManyTimes, org.opendaylight.controller.md.sal.common.api.data.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 aAsyncWriteTransaction.submit()
(alsoAsyncWriteTransaction.submit()
) 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.CheckedFuture<com.google.common.base.Optional<T>,org.opendaylight.controller.md.sal.common.api.data.ReadFailedException> handleRead(java.util.function.BiFunction<org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType,org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T>,com.google.common.util.concurrent.CheckedFuture<com.google.common.base.Optional<T>,org.opendaylight.controller.md.sal.common.api.data.ReadFailedException>> readMethod, org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType store, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
-
newReadWriteTransaction
public org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction newReadWriteTransaction()
- Specified by:
newReadWriteTransaction
in interfaceorg.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,org.opendaylight.yangtools.yang.binding.DataObject>
- Specified by:
newReadWriteTransaction
in interfaceorg.opendaylight.controller.md.sal.common.api.data.AsyncDataTransactionFactory<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,org.opendaylight.yangtools.yang.binding.DataObject>
- Specified by:
newReadWriteTransaction
in interfaceorg.opendaylight.controller.md.sal.binding.api.DataBroker
- Specified by:
newReadWriteTransaction
in interfaceorg.opendaylight.controller.md.sal.binding.api.TransactionFactory
- Overrides:
newReadWriteTransaction
in classorg.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker
-
newWriteOnlyTransaction
public org.opendaylight.controller.md.sal.binding.api.WriteTransaction newWriteOnlyTransaction()
- Specified by:
newWriteOnlyTransaction
in interfaceorg.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,org.opendaylight.yangtools.yang.binding.DataObject>
- Specified by:
newWriteOnlyTransaction
in interfaceorg.opendaylight.controller.md.sal.common.api.data.AsyncDataTransactionFactory<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,org.opendaylight.yangtools.yang.binding.DataObject>
- Specified by:
newWriteOnlyTransaction
in interfaceorg.opendaylight.controller.md.sal.binding.api.DataBroker
- Specified by:
newWriteOnlyTransaction
in interfaceorg.opendaylight.controller.md.sal.binding.api.TransactionFactory
- Overrides:
newWriteOnlyTransaction
in classorg.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker
-
-