Class MetadataDrivers


  • public final class MetadataDrivers
    extends java.lang.Object
    A driver manager for managing a set of metadata drivers.
    • Field Detail

      • ZK_CLIENT_DRIVER_CLASS

        static final java.lang.String ZK_CLIENT_DRIVER_CLASS
        See Also:
        Constant Field Values
      • ZK_BOOKIE_DRIVER_CLASS

        static final java.lang.String ZK_BOOKIE_DRIVER_CLASS
        See Also:
        Constant Field Values
      • BK_METADATA_CLIENT_DRIVERS_PROPERTY

        static final java.lang.String BK_METADATA_CLIENT_DRIVERS_PROPERTY
        See Also:
        Constant Field Values
      • BK_METADATA_BOOKIE_DRIVERS_PROPERTY

        static final java.lang.String BK_METADATA_BOOKIE_DRIVERS_PROPERTY
        See Also:
        Constant Field Values
    • Method Detail

      • loadInitialDrivers

        static void loadInitialDrivers()
      • registerClientDriver

        public static void registerClientDriver​(java.lang.String metadataBackendScheme,
                                                java.lang.Class<? extends MetadataClientDriver> driver)
        Register the metadata client driver.
        Parameters:
        metadataBackendScheme - scheme of metadata backend.
        driver - metadata client driver
      • registerClientDriver

        public static void registerClientDriver​(java.lang.String metadataBackendScheme,
                                                java.lang.Class<? extends MetadataClientDriver> driver,
                                                boolean allowOverride)
      • registerBookieDriver

        public static void registerBookieDriver​(java.lang.String metadataBackendScheme,
                                                java.lang.Class<? extends MetadataBookieDriver> driver)
        Register the metadata bookie driver.
        Parameters:
        metadataBackendScheme - scheme of metadata backend.
        driver - metadata bookie driver
      • registerBookieDriver

        public static void registerBookieDriver​(java.lang.String metadataBackendScheme,
                                                java.lang.Class<? extends MetadataBookieDriver> driver,
                                                boolean allowOverride)
      • getClientDriver

        public static MetadataClientDriver getClientDriver​(java.lang.String scheme)
        Retrieve the client driver for scheme.
        Parameters:
        scheme - the scheme for the metadata client driver
        Returns:
        the metadata client driver
        Throws:
        java.lang.NullPointerException - when scheme is null
      • getClientDriver

        public static MetadataClientDriver getClientDriver​(java.net.URI uri)
        Retrieve the client driver for uri.
        Parameters:
        uri - the metadata service uri
        Returns:
        the metadata client driver for uri
        Throws:
        java.lang.NullPointerException - if the metadata service uri is null or doesn't have scheme or there is no namespace driver registered for the scheme
        java.lang.IllegalArgumentException - if the metadata service uri scheme is illegal
      • getBookieDriver

        public static MetadataBookieDriver getBookieDriver​(java.lang.String scheme)
        Retrieve the bookie driver for scheme.
        Parameters:
        scheme - the scheme for the metadata bookie driver
        Returns:
        the metadata bookie driver
        Throws:
        java.lang.NullPointerException - when scheme is null
      • getBookieDriver

        public static MetadataBookieDriver getBookieDriver​(java.net.URI uri)
        Retrieve the bookie driver for uri.
        Parameters:
        uri - the metadata service uri
        Returns:
        the metadata bookie driver for uri
        Throws:
        java.lang.NullPointerException - if the metadata service uri is null or doesn't have scheme or there is no namespace driver registered for the scheme
        java.lang.IllegalArgumentException - if the metadata service uri scheme is illegal
      • runFunctionWithMetadataClientDriver

        public static <T> T runFunctionWithMetadataClientDriver​(ClientConfiguration conf,
                                                                java.util.function.Function<MetadataClientDriver,​T> function,
                                                                java.util.concurrent.ScheduledExecutorService executorService)
                                                         throws MetadataException,
                                                                java.util.concurrent.ExecutionException
        Process the provided function with metadata client driver resolved from the metadata service uri returned by AbstractConfiguration.getMetadataServiceUri().
        Parameters:
        conf - client configuration
        function - function to apply with metadata client driver.
        executorService - executor service used by the metadata client driver.
        Throws:
        MetadataException - when failed to access metadata store
        java.util.concurrent.ExecutionException - exception thrown when processing function.
      • runFunctionWithMetadataBookieDriver

        public static <T> T runFunctionWithMetadataBookieDriver​(ServerConfiguration conf,
                                                                java.util.function.Function<MetadataBookieDriver,​T> function)
                                                         throws MetadataException,
                                                                java.util.concurrent.ExecutionException
        Process the provided function with metadata bookie driver resolved from the metadata service uri returned by AbstractConfiguration.getMetadataServiceUri().
        Parameters:
        conf - server configuration
        function - function to apply with metadata bookie driver.
        Throws:
        MetadataException - when failed to access metadata store
        java.util.concurrent.ExecutionException - exception thrown when processing function.
      • runFunctionWithRegistrationManager

        public static <T> T runFunctionWithRegistrationManager​(ServerConfiguration conf,
                                                               java.util.function.Function<RegistrationManager,​T> function)
                                                        throws MetadataException,
                                                               java.util.concurrent.ExecutionException
        Process the provided function with registration manager resolved from the metadata service uri returned by AbstractConfiguration.getMetadataServiceUri().
        Parameters:
        conf - server configuration
        function - function to apply with registration manager.
        Throws:
        MetadataException - when failed to access metadata store
        java.util.concurrent.ExecutionException - exception thrown when processing consumer.
      • runFunctionWithLedgerManagerFactory

        public static <T> T runFunctionWithLedgerManagerFactory​(ServerConfiguration conf,
                                                                java.util.function.Function<LedgerManagerFactory,​T> function)
                                                         throws MetadataException,
                                                                java.util.concurrent.ExecutionException
        Process the provided function with ledger manager factory resolved from the metadata service uri returned by AbstractConfiguration.getMetadataServiceUri().
        Parameters:
        conf - server configuration
        function - function to apply with ledger manager factory.
        Throws:
        MetadataException - when failed to access metadata store
        java.util.concurrent.ExecutionException - exception thrown when processing consumer.