Ghatage commented on a change in pull request #2493:
URL: https://github.com/apache/bookkeeper/pull/2493#discussion_r528067089



##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerCreateOp.java
##########
@@ -125,28 +125,52 @@
      * Initiates the operation.
      */
     public void initiate() {
+        int actualEnsembleSize = ensembleSize;
+        List<BookieId> ensemble = null;
+        // select bookies for first ensemble
+        if (bk.getConf().getOpportunisticStriping()) {
+            BKNotEnoughBookiesException lastError = null;
+            // we would like to select ensembleSize bookies, but
+            // we can settle to writeQuorumSize
+            while (actualEnsembleSize >= writeQuorumSize) {
+                try {
+                    ensemble = bk.getBookieWatcher()
+                        .newEnsemble(actualEnsembleSize, writeQuorumSize, 
ackQuorumSize, customMetadata);
+                    lastError = null;
+                    break;
+                } catch (BKNotEnoughBookiesException e) {
+                    LOG.error("Not enough bookies to create ledger with 
{}/{}/{}",
+                            actualEnsembleSize, writeQuorumSize, 
ackQuorumSize);
+                    lastError = e;
+                    actualEnsembleSize--;
+                }
+            }
+            if (lastError != null) {
+                createComplete(lastError.getCode(), null);
+                return;
+            }
+        } else {
+            try {
+                ensemble = bk.getBookieWatcher()
+                        .newEnsemble(actualEnsembleSize, writeQuorumSize, 
ackQuorumSize, customMetadata);
+            } catch (BKNotEnoughBookiesException e) {
+                LOG.error("Not enough bookies to create ledger with {}/{}/{}",

Review comment:
       Very useful error log, can we also have some details as to what the 
three arguments are?
   something like `Not enough bookies to create ledger with 
EnsembleSize/WriteQuorum/AckQuorum : {}/{}/{}`
   So it'll be helpful for users to know which is which.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to