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
BucketSettingsinteract with the bucket management APIs:BucketManager,ReactiveBucketManagerandAsyncBucketManager, which can be obtained throughCluster.buckets(),ReactiveCluster.buckets()andAsyncCluster.buckets().
-
-
Constructor Summary
Constructors Constructor Description BucketSettings(String name, Map<String,String> controllers, Map<String,Long> quota, int numReplicas, boolean replicaIndex, int maxTTL, CompressionMode compressionMode, BucketType bucketType, ConflictResolutionType conflictResolutionType, EvictionPolicyType evictionPolicy, String durabilityMinLevel, StorageBackend storageBackend)CreatesBucketSettingsfrom a raw JSON payload.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BucketTypebucketType()Returns the bucket type.BucketSettingsbucketType(BucketType bucketType)Configures theBucketType.CompressionModecompressionMode()Returns theCompressionModeused for the bucket.BucketSettingscompressionMode(CompressionMode compressionMode)Sets the compression mode on the bucket.ConflictResolutionTypeconflictResolutionType()Returns the conflict resolution mode in use.BucketSettingsconflictResolutionType(ConflictResolutionType conflictResolutionType)Configures the conflict resolution mode for the bucket.static BucketSettingscreate(String name)CreatesBucketSettingswith the bucket name and all default properties.EjectionPolicyejectionPolicy()Deprecated.Please useevictionPolicyinstead.BucketSettingsejectionPolicy(EjectionPolicy ejectionPolicy)Deprecated.Please useevictionPolicyinstead.EvictionPolicyTypeevictionPolicy()Returns the eviction policy used on the bucket.BucketSettingsevictionPolicy(EvictionPolicyType evictionPolicy)Allows to configure a customEvictionPolicyTypeas the eviction policy.booleanflushEnabled()Returns true if flush is enabled on the bucket.BucketSettingsflushEnabled(boolean flushEnabled)Allows enabling flush on the bucket.booleanhealthy()Returns true if the bucket is identified as healthy by the cluster manager.DurationmaxExpiry()Returns the maximum expiry (time-to-live) for all documents in the bucket.BucketSettingsmaxExpiry(Duration maxExpiry)Specifies the maximum expiry (time-to-live) for all documents in the bucket.intmaxTTL()Deprecated.please usemaxExpiry()instead.BucketSettingsmaxTTL(int maxTTL)Deprecated.please usemaxExpiry(Duration)instead.DurabilityLevelminimumDurabilityLevel()Returns the minimum durability level set for the bucket.BucketSettingsminimumDurabilityLevel(DurabilityLevel durabilityLevel)Configures a custom minimumDurabilityLevelfor this bucket.Stringname()Returns the name of the bucket.intnumReplicas()Returns the configured number of replicas.BucketSettingsnumReplicas(int numReplicas)Sets the number of replica copies for the bucket.longramQuotaMB()Returns the bucket RAM quota in megabytes.BucketSettingsramQuotaMB(long ramQuotaMB)Sets the ram quota in MB for this bucket.booleanreplicaIndexes()Returns the number of replica indexes configured.BucketSettingsreplicaIndexes(boolean replicaIndexes)Sets the number of replica indexes on the bucket.StorageBackendstorageBackend()Returns the storage backend for the bucket.BucketSettingsstorageBackend(StorageBackend storageBackend)Configures aStorageBackendfor this bucket.StringtoString()
-
-
-
Constructor Detail
-
BucketSettings
@Internal public BucketSettings(String name, Map<String,String> controllers, Map<String,Long> quota, int numReplicas, boolean replicaIndex, int maxTTL, CompressionMode compressionMode, BucketType bucketType, ConflictResolutionType conflictResolutionType, EvictionPolicyType evictionPolicy, String durabilityMinLevel, StorageBackend storageBackend)
CreatesBucketSettingsfrom a raw JSON payload.Do not use this API directly, it's internal! Instead use
BucketSettings(String)and then apply the customizations through its setters.- Parameters:
name- the name of the bucket.controllers- the configured controllers.quota- the current bucket quota.numReplicas- the number of replicas configured.replicaIndex- the replica index.maxTTL- the maximum TTL currently configured.compressionMode- which compression mode is used, if any.bucketType- which bucket type is used.conflictResolutionType- which conflict resolution type is currently in use.evictionPolicy- the eviction policy in use.durabilityMinLevel- the minimum durability level configured, if any.storageBackend- the storage backend in use.
-
-
Method Detail
-
create
public static BucketSettings create(String name)
CreatesBucketSettingswith the bucket name and all default properties.- Parameters:
name- the name of the bucket.- Returns:
- the
BucketSettingswith 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 theCompressionModeused 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.
-
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
BucketSettingsinstance 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
BucketSettingsinstance 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
BucketSettingsinstance 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
BucketSettingsinstance 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
BucketSettingsinstance 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
BucketSettingsinstance for chaining purposes.
-
bucketType
public BucketSettings bucketType(BucketType bucketType)
Configures theBucketType.- Parameters:
bucketType- the type of the bucket.- Returns:
- this
BucketSettingsinstance 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
BucketSettingsinstance for chaining purposes.
-
evictionPolicy
public BucketSettings evictionPolicy(EvictionPolicyType evictionPolicy)
Allows to configure a customEvictionPolicyTypeas 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
BucketTypechosen - please consult the server documentation for more information on the subject.- Parameters:
evictionPolicy- (nullable) policy to use, or null for default policy for theBucketType.- Returns:
- this
BucketSettingsinstance for chaining purposes.
-
minimumDurabilityLevel
public BucketSettings minimumDurabilityLevel(DurabilityLevel durabilityLevel)
Configures a custom minimumDurabilityLevelfor this bucket.For
BucketType.COUCHBASE, all durability levels are available. ForBucketType.EPHEMERALonlyDurabilityLevel.NONEandDurabilityLevel.MAJORITYare 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
BucketSettingsinstance for chaining purposes.
-
storageBackend
public BucketSettings storageBackend(StorageBackend storageBackend)
Configures aStorageBackendfor this bucket.Note that
StorageBackend.MAGMAis 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
BucketTypeis chosen that does not have a storage backend attached (i.e.BucketType.MEMCACHEDorBucketType.EPHEMERAL), then this property is ignored.- Parameters:
storageBackend- the backend to use.- Returns:
- this
BucketSettingsinstance for chaining purposes.
-
maxTTL
@Deprecated public int maxTTL()
Deprecated.please usemaxExpiry()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 usemaxExpiry(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
BucketSettingsfor chaining purposes.
-
ejectionPolicy
@Deprecated public EjectionPolicy ejectionPolicy()
Deprecated.Please useevictionPolicyinstead.
-
ejectionPolicy
@Deprecated public BucketSettings ejectionPolicy(EjectionPolicy ejectionPolicy)
Deprecated.Please useevictionPolicyinstead.- Parameters:
ejectionPolicy- (nullable) policy to use, or null for default policy for the bucket type.
-
-