public class BucketManager extends Object
All mutating operations on this manager are eventually consistent, which means that as soon as the call returns the operation is accepted by the server, but it does not mean that the operation has been applied to all nodes in the cluster yet. In the future, APIs will be provided which allow to assert the propagation state.
Constructor and Description |
---|
BucketManager(AsyncBucketManager async)
Creates a new
BucketManager . |
Modifier and Type | Method and Description |
---|---|
AsyncBucketManager |
async()
Provides access to the
AsyncBucketManager for convenience. |
void |
createBucket(BucketSettings settings)
Creates a new bucket on the server.
|
void |
createBucket(BucketSettings settings,
CreateBucketOptions options)
Creates a new bucket on the server with custom options.
|
void |
dropBucket(String bucketName)
Drops ("deletes") a bucket from the cluster.
|
void |
dropBucket(String bucketName,
DropBucketOptions options)
Drops ("deletes") a bucket from the cluster with custom options.
|
void |
flushBucket(String bucketName)
Deletes all documents from ("flushes") a bucket.
|
void |
flushBucket(String bucketName,
FlushBucketOptions options)
Deletes all documents from ("flushes") a bucket with custom options.
|
Map<String,BucketSettings> |
getAllBuckets()
Loads the properties of all buckets the current user has access to from the cluster.
|
Map<String,BucketSettings> |
getAllBuckets(GetAllBucketOptions options)
Loads the properties of all buckets the current user has access to from the cluster.
|
BucketSettings |
getBucket(String bucketName)
Loads the properties of a bucket from the cluster.
|
BucketSettings |
getBucket(String bucketName,
GetBucketOptions options)
Loads the properties of a bucket from the cluster with custom options.
|
ReactiveBucketManager |
reactive()
Provides access to the
ReactiveBucketManager for convenience. |
void |
updateBucket(BucketSettings settings)
Updates the settings of a bucket which already exists.
|
void |
updateBucket(BucketSettings settings,
UpdateBucketOptions options)
Updates the settings of a bucket which already exists with custom options.
|
@Stability.Internal public BucketManager(AsyncBucketManager async)
BucketManager
.
This API is not intended to be called by the user directly, use Cluster.buckets()
instead.
async
- the underlying async manager that performs the ops.public AsyncBucketManager async()
AsyncBucketManager
for convenience.public ReactiveBucketManager reactive()
ReactiveBucketManager
for convenience.public void createBucket(BucketSettings settings)
The SDK will not perform any logical validation on correct combination of the settings - the server will return an error on invalid combinations. As an example, a magma bucket needs at least 1024 MiB of bucket quota - otherwise the server will reject it.
settings
- the BucketSettings
describing the properties of the bucket.com.couchbase.client.core.error.BucketExistsException
- if the bucket already exists.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public void createBucket(BucketSettings settings, CreateBucketOptions options)
The SDK will not perform any logical validation on correct combination of the settings - the server will return an error on invalid combinations. As an example, a magma bucket needs at least 1024 MiB of bucket quota - otherwise the server will reject it.
settings
- the BucketSettings
describing the properties of the bucket.options
- the custom options to apply.com.couchbase.client.core.error.BucketExistsException
- if the bucket already exists.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public void updateBucket(BucketSettings settings)
Not all properties of a bucket can be changed on an update. Notably, the following properties are ignored by the SDK on update and so will not produce an error but also not change anything on the server side:
BucketSettings.name()
BucketSettings.bucketType(BucketType)
BucketSettings.conflictResolutionType(ConflictResolutionType)
BucketSettings.replicaIndexes(boolean)
BucketSettings.storageBackend(StorageBackend)
The SDK will not perform any logical validation on correct combination of the settings - the server will return an error on invalid combinations. As an example, a magma bucket needs at least 1024 MiB of bucket quota - otherwise the server will reject it.
settings
- the BucketSettings
describing the properties of the bucket.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public void updateBucket(BucketSettings settings, UpdateBucketOptions options)
Not all properties of a bucket can be changed on an update. Notably, the following properties are ignored by the SDK on update and so will not produce an error but also not change anything on the server side:
BucketSettings.name()
BucketSettings.bucketType(BucketType)
BucketSettings.conflictResolutionType(ConflictResolutionType)
BucketSettings.replicaIndexes(boolean)
BucketSettings.storageBackend(StorageBackend)
The SDK will not perform any logical validation on correct combination of the settings - the server will return an error on invalid combinations. As an example, a magma bucket needs at least 1024 MiB of bucket quota - otherwise the server will reject it.
settings
- the BucketSettings
describing the properties of the bucket.options
- the custom options to apply.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public void dropBucket(String bucketName)
bucketName
- the name of the bucket to drop.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public void dropBucket(String bucketName, DropBucketOptions options)
bucketName
- the name of the bucket to drop.options
- the custom options to apply.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public BucketSettings getBucket(String bucketName)
bucketName
- the name of the bucket for which the settings should be loaded.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public BucketSettings getBucket(String bucketName, GetBucketOptions options)
bucketName
- the name of the bucket for which the settings should be loaded.options
- the custom options to apply.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public Map<String,BucketSettings> getAllBuckets()
com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public Map<String,BucketSettings> getAllBuckets(GetAllBucketOptions options)
options
- the custom options to apply.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public void flushBucket(String bucketName)
Flush needs to be enabled on the bucket in order to perform the operation. Enabling flush is not recommended in a production cluster and can lead to data loss!
Keep in mind that flush is not an atomic operation, the server will need some time to clean the partitions out completely. If isolation is preferred in an integration-test scenario, creating individual buckets might provide a better user experience.
bucketName
- the name of the bucket to flush.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.BucketNotFlushableException
- if flush is not enabled on the bucket.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.public void flushBucket(String bucketName, FlushBucketOptions options)
Flush needs to be enabled on the bucket in order to perform the operation. Enabling flush is not recommended in a production cluster and can lead to data loss!
Keep in mind that flush is not an atomic operation, the server will need some time to clean the partitions out completely. If isolation is preferred in an integration-test scenario, creating individual buckets might provide a better user experience.
bucketName
- the name of the bucket to flush.options
- the custom options to apply.com.couchbase.client.core.error.BucketNotFoundException
- if the specified bucket does not exist.com.couchbase.client.core.error.BucketNotFlushableException
- if flush is not enabled on the bucket.com.couchbase.client.core.error.CouchbaseException
- if any other generic unhandled/unexpected errors.Copyright © 2024 Couchbase, Inc.. All rights reserved.