@@ -153,14 +153,15 @@ public static Flux<CoreSubdocGetResult> lookupInAllReplicasReactive(
153153 final RetryStrategy retryStrategy ,
154154 Map <String , Object > clientContext ,
155155 RequestSpan parentSpan ,
156- CoreReadPreference readPreference
156+ CoreReadPreference readPreference ,
157+ byte flags
157158 ) {
158159 notNullOrEmpty (documentId , "Id" , () -> ReducedKeyValueErrorContext .create (documentId , collectionIdentifier ));
159160
160161 CoreEnvironment env = core .context ().environment ();
161162 RequestSpan getAllSpan = core .context ().coreResources ().requestTracer ().requestSpan (TracingIdentifiers .SPAN_LOOKUP_IN_ALL_REPLICAS , parentSpan );
162163 return Reactor
163- .toMono (() -> lookupInAllReplicasRequests (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , getAllSpan , readPreference ))
164+ .toMono (() -> lookupInAllReplicasRequests (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , getAllSpan , readPreference , flags ))
164165 .flux ()
165166 .flatMap (Flux ::fromStream )
166167 .flatMap (request -> Reactor
@@ -239,11 +240,12 @@ public static <R> CompletableFuture<List<CompletableFuture<R>>> lookupInAllRepli
239240 final Map <String , Object > clientContext ,
240241 final RequestSpan parentSpan ,
241242 final CoreReadPreference readPreference ,
243+ final byte flags ,
242244 final Function <CoreSubdocGetResult , R > responseMapper
243245 ) {
244246 RequestSpan getAllSpan = core .context ().coreResources ().requestTracer ().requestSpan (TracingIdentifiers .SPAN_GET_ALL_REPLICAS , parentSpan );
245247
246- return lookupInAllReplicasRequests (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , getAllSpan , readPreference )
248+ return lookupInAllReplicasRequests (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , getAllSpan , readPreference , flags )
247249 .thenApply (stream ->
248250 stream .map (request ->
249251 get (core , request )
@@ -312,13 +314,14 @@ public static <R> CompletableFuture<R> lookupInAnyReplicaAsync(
312314 final Map <String , Object > clientContext ,
313315 final RequestSpan parentSpan ,
314316 final CoreReadPreference readPreference ,
317+ final byte flags ,
315318 final Function <CoreSubdocGetResult , R > responseMapper ) {
316319
317320 RequestSpan getAnySpan = core .context ().coreResources ().requestTracer ()
318321 .requestSpan (TracingIdentifiers .SPAN_LOOKUP_IN_ANY_REPLICA , parentSpan );
319322
320323 CompletableFuture <List <CompletableFuture <R >>> listOfFutures = lookupInAllReplicasAsync (
321- core , collectionIdentifier , documentId , commands , timeout , retryStrategy , clientContext , getAnySpan , readPreference , responseMapper
324+ core , collectionIdentifier , documentId , commands , timeout , retryStrategy , clientContext , getAnySpan , readPreference , flags , responseMapper
322325 );
323326
324327 // Aggregating the futures here will discard the individual errors, which we don't need
@@ -476,7 +479,8 @@ public static CompletableFuture<Stream<SubdocGetRequest>> lookupInAllReplicasReq
476479 final RetryStrategy retryStrategy ,
477480 final Duration timeout ,
478481 final RequestSpan parent ,
479- final CoreReadPreference readPreference
482+ final CoreReadPreference readPreference ,
483+ final byte flags
480484 ) {
481485 notNullOrEmpty (documentId , "Id" );
482486
@@ -490,7 +494,7 @@ public static CompletableFuture<Stream<SubdocGetRequest>> lookupInAllReplicasReq
490494 return failedFuture (FeatureNotAvailableException .subdocReadReplica ());
491495 }
492496
493- List <SubdocGetRequest > requests = lookupInAllReplicasRequestsWithFallback (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , parent , readPreference , topology );
497+ List <SubdocGetRequest > requests = lookupInAllReplicasRequestsWithFallback (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , parent , readPreference , topology , flags );
494498 if (requests .isEmpty ()) {
495499 return failedFuture (DocumentUnretrievableException .noReplicasSuitable ());
496500 }
@@ -501,7 +505,7 @@ public static CompletableFuture<Stream<SubdocGetRequest>> lookupInAllReplicasReq
501505 final Duration retryDelay = Duration .ofMillis (100 );
502506 final CompletableFuture <Stream <SubdocGetRequest >> future = new CompletableFuture <>();
503507 coreContext .environment ().timer ().schedule (() -> {
504- lookupInAllReplicasRequests (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout .minus (retryDelay ), parent , readPreference ).whenComplete ((getRequestStream , throwable ) -> {
508+ lookupInAllReplicasRequests (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout .minus (retryDelay ), parent , readPreference , flags ).whenComplete ((getRequestStream , throwable ) -> {
505509 if (throwable != null ) {
506510 future .completeExceptionally (throwable );
507511 } else {
@@ -524,15 +528,16 @@ private static List<SubdocGetRequest> lookupInAllReplicasRequestsWithFallback(Co
524528 Duration timeout ,
525529 RequestSpan parent ,
526530 CoreReadPreference readPreference ,
527- CouchbaseBucketConfig topology ) {
531+ CouchbaseBucketConfig topology ,
532+ byte flags ) {
528533 CoreContext coreContext = core .context ();
529534
530535 int numReplicas = topology .numberOfReplicas ();
531536 List <SubdocGetRequest > requests = new ArrayList <>(numReplicas + 1 );
532537 NodeIndexCalculator allowedNodeIndexes = new NodeIndexCalculator (readPreference , topology , coreContext );
533538 if (allowedNodeIndexes .canUseNodeForActive (documentId )) {
534539 RequestSpan span = coreContext .coreResources ().requestTracer ().requestSpan (TracingIdentifiers .SPAN_REQUEST_KV_LOOKUP_IN , parent );
535- SubdocGetRequest activeRequest = SubdocGetRequest .create (timeout , coreContext , collectionIdentifier , retryStrategy , documentId , ( byte ) 0 , commands , span );
540+ SubdocGetRequest activeRequest = SubdocGetRequest .create (timeout , coreContext , collectionIdentifier , retryStrategy , documentId , flags , commands , span );
536541 activeRequest .context ().clientContext (clientContext );
537542 requests .add (activeRequest );
538543 }
@@ -541,15 +546,15 @@ private static List<SubdocGetRequest> lookupInAllReplicasRequestsWithFallback(Co
541546 if (allowedNodeIndexes .canUseNodeForReplica (documentId , replica - 1 )) {
542547 RequestSpan replicaSpan = coreContext .coreResources ().requestTracer ().requestSpan (TracingIdentifiers .SPAN_LOOKUP_IN_ALL_REPLICAS , parent );
543548 ReplicaSubdocGetRequest replicaRequest = ReplicaSubdocGetRequest .create (
544- timeout , coreContext , collectionIdentifier , retryStrategy , documentId , ( byte ) 0 , commands , replica , replicaSpan
549+ timeout , coreContext , collectionIdentifier , retryStrategy , documentId , flags , commands , replica , replicaSpan
545550 );
546551 replicaRequest .context ().clientContext (clientContext );
547552 requests .add (replicaRequest );
548553 }
549554 }
550555 if (requests .isEmpty () && readPreference == CoreReadPreference .PREFERRED_SERVER_GROUP_OR_ALL_AVAILABLE ) {
551556 logger .trace ("Unable to find suitable replicas with PREFERRED_SERVER_GROUP_WITH_FALLBACK, falling back to NO_PREFERENCE" );
552- return lookupInAllReplicasRequestsWithFallback (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , parent , CoreReadPreference .NO_PREFERENCE , topology );
557+ return lookupInAllReplicasRequestsWithFallback (core , collectionIdentifier , documentId , commands , clientContext , retryStrategy , timeout , parent , CoreReadPreference .NO_PREFERENCE , topology , flags );
553558 }
554559 return requests ;
555560 }
0 commit comments