Skip to content

Commit 7a393a2

Browse files
committed
SCBC-479: Update Bucket & Storage Support in SDKs
Supporting Morpheus changes for Magma. Change-Id: I1758ff189bbd64bba05ae6939fff2b0c59fa27b1 Reviewed-on: https://review.couchbase.org/c/couchbase-jvm-clients/+/228219 Reviewed-by: David Nault <[email protected]> Tested-by: Build Bot <[email protected]> Reviewed-by: Michael Reiche <[email protected]>
1 parent 45d82c5 commit 7a393a2

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

scala-client/src/main/scala/com/couchbase/client/scala/manager/bucket/BucketSettings.scala

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.couchbase.client.scala.manager.bucket
1717

18+
import com.couchbase.client.core.annotation.SinceCouchbase
1819
import com.couchbase.client.core.annotation.Stability.Internal
1920
import com.couchbase.client.core.config
2021
import com.couchbase.client.core.error.CouchbaseException
@@ -221,7 +222,8 @@ case class CreateBucketSettings(
221222
private[scala] val storageBackend: Option[StorageBackend] = None,
222223
private[scala] val historyRetentionCollectionDefault: Option[Boolean] = None,
223224
private[scala] val historyRetentionBytes: Option[Long] = None,
224-
private[scala] val historyRetentionDuration: Option[Duration] = None
225+
private[scala] val historyRetentionDuration: Option[Duration] = None,
226+
private[scala] val numVBuckets: Option[Int] = None
225227
) {
226228

227229
def flushEnabled(value: Boolean): CreateBucketSettings = {
@@ -285,6 +287,11 @@ case class CreateBucketSettings(
285287
copy(historyRetentionDuration = Some(value))
286288
}
287289

290+
/** Specifies the number of vbuckets (partitions) the created bucket should have.
291+
*/
292+
@SinceCouchbase("8.0")
293+
def numVBuckets(value: Int): CreateBucketSettings = copy(numVBuckets = Some(value))
294+
288295
private[scala] def toCore: CoreBucketSettings = {
289296
val x = this
290297
new CoreBucketSettings {
@@ -359,7 +366,7 @@ case class CreateBucketSettings(
359366
x.historyRetentionDuration.map(v => DurationConversions.scalaDurationToJava(v)).orNull
360367

361368
override def numVBuckets(): Integer =
362-
null // TODO https://jira.issues.couchbase.com/browse/SCBC-479
369+
x.numVBuckets.map(lang.Integer.valueOf).orNull
363370
}
364371
}
365372
}
@@ -379,7 +386,8 @@ case class BucketSettings(
379386
storageBackend: Option[StorageBackend] = None,
380387
historyRetentionCollectionDefault: Option[Boolean] = None,
381388
historyRetentionBytes: Option[Long] = None,
382-
historyRetentionDuration: Option[Duration] = None
389+
historyRetentionDuration: Option[Duration] = None,
390+
numVBuckets: Option[Int] = None
383391
) {
384392
def toCreateBucketSettings: CreateBucketSettings = {
385393
CreateBucketSettings(
@@ -397,7 +405,8 @@ case class BucketSettings(
397405
storageBackend,
398406
historyRetentionCollectionDefault,
399407
historyRetentionBytes,
400-
historyRetentionDuration
408+
historyRetentionDuration,
409+
numVBuckets
401410
)
402411
}
403412
}
@@ -452,7 +461,8 @@ private[scala] object BucketSettings {
452461
if (core.historyRetentionBytes != null) Some(core.historyRetentionBytes) else None,
453462
if (core.historyRetentionDuration != null)
454463
Some(core.historyRetentionDuration).map(DurationConversions.javaDurationToScala)
455-
else None
464+
else None,
465+
Some(core.numVBuckets)
456466
)
457467
out
458468
}

scala-fit-performer/src/main/scala/com/couchbase/client/performer/scala/manager/BucketManagerHelper.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import com.couchbase.client.performer.scala.util.OptionsUtil.{
2525
}
2626
import com.couchbase.client.protocol.run.Result
2727
import com.couchbase.client.protocol.sdk.Command
28+
import com.couchbase.client.protocol.sdk.cluster.bucketmanager
2829
import com.couchbase.client.protocol.shared.Durability
2930
import com.couchbase.client.scala.durability.Durability._
3031
import com.couchbase.client.scala.manager.bucket
@@ -300,6 +301,9 @@ object BucketManagerHelper {
300301
})
301302
case _ =>
302303
}
304+
// [if:1.8.2]
305+
if (bs.hasNumVbuckets) cs = cs.numVBuckets(bs.getNumVbuckets)
306+
// [end]
303307
cs
304308
}
305309

@@ -393,6 +397,15 @@ object BucketManagerHelper {
393397
response.historyRetentionCollectionDefault.foreach(v => builder.setHistoryRetentionCollectionDefault(v))
394398
response.historyRetentionBytes.foreach(v => builder.setHistoryRetentionBytes(v))
395399
response.historyRetentionDuration.foreach(v => builder.setHistoryRetentionSeconds(v.toSeconds))
400+
// [if:1.8.2]
401+
response.numVBuckets.foreach(v => builder.setNumVbuckets(v))
402+
// [end]
403+
404+
response.storageBackend match {
405+
case Some(StorageBackend.Magma) => builder.setStorageBackend(bucketmanager.StorageBackend.MAGMA)
406+
case Some(StorageBackend.Couchstore) => builder.setStorageBackend(bucketmanager.StorageBackend.COUCHSTORE)
407+
case _ =>
408+
}
396409

397410
builder.build
398411
}

scala-fit-performer/src/main/scala/com/couchbase/client/performer/scala/util/Capabilities.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ object Capabilities {
8282
out.add(Caps.SDK_ZONE_AWARE_READ_FROM_REPLICA)
8383
// [end:1.8.0]
8484

85+
// [start:1.8.2]
86+
out.add(Caps.SDK_BUCKET_SETTINGS_NUM_VBUCKETS)
87+
// [end:1.8.2]
88+
8589
out
8690
}
8791

0 commit comments

Comments
 (0)