Reputation: 211
I would like to know if there's some way to perform functions like listing the existing buckets in a couchbase cluster, creating a new bucket, retrieving cluster information etc. using the Couchbase Java SDK?
I know this can be done through the REST API, but I'm trying to manage the cluster dynamically using Java.
Upvotes: 1
Views: 184
Reputation: 176
To create a new bucket you can use the cluster manager class's insertBucket() method that takes in a BucketSettings object. For example you can create a bucket like this :
....
BucketSettings PrashantSampleBucket = new
DefaultBucketSettings.Builder()
.type(BucketType.COUCHBASE)
.name("PrashantSampleBucket")
.password("")
.quota(2048) // megabytes
.replicas(1)
.indexReplicas(true)
.enableFlush(true)
.build();
.... and now you need to insert your bucket in your cluster this can be done by :
cluster.clusterManager().insertBucket(PrashantSampleBucket);
Upvotes: 0
Reputation: 28301
Yes, there is a ClusterManager
class accessible through the Cluster
object's clusterManager()
method. You'll need the administrative credentials.
Upvotes: 2