sijie commented on a change in pull request #1808: Allow to configure sticky 
reads
URL: https://github.com/apache/bookkeeper/pull/1808#discussion_r241438417
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
 ##########
 @@ -180,6 +194,13 @@
 
         this.ledgerId = ledgerId;
 
+        if (clientCtx.getConf().enableStickyReads
+                && getLedgerMetadata().getEnsembleSize() == 
getLedgerMetadata().getWriteQuorumSize()) {
+            stickyBookieIndex = ThreadLocalRandom.current().nextInt() % 
getLedgerMetadata().getEnsembleSize();
 
 Review comment:
   it might be better to add a method in `EnsemblePlacementPolicy`
   
   ```
   int getStickyReadBookieIndex(LedgerMetadata metadata);
   ```
   
   it can pick up a bookie randomly by default. for rack-aware and region-aware 
placement, it can be implemented using network locations.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to