Class SingleTransactionDataBroker


  • public class SingleTransactionDataBroker
    extends java.lang.Object
    Utility methods for single transaction DataBroker usage.

    Please consider using a ManagedNewTransactionRunner instead.

    Author:
    Michael Vorburger
    • Constructor Summary

      Constructors 
      Constructor Description
      SingleTransactionDataBroker​(@NonNull org.opendaylight.mdsal.binding.api.DataBroker broker)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncDelete​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncDelete​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, int maxRetries)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncDelete​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncDelete​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, int maxRetries)  
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      T
      syncRead​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      T
      syncRead​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
      Synchronously read; method variant to use by code which expecting that data MUST exist at given path.
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      java.util.Optional<T>
      syncReadOptional​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      java.util.Optional<T>
      syncReadOptional​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
      Synchronously read; preferred & strongly recommended method variant over other ones offered by this class (because this is the most explicit variant).
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      java.util.Optional<T>
      syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
      Deprecated.
      This variant is not recommended, and only exists for legacy purposes for code which does not yet correctly propagate technical exceptions.
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      java.util.Optional<T>
      syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
      Deprecated.
      This variant is not recommended, and only exists for legacy purposes for code which does not yet correctly propagate technical exceptions.
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncUpdate​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data)  
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncUpdate​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data, int maxRetries)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncUpdate​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncUpdate​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data, int maxRetries)  
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncWrite​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data)  
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncWrite​(org.opendaylight.mdsal.binding.api.DataBroker broker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data, int maxRetries)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncWrite​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncWrite​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data, int maxRetries)  
      • Methods inherited from class java.lang.Object

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

      • SingleTransactionDataBroker

        public SingleTransactionDataBroker​(@NonNull org.opendaylight.mdsal.binding.api.DataBroker broker)
    • Method Detail

      • syncReadOptional

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> java.util.Optional<T> syncReadOptional​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                                     org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                                              throws java.util.concurrent.ExecutionException,
                                                                                                                     java.lang.InterruptedException
        Synchronously read; preferred & strongly recommended method variant over other ones offered by this class (because this is the most explicit variant).

        See ReadOperations.read(LogicalDatastoreType, InstanceIdentifier).

        Type Parameters:
        T - DataObject subclass
        Parameters:
        datastoreType - Logical data store from which read should occur.
        path - Path which uniquely identifies subtree which client want to read
        Returns:
        If the data at the supplied path exists, returns an Optional object containing the data; if the data at the supplied path does not exist, returns Optional#absent().
        Throws:
        java.util.concurrent.ExecutionException - in case of a technical (!) error while reading
        java.lang.InterruptedException - in case of a technical (!) error while reading
      • syncReadOptional

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> java.util.Optional<T> syncReadOptional​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                                            org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                                            org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                                                     throws java.util.concurrent.ExecutionException,
                                                                                                                            java.lang.InterruptedException
        Throws:
        java.util.concurrent.ExecutionException
        java.lang.InterruptedException
      • syncRead

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> T syncRead​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                         org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                  throws org.opendaylight.mdsal.common.api.ReadFailedException
        Synchronously read; method variant to use by code which expecting that data MUST exist at given path.

        This variant is only recommended if the calling code would treat the Optional returned by the other method variant as a terminal failure anyway, and would itself throw an Exception for that.

        If calling code can more sensibly handle non-present data, then use syncReadOptional(LogicalDatastoreType, InstanceIdentifier) instead of this.

        See ReadOperations.read(LogicalDatastoreType, InstanceIdentifier).

        Type Parameters:
        T - DataObject subclass
        Parameters:
        datastoreType - Logical data store from which read should occur.
        path - Path which uniquely identifies subtree which client want to read
        Returns:
        If the data at the supplied path exists, returns the data.
        Throws:
        org.opendaylight.mdsal.common.api.ReadFailedException - in case of a technical (!) error while reading
        ExpectedDataObjectNotFoundException - a ReadFailedException sub-type, if no data exists at path
      • syncRead

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> T syncRead​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                         throws ExpectedDataObjectNotFoundException
        Throws:
        ExpectedDataObjectNotFoundException
      • syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional

        @Deprecated
        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> java.util.Optional<T> syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                                                                                org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
        Deprecated.
        This variant is not recommended, and only exists for legacy purposes for code which does not yet correctly propagate technical exceptions. Prefer using syncReadOptional(LogicalDatastoreType, InstanceIdentifier).
        Synchronously read; swallowing (!) ReadFailedException.

        See ReadOperations.read(LogicalDatastoreType, InstanceIdentifier).

        Type Parameters:
        T - DataObject subclass
        Parameters:
        datastoreType - Logical data store from which read should occur.
        path - Path which uniquely identifies subtree which client want to read
        Returns:
        If the data at the supplied path exists, returns an Optional object containing the data; if the data at the supplied path does not exist, or a technical error occurred (logged), returns Optional#absent().
      • syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional

        @Deprecated
        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> java.util.Optional<T> syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                                                                                       org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                                                                                       org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
        Deprecated.
        This variant is not recommended, and only exists for legacy purposes for code which does not yet correctly propagate technical exceptions. Prefer using syncReadOptional(DataBroker, LogicalDatastoreType, InstanceIdentifier).
        Synchronously read; swallowing (!) ReadFailedException.
        Type Parameters:
        T - DataObject subclass
        Parameters:
        broker - the broker
        datastoreType - the Datastore type that will be accessed
        path - Path which uniquely identifies subtree which client want to read
        Returns:
        If the data at the supplied path exists, returns the data.
      • syncWrite

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncWrite​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                             org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                             T data)
                                                                                      throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncWrite

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncWrite​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                             org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                             T data,
                                                                                             int maxRetries)
                                                                                      throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncWrite

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncWrite​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                    org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                    org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                                    T data)
                                                                                             throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncWrite

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncWrite​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                    org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                    org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                                    T data,
                                                                                                    int maxRetries)
                                                                                             throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncUpdate

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncUpdate​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                              org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                              T data)
                                                                                       throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncUpdate

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncUpdate​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                              org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                              T data,
                                                                                              int maxRetries)
                                                                                       throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncUpdate

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncUpdate​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                     org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                     org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                                     T data)
                                                                                              throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncUpdate

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncUpdate​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                     org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                     org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                                     T data,
                                                                                                     int maxRetries)
                                                                                              throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncDelete

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncDelete​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                              org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                       throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncDelete

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncDelete​(org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                              org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                              int maxRetries)
                                                                                       throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncDelete

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncDelete​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                     org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                     org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                              throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException
      • syncDelete

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> void syncDelete​(org.opendaylight.mdsal.binding.api.DataBroker broker,
                                                                                                     org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType,
                                                                                                     org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path,
                                                                                                     int maxRetries)
                                                                                              throws org.opendaylight.mdsal.common.api.TransactionCommitFailedException
        Throws:
        org.opendaylight.mdsal.common.api.TransactionCommitFailedException