yangl commented on PR #18672:
URL: https://github.com/apache/pulsar/pull/18672#issuecomment-1347634103
btw, the else logic `MetadataStore store` should use the broker
`metadataStoreUrl`, because when we set the rack info by `admin bookies
set-bookie-rack` the configured json info on the broker used meta store url.
eg:
```sh
run autorcovery standlone `./bin/pulsar autorecovery`
```
```diff
- String metadataServiceUri =
ConfigurationStringUtil.castToString(conf.getProperty("metadataServiceUri"));
+ String metadataServiceUri =
ConfigurationStringUtil.castToString(conf.getProperty("metadataStoreUrl"));
```
```java
String url;
String metadataServiceUri =
ConfigurationStringUtil.castToString(conf.getProperty("metadataServiceUri"));
if (StringUtils.isNotBlank(metadataServiceUri)) {
try {
url =
metadataServiceUri.replaceFirst(METADATA_STORE_SCHEME + ":", "")
.replace(";", ",");
} catch (Exception e) {
throw new MetadataException(Code.METADATA_SERVICE_ERROR,
e);
}
} else {
String zkServers =
ConfigurationStringUtil.castToString(conf.getProperty("zkServers"));
if (StringUtils.isBlank(zkServers)) {
String errorMsg = String.format("Neither %s
configuration set in the BK client configuration nor "
+ "metadataServiceUri/zkServers set in bk server
configuration", METADATA_STORE_INSTANCE);
throw new RuntimeException(errorMsg);
}
url = zkServers;
}
try {
int zkTimeout = Integer.parseInt((String)
conf.getProperty("zkTimeout"));
store = MetadataStoreExtended.create(url,
MetadataStoreConfig.builder()
.metadataStoreName(MetadataStoreConfig.METADATA_STORE)
.sessionTimeoutMillis(zkTimeout)
.build());
} catch (MetadataStoreException e) {
throw new MetadataException(Code.METADATA_SERVICE_ERROR, e);
}
}
return store;
```
https://github.com/apache/pulsar/blob/master/pulsar-broker-common/src/main/java/org/apache/pulsar/bookie/rackawareness/BookieRackAffinityMapping.java#L79-L108
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]