Buckets and Clusters

The Couchbase Java SDK provides an API for managing a Couchbase cluster programmatically.

The primary means for managing clusters is through the Couchbase Web UI which provides an easy to use interface for adding, removing, monitoring and modifying buckets. In some instances you may wish to have a programmatic interface. For example, if you wish to manage a cluster from a setup script, or if you are setting up buckets in test scaffolding.

The Java SDK also comes with some convenience functionality for common Couchbase management requests. Management operations in the Java SDK may be performed through several interfaces depending on the object.

Creating and Removing Buckets

To create or delete a bucket, call the bucket manager with the buckets() call on the cluster:

Cluster cluster = Cluster.connect("", "Administrator", "123456");
BucketManager manager = cluster.buckets();

This class is also used to expose information about an existing bucket (manager.getBucket(string)) or to update an existing bucket (manager.updateBucket(bucketSettings)).

The default Collection & Default Scope will be used automatically.

Note that any property that is not explicitly set when building the BucketSettings will use the default value. In the case of the update, this is not necessarily the currently configured value, so you should be careful to set all properties to their correct expected values when updating an existing bucket configuration.