Skip to content
Permalink
Browse files
catch onBookieRackChange exception (#3060)
### Motivation
When we update the bookie rack info, it will use all the bookie list to update rack topology. However If one bookie update failed and throw exception out, it will throw the exception out and the remains bookie info won't be updated into the rack topology, which will affect the ledger ensemble selection.

### Changes

Catch the bookie topology update exception to ensure the remaining bookies' info can be updated into the rack topology.
  • Loading branch information
hangc0276 committed Mar 31, 2022
1 parent ba2dede commit f55ac1ed55336c3ba461c57a3428430309118344
Showing 1 changed file with 14 additions and 9 deletions.
@@ -47,6 +47,7 @@
import org.apache.bookkeeper.net.DNSToSwitchMapping;
import org.apache.bookkeeper.net.NetUtils;
import org.apache.bookkeeper.net.NetworkTopology;
import org.apache.bookkeeper.net.NetworkTopologyImpl;
import org.apache.bookkeeper.net.Node;
import org.apache.bookkeeper.net.NodeBase;
import org.apache.bookkeeper.proto.BookieAddressResolver;
@@ -740,16 +741,20 @@ public void handleBookiesThatJoined(Set<BookieId> joinedBookies) {
public void onBookieRackChange(List<BookieId> bookieAddressList) {
rwLock.writeLock().lock();
try {
for (BookieId bookieAddress : bookieAddressList) {
BookieNode node = knownBookies.get(bookieAddress);
if (node != null) {
// refresh the rack info if its a known bookie
BookieNode newNode = createBookieNode(bookieAddress);
topology.remove(node);
topology.add(newNode);
knownBookies.put(bookieAddress, newNode);
bookieAddressList.forEach(bookieAddress -> {
try {
BookieNode node = knownBookies.get(bookieAddress);
if (node != null) {
// refresh the rack info if its a known bookie
BookieNode newNode = createBookieNode(bookieAddress);
topology.remove(node);
topology.add(newNode);
knownBookies.put(bookieAddress, newNode);
}
} catch (IllegalArgumentException | NetworkTopologyImpl.InvalidTopologyException e) {
LOG.error("Failed to update bookie rack info: {} ", bookieAddress, e);
}
}
});
} finally {
rwLock.writeLock().unlock();
}

0 comments on commit f55ac1e

Please sign in to comment.