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.controller.md.sal.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.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      static <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncDelete​(org.opendaylight.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, int maxRetries)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncDelete​(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncDelete​(org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      T
      syncRead​(org.opendaylight.controller.md.sal.common.api.data.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>
      com.google.common.base.Optional<T>
      syncReadOptional​(org.opendaylight.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      com.google.common.base.Optional<T>
      syncReadOptional​(org.opendaylight.controller.md.sal.common.api.data.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>
      com.google.common.base.Optional<T>
      syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.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>
      com.google.common.base.Optional<T>
      syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncUpdate​(org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.binding.api.DataBroker broker, org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path, T data)  
      <T extends org.opendaylight.yangtools.yang.binding.DataObject>
      void
      syncWrite​(org.opendaylight.controller.md.sal.common.api.data.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.controller.md.sal.binding.api.DataBroker broker)
    • Method Detail

      • syncReadOptional

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> com.google.common.base.Optional<T> syncReadOptional​(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType,
                                                                                                                                  org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                                                           throws org.opendaylight.controller.md.sal.common.api.data.ReadFailedException
        Synchronously read; preferred & strongly recommended method variant over other ones offered by this class (because this is the most explicit variant).

        See ReadTransaction.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:
        org.opendaylight.controller.md.sal.common.api.data.ReadFailedException - in case of a technical (!) error while reading
      • syncReadOptional

        public static <T extends org.opendaylight.yangtools.yang.binding.DataObject> com.google.common.base.Optional<T> syncReadOptional​(org.opendaylight.controller.md.sal.binding.api.DataBroker broker,
                                                                                                                                         org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType,
                                                                                                                                         org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                                                                  throws org.opendaylight.controller.md.sal.common.api.data.ReadFailedException
        Throws:
        org.opendaylight.controller.md.sal.common.api.data.ReadFailedException
      • syncRead

        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> T syncRead​(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType,
                                                                                         org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                  throws org.opendaylight.controller.md.sal.common.api.data.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 ReadTransaction.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.controller.md.sal.common.api.data.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.controller.md.sal.binding.api.DataBroker broker,
                                                                                                org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType datastoreType,
                                                                                                org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> path)
                                                                                         throws org.opendaylight.controller.md.sal.common.api.data.ReadFailedException
        Throws:
        org.opendaylight.controller.md.sal.common.api.data.ReadFailedException
      • syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional

        @Deprecated
        public <T extends org.opendaylight.yangtools.yang.binding.DataObject> com.google.common.base.Optional<T> syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.controller.md.sal.common.api.data.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 ReadTransaction.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> com.google.common.base.Optional<T> syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional​(org.opendaylight.controller.md.sal.binding.api.DataBroker broker,
                                                                                                                                                                                    org.opendaylight.controller.md.sal.common.api.data.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.
      • syncWrite

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

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

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

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

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

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

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

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

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

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

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

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