ivankelly commented on a change in pull request #1192: BP-29 (task 3): use
metadata service uri for constructing registration client
URL: https://github.com/apache/bookkeeper/pull/1192#discussion_r170880742
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MetadataDrivers.java
##########
@@ -167,17 +167,28 @@ private static void loadInitialBookieDrivers() {
*/
public static void registerClientDriver(String metadataBackendScheme,
Class<? extends
MetadataClientDriver> driver) {
+ registerClientDriver(metadataBackendScheme, driver, false);
+ }
+
+ @VisibleForTesting
+ public static void registerClientDriver(String metadataBackendScheme,
+ Class<? extends
MetadataClientDriver> driver,
+ boolean allowOverride) {
if (!initialized) {
initialize();
}
String scheme = metadataBackendScheme.toLowerCase();
MetadataClientDriverInfo oldDriverInfo = clientDrivers.get(scheme);
- if (null != oldDriverInfo) {
+ if (null != oldDriverInfo && !allowOverride) {
return;
}
MetadataClientDriverInfo newDriverInfo = new
MetadataClientDriverInfo(driver);
- oldDriverInfo = clientDrivers.putIfAbsent(scheme, newDriverInfo);
+ if (allowOverride) {
Review comment:
Ah, true. Still, it would be nice to check allow override only once, to so
the read doesn't have to keep so much state in mind while reading. How about.
```
MetadataClientDriverInfo oldDriverInfo = clientDrivers.computeIfAbsent(
scheme, (k) -> new MetadataClientDriverInfo(driver));
if (null != oldDriverInfo) {
log.debug("Metadata client driver for {} is already there.", scheme);
if (allowOverride) {
log.debug("Overriding client driver for {}", scheme);
clientDrivers.put(scheme, new MetadataClientDriverInfo(driver));
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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