Class AbstractConfiguration<T extends AbstractConfiguration>

java.lang.Object
org.apache.commons.configuration2.event.BaseEventSource
org.apache.commons.configuration2.AbstractConfiguration
org.apache.commons.configuration2.CompositeConfiguration
org.apache.bookkeeper.conf.AbstractConfiguration<T>
All Implemented Interfaces:
Cloneable, org.apache.commons.configuration2.Configuration, org.apache.commons.configuration2.event.EventSource, org.apache.commons.configuration2.ImmutableConfiguration, org.apache.commons.configuration2.sync.SynchronizerSupport
Direct Known Subclasses:
ClientConfiguration, ServerConfiguration

public abstract class AbstractConfiguration<T extends AbstractConfiguration> extends org.apache.commons.configuration2.CompositeConfiguration
Abstract configuration.
  • Field Details

  • Constructor Details

    • AbstractConfiguration

      protected AbstractConfiguration()
  • Method Details

    • setPermittedStartupUsers

      public void setPermittedStartupUsers(String s)
      Limit who can start the application to prevent future permission errors.
    • getPermittedStartupUsers

      public String[] getPermittedStartupUsers()
      Get array of users specified in this property.
    • loadConf

      public void loadConf(URL confURL) throws org.apache.commons.configuration2.ex.ConfigurationException
      You can load configurations in precedence order. The first one takes precedence over any loaded later.
      Parameters:
      confURL - Configuration URL
      Throws:
      org.apache.commons.configuration2.ex.ConfigurationException
    • loadConf

      public void loadConf(org.apache.commons.configuration2.CompositeConfiguration baseConf)
      You can load configuration from other configuration.
      Parameters:
      baseConf - Other Configuration
    • getMetadataServiceUriUnchecked

      public String getMetadataServiceUriUnchecked() throws UncheckedConfigurationException
      Get metadata service uri.

      Warning: this method silently converts checked exceptions to unchecked exceptions. It is useful to use this method in lambda expressions. However it should not be used with places which have logics to handle checked exceptions. In such cases use getMetadataServiceUri() instead.

      Returns:
      metadata service uri
      Throws:
      UncheckedConfigurationException - if the metadata service uri is invalid.
    • getMetadataServiceUri

      public String getMetadataServiceUri() throws org.apache.commons.configuration2.ex.ConfigurationException
      Get metadata service uri.
      Returns:
      metadata service uri.
      Throws:
      org.apache.commons.configuration2.ex.ConfigurationException - if the metadata service uri is invalid.
    • setMetadataServiceUri

      public T setMetadataServiceUri(String serviceUri)
      Set the metadata service uri.
      Parameters:
      serviceUri - the metadata service uri.
      Returns:
      the configuration object.
    • getZkServers

      @Deprecated public String getZkServers()
      Deprecated.
      since 4.7.0
      Get zookeeper servers to connect.

      `zkServers` is deprecating, in favor of using `metadataServiceUri`

      Returns:
      zookeeper servers
    • setZkServers

      @Deprecated public T setZkServers(String zkServers)
      Deprecated.
      Set zookeeper servers to connect.

      `zkServers` is deprecating, in favor of using `metadataServiceUri`

      Parameters:
      zkServers - ZooKeeper servers to connect
    • getZkTimeout

      public int getZkTimeout()
      Get zookeeper timeout.
      Returns:
      zookeeper server timeout
    • setZkTimeout

      public T setZkTimeout(int zkTimeout)
      Set zookeeper timeout.
      Parameters:
      zkTimeout - ZooKeeper server timeout
      Returns:
      server configuration
    • getZkRetryBackoffMaxRetries

      public int getZkRetryBackoffMaxRetries()
      Get zookeeper client backoff max retry times.
      Returns:
      zk backoff max retry times.
    • setZkRetryBackoffMaxRetries

      public T setZkRetryBackoffMaxRetries(int maxRetries)
      Set zookeeper client backoff max retry times.
      Parameters:
      maxRetries - backoff max retry times
      Returns:
      server configuration.
    • setLedgerManagerType

      @Deprecated public void setLedgerManagerType(String lmType)
      Set Ledger Manager Type.
      Parameters:
      lmType - Ledger Manager Type
    • getLedgerManagerType

      @Deprecated public String getLedgerManagerType()
      Deprecated.
      Get Ledger Manager Type.
      Returns:
      ledger manager type
    • setAllowShadedLedgerManagerFactoryClass

      public T setAllowShadedLedgerManagerFactoryClass(boolean allowed)
      Set the flag to allow using shaded ledger manager factory class for instantiating a ledger manager factory.
      Parameters:
      allowed - the flag to allow/disallow using shaded ledger manager factory class
      Returns:
      configuration instance.
    • isShadedLedgerManagerFactoryClassAllowed

      public boolean isShadedLedgerManagerFactoryClassAllowed()
      Is shaded ledger manager factory class name allowed to be used for instantiating ledger manager factory.
      Returns:
      ledger manager factory class name.
    • setShadedLedgerManagerFactoryClassPrefix

      public T setShadedLedgerManagerFactoryClassPrefix(String classPrefix)
      Set the class prefix of the shaded ledger manager factory class for instantiating a ledger manager factory.

      This setting only takes effects when isShadedLedgerManagerFactoryClassAllowed() returns true.

      Parameters:
      classPrefix - the class prefix of shaded ledger manager factory class
      Returns:
      configuration instance.
    • getShadedLedgerManagerFactoryClassPrefix

      public String getShadedLedgerManagerFactoryClassPrefix()
      Get the class prefix of the shaded ledger manager factory class name allowed to be used for instantiating ledger manager factory.

      This setting only takes effects when isShadedLedgerManagerFactoryClassAllowed() returns true

      Returns:
      ledger manager factory class name.
      See Also:
    • setLedgerManagerFactoryClassName

      public void setLedgerManagerFactoryClassName(String factoryClassName)
      Set Ledger Manager Factory Class Name.
      Parameters:
      factoryClassName - Ledger Manager Factory Class Name
    • getLedgerManagerFactoryClassName

      public String getLedgerManagerFactoryClassName()
      Get Ledger Manager Factory Class Name.
      Returns:
      ledger manager factory class name.
    • setLedgerMetadataFormatVersion

      public void setLedgerMetadataFormatVersion(int metadataFormatVersion)
      Set Ledger metadata format version.
      Parameters:
      metadataFormatVersion - Ledger metadata format version. pass -1 to use default version
    • getLedgerMetadataFormatVersion

      public int getLedgerMetadataFormatVersion()
      Get Ledger metadata format version.
      Returns:
      ledger metadata format version.
    • getLedgerManagerLayoutStringFromFactoryClass

      public String getLedgerManagerLayoutStringFromFactoryClass() throws org.apache.commons.configuration2.ex.ConfigurationException
      Get layout string ("null" if unconfigured).
      Returns:
      null, hierarchical, longhierarchical, or flat based on LEDGER_MANAGER_FACTORY_CLASS
      Throws:
      org.apache.commons.configuration2.ex.ConfigurationException
    • setLedgerManagerFactoryClass

      public void setLedgerManagerFactoryClass(Class<? extends LedgerManagerFactory> factoryClass)
      Set Ledger Manager Factory Class.
      Parameters:
      factoryClass - Ledger Manager Factory Class
    • getLedgerManagerFactoryClass

      public Class<? extends LedgerManagerFactory> getLedgerManagerFactoryClass() throws org.apache.commons.configuration2.ex.ConfigurationException
      Get ledger manager factory class.
      Returns:
      ledger manager factory class
      Throws:
      org.apache.commons.configuration2.ex.ConfigurationException
    • setZkLedgersRootPath

      @Deprecated public void setZkLedgersRootPath(String zkLedgersPath)
      Deprecated.
      Set Zk Ledgers Root Path.
      Parameters:
      zkLedgersPath - zk ledgers root path
    • getZkLedgersRootPath

      @Deprecated public String getZkLedgersRootPath()
      Deprecated.
      Get Zk Ledgers Root Path.
      Returns:
      zk ledgers root path
    • getZkRequestRateLimit

      public double getZkRequestRateLimit()
      Get zookeeper access request rate limit.
      Returns:
      zookeeper access request rate limit.
    • setZkRequestRateLimit

      public void setZkRequestRateLimit(double rateLimit)
      Set zookeeper access request rate limit.
      Parameters:
      rateLimit - zookeeper access request rate limit.
    • isZkEnableSecurity

      public boolean isZkEnableSecurity()
      Are z-node created with strict ACLs.
      Returns:
      usage of secure ZooKeeper ACLs
    • setZkEnableSecurity

      public void setZkEnableSecurity(boolean zkEnableSecurity)
      Set the usage of ACLs of new z-nodes.
      Parameters:
      zkEnableSecurity -
    • getZkAvailableBookiesPath

      @Deprecated public String getZkAvailableBookiesPath()
      Deprecated.
      Get the node under which available bookies are stored.
      Returns:
      Node under which available bookies are stored.
    • setRereplicationEntryBatchSize

      public void setRereplicationEntryBatchSize(long rereplicationEntryBatchSize)
      Set the max entries to keep in fragment for re-replication. If fragment has more entries than this count, then the original fragment will be split into multiple small logical fragments by keeping max entries count to rereplicationEntryBatchSize. So, re-replication will happen in batches wise.
    • getRereplicationEntryBatchSize

      public long getRereplicationEntryBatchSize()
      Get the re-replication entry batch size.
    • getMetastoreImplClass

      public String getMetastoreImplClass()
      Get metastore implementation class.
      Returns:
      metastore implementation class name.
    • setMetastoreImplClass

      public void setMetastoreImplClass(String metastoreImplClass)
      Set metastore implementation class.
      Parameters:
      metastoreImplClass - Metastore implementation Class name.
    • getMetastoreMaxEntriesPerScan

      public int getMetastoreMaxEntriesPerScan()
      Get max entries per scan in metastore.
      Returns:
      max entries per scan in metastore.
    • setMetastoreMaxEntriesPerScan

      public void setMetastoreMaxEntriesPerScan(int maxEntries)
      Set max entries per scan in metastore.
      Parameters:
      maxEntries - Max entries per scan in metastore.
    • setFeature

      public void setFeature(String configProperty, Feature feature)
    • getFeature

      public Feature getFeature(String configProperty, Feature defaultValue)
    • setLedgerIdFormatterClass

      public void setLedgerIdFormatterClass(Class<? extends LedgerIdFormatter> formatterClass)
      Set Ledger id formatter Class.
      Parameters:
      formatterClass - LedgerIdFormatter Class
    • getLedgerIdFormatterClass

      public Class<? extends LedgerIdFormatter> getLedgerIdFormatterClass() throws org.apache.commons.configuration2.ex.ConfigurationException
      Get ledger id formatter class.
      Returns:
      LedgerIdFormatter class
      Throws:
      org.apache.commons.configuration2.ex.ConfigurationException
    • setEntryFormatterClass

      public void setEntryFormatterClass(Class<? extends EntryFormatter> formatterClass)
      Set entry formatter Class.
      Parameters:
      formatterClass - EntryFormatter Class
    • getEntryFormatterClass

      public Class<? extends EntryFormatter> getEntryFormatterClass() throws org.apache.commons.configuration2.ex.ConfigurationException
      Get entry formatter class.
      Returns:
      EntryFormatter class
      Throws:
      org.apache.commons.configuration2.ex.ConfigurationException
    • setClientAuthProviderFactoryClass

      public T setClientAuthProviderFactoryClass(String factoryClass)
      Set the client authentication provider factory class name. If this is not set, no authentication will be used
      Parameters:
      factoryClass - the client authentication provider factory class name
      Returns:
      client configuration
    • getClientAuthProviderFactoryClass

      public String getClientAuthProviderFactoryClass()
      Get the client authentication provider factory class name. If this returns null, no authentication will take place.
      Returns:
      the client authentication provider factory class name or null.
    • getNettyMaxFrameSizeBytes

      public int getNettyMaxFrameSizeBytes()
      Get the maximum netty frame size in bytes. Any message received larger that this will be rejected.
      Returns:
      the maximum netty frame size in bytes.
    • setNettyMaxFrameSizeBytes

      public T setNettyMaxFrameSizeBytes(int maxSize)
      Set the max number of bytes a single message can be that is read by the bookie. Any message larger than that size will be rejected.
      Parameters:
      maxSize - the max size in bytes
      Returns:
      server configuration
    • getTLSProviderFactoryClass

      public String getTLSProviderFactoryClass()
      Get the security provider factory class name. If this returns null, no security will be enforced on the channel.
      Returns:
      the security provider factory class name or null.
    • setTLSProviderFactoryClass

      public T setTLSProviderFactoryClass(String factoryClass)
      Set the client security provider factory class name. If this is not set, no security will be used on the channel.
      Parameters:
      factoryClass - the client security provider factory class name
      Returns:
      client configuration
    • getTLSProvider

      public String getTLSProvider()
      Get TLS Provider (JDK or OpenSSL).
      Returns:
      the TLS provider to use in creating TLS Context
    • setTLSProvider

      public T setTLSProvider(String provider)
      Set TLS Provider (JDK or OpenSSL).
      Parameters:
      provider - TLS Provider type
      Returns:
      Client Configuration
    • getTLSClientAuthentication

      public boolean getTLSClientAuthentication()
      Whether the client will send an TLS certificate on TLS-handshake.
      Returns:
      whether TLS is enabled on the bookie or not.
      See Also:
    • setTLSClientAuthentication

      public T setTLSClientAuthentication(boolean enabled)
      Specify whether the client will send an TLS certificate on TLS-handshake.
      Parameters:
      enabled - Whether to send a certificate or not
      Returns:
      client configuration
    • setTLSCertFilesRefreshDurationSeconds

      public T setTLSCertFilesRefreshDurationSeconds(long certFilesRefreshSec)
      Set tls certificate files refresh duration in seconds.
      Parameters:
      certFilesRefreshSec - tls certificate files refresh duration in seconds (set 0 to disable auto refresh)
      Returns:
      current configuration
    • getTLSCertFilesRefreshDurationSeconds

      public long getTLSCertFilesRefreshDurationSeconds()
      Get tls certificate files refresh duration in seconds.
      Returns:
      tls certificate files refresh duration in seconds. Default 0 to disable auto refresh.
    • setTLSEnabledCipherSuites

      public T setTLSEnabledCipherSuites(String list)
      Set the list of enabled TLS cipher suites. Leave null not to override default JDK list. This list will be passed to SSLEngine.setEnabledCipherSuites(java.lang.String[]). Please refer to official JDK JavaDocs
      Parameters:
      list - comma separated list of enabled TLS cipher suites
      Returns:
      current configuration
    • getTLSEnabledCipherSuites

      public String getTLSEnabledCipherSuites()
      Get the list of enabled TLS cipher suites.
      Returns:
      this list of enabled TLS cipher suites
      See Also:
    • setTLSEnabledProtocols

      public T setTLSEnabledProtocols(String list)
      Set the list of enabled TLS protocols. Leave null not to override default JDK list. This list will be passed to SSLEngine.setEnabledProtocols(java.lang.String[]). Please refer to official JDK JavaDocs
      Parameters:
      list - comma separated list of enabled TLS cipher suites
      Returns:
      current configuration
    • getTLSEnabledProtocols

      public String getTLSEnabledProtocols()
      Get the list of enabled TLS protocols.
      Returns:
      the list of enabled TLS protocols.
      See Also:
    • setMinNumRacksPerWriteQuorum

      public void setMinNumRacksPerWriteQuorum(int minNumRacksPerWriteQuorum)
      Set the minimum number of racks per write quorum.
    • getMinNumRacksPerWriteQuorum

      public int getMinNumRacksPerWriteQuorum()
      Get the minimum number of racks per write quorum.
    • setMinNumZonesPerWriteQuorum

      public void setMinNumZonesPerWriteQuorum(int minNumZonesPerWriteQuorum)
      Set the minimum number of zones per write quorum in ZoneAwarePlacementPolicy.
    • getMinNumZonesPerWriteQuorum

      public int getMinNumZonesPerWriteQuorum()
      Get the minimum number of zones per write quorum in ZoneAwarePlacementPolicy.
    • setDesiredNumZonesPerWriteQuorum

      public void setDesiredNumZonesPerWriteQuorum(int desiredNumZonesPerWriteQuorum)
      Set the desired number of zones per write quorum in ZoneAwarePlacementPolicy.
    • getDesiredNumZonesPerWriteQuorum

      public int getDesiredNumZonesPerWriteQuorum()
      Get the desired number of zones per write quorum in ZoneAwarePlacementPolicy.
    • setEnforceStrictZoneawarePlacement

      public void setEnforceStrictZoneawarePlacement(boolean enforceStrictZoneawarePlacement)
      Set the flag to enforce strict zoneaware placement.

      in ZoneawareEnsemblePlacementPolicy if strict placement is enabled then minZones/desiredZones in writeQuorum would be maintained otherwise it will pick nodes randomly.

    • getEnforceStrictZoneawarePlacement

      public boolean getEnforceStrictZoneawarePlacement()
      Get the flag to enforce strict zoneaware placement.

      in ZoneawareEnsemblePlacementPolicy if strict placement is enabled then minZones/desiredZones in writeQuorum would be maintained otherwise it will pick nodes randomly.

    • setEnforceMinNumRacksPerWriteQuorum

      public void setEnforceMinNumRacksPerWriteQuorum(boolean enforceMinNumRacksPerWriteQuorum)
      Set the flag to enforce minimum number of racks per write quorum.
    • getEnforceMinNumRacksPerWriteQuorum

      public boolean getEnforceMinNumRacksPerWriteQuorum()
      Get the flag which enforces the minimum number of racks per write quorum.
    • setEnforceMinNumFaultDomainsForWrite

      public void setEnforceMinNumFaultDomainsForWrite(boolean enforceMinNumFaultDomainsForWrite)
      Set the flag to enforce minimum number of fault domains for write.
    • getEnforceMinNumFaultDomainsForWrite

      public boolean getEnforceMinNumFaultDomainsForWrite()
      Get the flag to enforce minimum number of fault domains for write.
    • setIgnoreLocalNodeInPlacementPolicy

      public void setIgnoreLocalNodeInPlacementPolicy(boolean ignoreLocalNodeInPlacementPolicy)
      Sets the flag to ignore usage of localnode in placement policy.
    • getIgnoreLocalNodeInPlacementPolicy

      public boolean getIgnoreLocalNodeInPlacementPolicy()
      Whether to ignore localnode in placementpolicy.
    • setStoreSystemTimeAsLedgerUnderreplicatedMarkTime

      public T setStoreSystemTimeAsLedgerUnderreplicatedMarkTime(boolean enabled)
      Enable the Auditor to use system time as underreplicated ledger mark time.

      If this is enabled, Auditor will write a ctime field into the underreplicated ledger znode.

      Parameters:
      enabled - flag to enable/disable Auditor using system time as underreplicated ledger mark time.
    • getStoreSystemTimeAsLedgerUnderreplicatedMarkTime

      public boolean getStoreSystemTimeAsLedgerUnderreplicatedMarkTime()
      Return the flag that indicates whether auditor is using system time as underreplicated ledger mark time.
      Returns:
      the flag that indicates whether auditor is using system time as underreplicated ledger mark time.
    • getPreserveMdcForTaskExecution

      public boolean getPreserveMdcForTaskExecution()
      Whether to preserve MDC for tasks in Executor.
      Returns:
      flag to enable/disable MDC preservation in Executor.
    • setPreserveMdcForTaskExecution

      public T setPreserveMdcForTaskExecution(boolean enabled)
      Whether to preserve MDC for tasks in Executor.
      Parameters:
      enabled - flag to enable/disable MDC preservation in Executor.
      Returns:
      configuration.
    • getAllocatorPoolingPolicy

      public PoolingPolicy getAllocatorPoolingPolicy()
      Returns:
      the configured pooling policy for the allocator.
    • setAllocatorPoolingPolicy

      public T setAllocatorPoolingPolicy(PoolingPolicy poolingPolicy)
      Define the memory pooling policy.

      Default is PoolingPolicy.PooledDirect

      Parameters:
      poolingPolicy - the memory pooling policy
      Returns:
      configuration object.
    • getAllocatorPoolingConcurrency

      public int getAllocatorPoolingConcurrency()
      Returns:
      the configured pooling concurrency for the allocator.
    • setAllocatorPoolingConcurrency

      public T setAllocatorPoolingConcurrency(int concurrency)
      Controls the amount of concurrency for the memory pool.

      Default is to have a number of allocator arenas equals to 2 * CPUS.

      Decreasing this number will reduce the amount of memory overhead, at the expense of increased allocation contention.

      Parameters:
      concurrency - the concurrency level to use for the allocator pool
      Returns:
      configuration object.
    • getAllocatorOutOfMemoryPolicy

      public OutOfMemoryPolicy getAllocatorOutOfMemoryPolicy()
      Returns:
      the configured ouf of memory policy for the allocator.
    • setAllocatorOutOfMemoryPolicy

      public T setAllocatorOutOfMemoryPolicy(OutOfMemoryPolicy oomPolicy)
      Define the memory allocator out of memory policy.

      Default is OutOfMemoryPolicy.FallbackToHeap

      Parameters:
      oomPolicy - the "out-of-memory" policy for the memory allocator
      Returns:
      configuration object.
    • getAllocatorLeakDetectionPolicy

      public LeakDetectionPolicy getAllocatorLeakDetectionPolicy()
      Return the configured leak detection policy for the allocator.
    • setAllocatorLeakDetectionPolicy

      public T setAllocatorLeakDetectionPolicy(LeakDetectionPolicy leakDetectionPolicy)
      Enable the leak detection for the allocator.

      Default is LeakDetectionPolicy.Disabled

      Parameters:
      leakDetectionPolicy - the leak detection policy for the memory allocator
      Returns:
      configuration object.
    • setExitOnOutOfMemory

      public T setExitOnOutOfMemory(boolean exitOnOutOfMemory)
    • exitOnOutOfMemory

      public boolean exitOnOutOfMemory()
    • isBusyWaitEnabled

      public boolean isBusyWaitEnabled()
      Return whether the busy-wait is enabled for BookKeeper and Netty IO threads.

      Default is false

      Returns:
      the value of the option
    • setBusyWaitEnabled

      public T setBusyWaitEnabled(boolean busyWaitEnabled)
      Option to enable busy-wait settings.

      Default is false.

      WARNING: This option will enable spin-waiting on executors and IO threads in order to reduce latency during context switches. The spinning will consume 100% CPU even when bookie is not doing any work. It is recommended to reduce the number of threads in the main workers pool (ClientConfiguration.setNumWorkerThreads(int)) and Netty event loop ClientConfiguration.setNumIOThreads(int) to only have few CPU cores busy.

      Parameters:
      busyWaitEnabled - if enabled, use spin-waiting strategy to reduce latency in context switches
      See Also:
    • getLimitStatsLogging

      public boolean getLimitStatsLogging()
      Return the flag indicating whether to limit stats logging.
      Returns:
      the boolean flag indicating whether to limit stats logging
    • setLimitStatsLogging

      public T setLimitStatsLogging(boolean limitStatsLogging)
      Sets flag to limit the stats logging.
      Parameters:
      limitStatsLogging - flag to limit the stats logging.
      Returns:
      configuration.
    • getReplicationRateByBytes

      public int getReplicationRateByBytes()
      Get the bytes rate of re-replication. Default value is -1 which it means entries will replicated without any throttling activity.
      Returns:
      bytes rate of re-replication.
    • setReplicationRateByBytes

      public T setReplicationRateByBytes(int rate)
      Set the bytes rate of re-replication.
      Parameters:
      rate - bytes rate of re-replication.
      Returns:
      ClientConfiguration
    • getZkReplicationTaskRateLimit

      public double getZkReplicationTaskRateLimit()
      get the max tasks can be acquired per second of re-replication.
      Returns:
      max tasks can be acquired per second of re-replication.
    • setZkReplicationTaskRateLimit

      public T setZkReplicationTaskRateLimit(double zkReplicationTaskRateLimit)
      set the max tasks can be acquired per second of re-replication, default is 0, which means no limit. Value greater than 0 will enable the rate limiting. Decimal value is allowed. For example, 0.5 means 1 task per 2 seconds, 1 means 1 task per second.
      Parameters:
      zkReplicationTaskRateLimit -
      Returns:
      ClientConfiguration
    • getThis

      protected abstract T getThis()
      Trickery to allow inheritance with fluent style.
    • asJson

      public String asJson() throws JsonUtil.ParseJsonException
      returns the string representation of json format of this config.
      Returns:
      Throws:
      JsonUtil.ParseJsonException