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_r170574099
##########
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:
It'd be better to handle all the special case branching based on a boolean
flag in one place.
```java
if (null != oldDriverInfo) {
if (allowOverride) {
log.debug("Metadata client driver for {} is already there.",
scheme);
} else {
return;
}
}
clientDrivers.put(scheme, newDriverInfo);
```
----------------------------------------------------------------
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