ankit-j 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_r286271112
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/RackawareEnsemblePlacementPolicyImpl.java
 ##########
 @@ -1060,4 +1061,33 @@ public boolean 
isEnsembleAdheringToPlacementPolicy(List<BookieSocketAddress> ens
         }
         return true;
     }
+
+    @Override
+    public boolean 
areAckedBookiesAdheringToPlacementPolicy(Set<BookieSocketAddress> ackedBookies) 
{
+        HashSet<String> rackCounter = new HashSet<>();
+
+        ReentrantReadWriteLock.ReadLock readLock = rwLock.readLock();
+        readLock.lock();
+        try {
+            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);
+            }
+        } finally {
+            readLock.unlock();
+        }
+        return rackCounter.size() >= minNumRacksPerWriteQuorum;
 
 Review comment:
   As per our discussion not sure this is the right approach, but doing these 
changes nevertheless.

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to