2

I'm trying to enable/disable bucket flush option using below code and it doesn't work. (SDK 3.0)

public static void main(String... args) {
    Cluster cluster = Cluster.connect("host", "user", "password");
    cluster.bucket("bucketName").async();
    cluster.buckets().getBucket("bucketName").flushEnabled(true);
    cluster.buckets().flushBucket("bucketName");
}

Is there any other way to do it? (If i enable the bucket option to flush, i am able to flush the bucket using above code.)

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121
Shmuel P.
  • 129
  • 1
  • 8

1 Answers1

3

You're missing a call to updateBucket which saves the modified settings:

public void setFlushable(Cluster cluster, String bucket, boolean flushable) {
  BucketSettings settings = cluster.buckets().getBucket(bucket);
  settings.flushEnabled(flushable);
  cluster.buckets().updateBucket(settings);
}
dnault
  • 8,340
  • 1
  • 34
  • 53
  • I tried adding the BucketSetting as u suggested but im facing below exception: Exception in thread "main" java.lang.IllegalArgumentException: Cannot deserialize value of type `com.couchbase.client.java.manager.bucket.EjectionPolicy` from String "noEviction": not one of the values accepted for Enum class: [valueOnly, fullEviction] at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: com.couchbase.client.java.manager.bucket.BucketSettings["evictionPolicy"]) – Shmuel P. Jun 25 '20 at 07:21
  • 1
    Sounds like a bug in the SDK. What version of Couchbase Server, and what version of Couchbase Java SDK? – dnault Jun 25 '20 at 17:39
  • Also, can you confirm this is en "ephemeral" bucket? – dnault Jun 25 '20 at 17:46
  • 1
    I filed [JCBC-1647](https://issues.couchbase.com/browse/JCBC-1647) on the Couchbase Jira to track this issue. – dnault Jun 25 '20 at 19:22
  • im using Couchbase Server 5.5.6 and Couchbase Java SDK 3.0 – Shmuel P. Jul 08 '20 at 07:15