Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,8 @@ public void setConf(Configuration conf) {
conf.setProperty(ZK_DATA_CACHE_BK_RACK_CONF_INSTANCE, bookieMappingCache);
}

try {
BookiesRackConfiguration racks = bookieMappingCache.get(BOOKIE_INFO_ROOT_PATH).orElseGet(BookiesRackConfiguration::new);
updateRacksWithHost(racks);
} catch (Exception e) {
throw new RuntimeException(e);
}
// A previous version of this code tried to eagerly load the cache. However, this is invalid
// in later versions of bookkeeper as when setConf is called, the bookieAddressResolver is not yet set
}

private void updateRacksWithHost(BookiesRackConfiguration racks) {
Expand All @@ -94,20 +90,25 @@ private void updateRacksWithHost(BookiesRackConfiguration racks) {
bookies.forEach((addr, bi) -> {
try {
BookieId bookieId = BookieId.parse(addr);
BookieSocketAddress bsa = getBookieAddressResolver().resolve(bookieId);
newRacksWithHost.updateBookie(group, bsa.toString(), bi);

String hostname = bsa.getSocketAddress().getHostName();
newBookieInfoMap.put(hostname, bi);

InetAddress address = bsa.getSocketAddress().getAddress();
if (null != address) {
String hostIp = address.getHostAddress();
if (null != hostIp) {
newBookieInfoMap.put(hostIp, bi);
}
BookieAddressResolver addressResolver = getBookieAddressResolver();
if (addressResolver == null) {
LOG.warn("Bookie address resolver not yet initialized, skipping resolution");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this case happen?
Or is this only a precautionary null check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precautionary, I figure if it can return null we should be defensive

} else {
LOG.info("Network address for {} is unresolvable yet.", addr);
BookieSocketAddress bsa = addressResolver.resolve(bookieId);
newRacksWithHost.updateBookie(group, bsa.toString(), bi);

String hostname = bsa.getSocketAddress().getHostName();
newBookieInfoMap.put(hostname, bi);

InetAddress address = bsa.getSocketAddress().getAddress();
if (null != address) {
String hostIp = address.getHostAddress();
if (null != hostIp) {
newBookieInfoMap.put(hostIp, bi);
}
} else {
LOG.info("Network address for {} is unresolvable yet.", addr);
}
}
} catch (BookieAddressResolver.BookieIdNotResolvedException e) {
LOG.info("Network address for {} is unresolvable yet. error is {}", addr, e);
Expand Down