Class BucketSettings

java.lang.Object
com.couchbase.client.java.manager.bucket.BucketSettings

public class BucketSettings extends Object
Represents all properties of a Couchbase Server Bucket.

The BucketSettings interact with the bucket management APIs: BucketManager, ReactiveBucketManager and AsyncBucketManager, which can be obtained through Cluster.buckets(), ReactiveCluster.buckets() and AsyncCluster.buckets().

  • Constructor Details

  • Method Details

    • create

      public static BucketSettings create(String name)
      Creates BucketSettings with the bucket name and all default properties.
      Parameters:
      name - the name of the bucket.
      Returns:
      the BucketSettings with all its defaults set.
    • name

      public String name()
      Returns the name of the bucket.
    • flushEnabled

      public boolean flushEnabled()
      Returns true if flush is enabled on the bucket.
    • ramQuotaMB

      public long ramQuotaMB()
      Returns the bucket RAM quota in megabytes.
    • numReplicas

      public int numReplicas()
      Returns the configured number of replicas.
    • replicaIndexes

      public boolean replicaIndexes()
      Returns the number of replica indexes configured.
    • minimumDurabilityLevel

      public DurabilityLevel minimumDurabilityLevel()
      Returns the minimum durability level set for the bucket.

      Note that if the bucket does not support it, and by default, it is set to DurabilityLevel.NONE.

      Returns:
      the minimum durability level for that bucket.
    • maxExpiry

      public Duration maxExpiry()
      Returns the maximum expiry (time-to-live) for all documents in the bucket.
    • compressionMode

      public CompressionMode compressionMode()
      Returns the CompressionMode used for the bucket.
    • bucketType

      public BucketType bucketType()
      Returns the bucket type.
    • conflictResolutionType

      public ConflictResolutionType conflictResolutionType()
      Returns the conflict resolution mode in use.
    • storageBackend

      public StorageBackend storageBackend()
      Returns the storage backend for the bucket.
    • historyRetentionDuration

      public Duration historyRetentionDuration()
      Returns the history retention duration used on the bucket.
    • historyRetentionBytes

      public Long historyRetentionBytes()
      Returns the history retention bytes used on the bucket.
    • historyRetentionCollectionDefault

      public Boolean historyRetentionCollectionDefault()
      Returns the history retention default used on the bucket.
    • evictionPolicy

      public EvictionPolicyType evictionPolicy()
      Returns the eviction policy used on the bucket.
    • healthy

      @Internal public boolean healthy()
      Returns true if the bucket is identified as healthy by the cluster manager.
    • flushEnabled

      public BucketSettings flushEnabled(boolean flushEnabled)
      Allows enabling flush on the bucket.
      Parameters:
      flushEnabled - if flush should be enabled (not recommended for production!).
      Returns:
      this BucketSettings instance for chaining purposes.
    • ramQuotaMB

      public BucketSettings ramQuotaMB(long ramQuotaMB)
      Sets the ram quota in MB for this bucket.
      Parameters:
      ramQuotaMB - the bucket quota in megabytes.
      Returns:
      this BucketSettings instance for chaining purposes.
    • numReplicas

      public BucketSettings numReplicas(int numReplicas)
      Sets the number of replica copies for the bucket.
      Parameters:
      numReplicas - the number of replicas.
      Returns:
      this BucketSettings instance for chaining purposes.
    • replicaIndexes

      public BucketSettings replicaIndexes(boolean replicaIndexes)
      Sets the number of replica indexes on the bucket.
      Parameters:
      replicaIndexes - the number of replica indexes.
      Returns:
      this BucketSettings instance for chaining purposes.
    • maxExpiry

      public BucketSettings maxExpiry(Duration maxExpiry)
      Specifies the maximum expiry (time-to-live) for all documents in the bucket.
      Parameters:
      maxExpiry - the maximum expiry.
      Returns:
      this BucketSettings instance for chaining purposes.
    • compressionMode

      public BucketSettings compressionMode(CompressionMode compressionMode)
      Sets the compression mode on the bucket.
      Parameters:
      compressionMode - the compression mode to use.
      Returns:
      this BucketSettings instance for chaining purposes.
    • bucketType

      public BucketSettings bucketType(BucketType bucketType)
      Configures the BucketType.
      Parameters:
      bucketType - the type of the bucket.
      Returns:
      this BucketSettings instance for chaining purposes.
    • conflictResolutionType

      public BucketSettings conflictResolutionType(ConflictResolutionType conflictResolutionType)
      Configures the conflict resolution mode for the bucket.
      Parameters:
      conflictResolutionType - the type of conflict resolution to use.
      Returns:
      this BucketSettings instance for chaining purposes.
    • evictionPolicy

      public BucketSettings evictionPolicy(EvictionPolicyType evictionPolicy)
      Allows to configure a custom EvictionPolicyType as the eviction policy.

      Eviction automatically removes older data from RAM to create space for new data if you reach your bucket quota. How eviction behaves in detail depends on the BucketType chosen - please consult the server documentation for more information on the subject.

      Parameters:
      evictionPolicy - (nullable) policy to use, or null for default policy for the BucketType.
      Returns:
      this BucketSettings instance for chaining purposes.
    • minimumDurabilityLevel

      public BucketSettings minimumDurabilityLevel(DurabilityLevel durabilityLevel)
      Configures a custom minimum DurabilityLevel for this bucket.

      For BucketType.COUCHBASE, all durability levels are available. For BucketType.EPHEMERAL only DurabilityLevel.NONE and DurabilityLevel.MAJORITY are available. The durability level is not supported on memcached buckets (please use ephemeral buckets instead).

      Parameters:
      durabilityLevel - the minimum level to use for all KV operations.
      Returns:
      this BucketSettings instance for chaining purposes.
    • storageBackend

      public BucketSettings storageBackend(StorageBackend storageBackend)
      Configures a StorageBackend for this bucket.

      Note that StorageBackend.MAGMA is only supported in 7.0 if developer preview is enabled. It is recommended to be used only with Server 7.1 and later.

      Also, if a BucketType is chosen that does not have a storage backend attached (i.e. BucketType.MEMCACHED or BucketType.EPHEMERAL), then this property is ignored.

      Parameters:
      storageBackend - the backend to use.
      Returns:
      this BucketSettings instance for chaining purposes.
    • historyRetentionCollectionDefault

      public BucketSettings historyRetentionCollectionDefault(Boolean historyRetentionCollectionDefault)
      Configures historyRetentionCollectionDefault for this bucket.
      Parameters:
      historyRetentionCollectionDefault -
      Returns:
      this BucketSettings instance for chaining purposes.
    • historyRetentionBytes

      public BucketSettings historyRetentionBytes(Long historyRetentionBytes)
      Configures historyRetentionBytes for this bucket.
      Parameters:
      historyRetentionBytes -
      Returns:
      this BucketSettings instance for chaining purposes.
    • historyRetentionDuration

      public BucketSettings historyRetentionDuration(Duration historyRetentionDuration)
      Configures historyRetentionDuration for this bucket.
      Parameters:
      historyRetentionDuration -
      Returns:
      this BucketSettings instance for chaining purposes.
    • maxTTL

      @Deprecated public int maxTTL()
      Deprecated.
      please use maxExpiry() instead.
      Returns the maximum expiry (time-to-live) for all documents in the bucket in seconds.
    • maxTTL

      @Deprecated public BucketSettings maxTTL(int maxTTL)
      Deprecated.
      please use maxExpiry(Duration) instead.
      Specifies the maximum expiry (time-to-live) for all documents in the bucket in seconds.
      Parameters:
      maxTTL - the maximum expiry in seconds.
      Returns:
      this BucketSettings for chaining purposes.
    • ejectionPolicy

      @Deprecated public EjectionPolicy ejectionPolicy()
      Deprecated.
      Please use evictionPolicy instead.
    • ejectionPolicy

      @Deprecated public BucketSettings ejectionPolicy(EjectionPolicy ejectionPolicy)
      Deprecated.
      Please use evictionPolicy instead.
      Parameters:
      ejectionPolicy - (nullable) policy to use, or null for default policy for the bucket type.
    • toCore

      @Internal public CoreBucketSettings toCore()
    • toString

      public String toString()
      Overrides:
      toString in class Object