You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2019/05/15 06:38:49 UTC

[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2096: Entries must be acknowledged by bookies in multiple fault domains before being acknowledged to client

eolivelli commented on a change in pull request #2096: Entries must be acknowledged by bookies in multiple fault domains before being acknowledged to client
URL: https://github.com/apache/bookkeeper/pull/2096#discussion_r284105068
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java
 ##########
 @@ -1060,4 +1061,30 @@ public boolean isEnsembleAdheringToPlacementPolicy(List<BookieSocketAddress> ens
         }
         return true;
     }
+
+    @Override
+    public boolean areAckedBookiesAdheringToPlacementPolicy(Set<BookieSocketAddress> ackedBookies) {
+        ReentrantReadWriteLock.ReadLock readLock = rwLock.readLock();
+
+        readLock.lock();
+        HashSet<String> rackCounter = new HashSet<>();
+        for (BookieSocketAddress bookie : ackedBookies) {
+            try {
+                rackCounter.add(knownBookies.get(bookie).getNetworkLocation());
+            } catch (Exception e) {
+                LOG.warn("Received exception while trying to get network location of bookie: {}", bookie, e);
+            }
+        }
+
+        // Check to make sure that ensemble is writing to `minNumberOfRacks`'s number of racks at least.
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("areAckedBookiesAdheringToPlacementPolicy returning {} because number of racks = {} and "
+                      + "minNumRacksPerWriteQuorum = {}",
+                      rackCounter.size() >= minNumRacksPerWriteQuorum,
+                      rackCounter.size(),
+                      minNumRacksPerWriteQuorum);
+        }
+        readLock.unlock();
 
 Review comment:
   enclose "readLock.unlock()"  in a finally block please

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services