Class 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()
      • Methods inherited from class org.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker

        createTransactionChain, newReadOnlyTransaction, registerDataTreeChangeListener
      • Methods inherited from class com.google.common.collect.ForwardingObject

        toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DataBrokerFailuresImpl

        public DataBrokerFailuresImpl​(org.opendaylight.controller.md.sal.binding.api.DataBroker delegate)
    • Method Detail

      • delegate

        protected org.opendaylight.controller.md.sal.binding.api.DataBroker delegate()
        Specified by:
        delegate in class org.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 interface DataBrokerFailures
        Parameters:
        exception - a ReadFailedException to throw from a ReadTransaction.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 interface DataBrokerFailures
        Parameters:
        howManyTimes - how many times to throw the passed exception, until it resets.
        exception - a ReadFailedException to throw from a ReadTransaction.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 interface DataBrokerFailures
        Parameters:
        exception - an Exception to throw from a AsyncWriteTransaction.submit() (also AsyncWriteTransaction.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 interface DataBrokerFailures
        Parameters:
        howManyTimes - how many times to throw the passed exception, until it resets
        exception - an Exception to throw from a AsyncWriteTransaction.submit() (also AsyncWriteTransaction.submit()) method
      • 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 interface DataBrokerFailures
      • 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 interface org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,​org.opendaylight.yangtools.yang.binding.DataObject>
        Specified by:
        newReadWriteTransaction in interface org.opendaylight.controller.md.sal.common.api.data.AsyncDataTransactionFactory<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,​org.opendaylight.yangtools.yang.binding.DataObject>
        Specified by:
        newReadWriteTransaction in interface org.opendaylight.controller.md.sal.binding.api.DataBroker
        Specified by:
        newReadWriteTransaction in interface org.opendaylight.controller.md.sal.binding.api.TransactionFactory
        Overrides:
        newReadWriteTransaction in class org.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker
      • newWriteOnlyTransaction

        public org.opendaylight.controller.md.sal.binding.api.WriteTransaction newWriteOnlyTransaction()
        Specified by:
        newWriteOnlyTransaction in interface org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,​org.opendaylight.yangtools.yang.binding.DataObject>
        Specified by:
        newWriteOnlyTransaction in interface org.opendaylight.controller.md.sal.common.api.data.AsyncDataTransactionFactory<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>,​org.opendaylight.yangtools.yang.binding.DataObject>
        Specified by:
        newWriteOnlyTransaction in interface org.opendaylight.controller.md.sal.binding.api.DataBroker
        Specified by:
        newWriteOnlyTransaction in interface org.opendaylight.controller.md.sal.binding.api.TransactionFactory
        Overrides:
        newWriteOnlyTransaction in class org.opendaylight.controller.md.sal.binding.api.ForwardingDataBroker