未验证 提交 9ddafdf1 编写于 作者: A Aloys 提交者: GitHub

update from zookeeper for available broker one more time if availableBrokers is empty (#7975)

Fixes #7476 

### Motivation

In some situations,  discovery service can't find active broker while all brokers are running well.  This PR will update from zookeeper if available broker list is empty to avoid  "No active broker is available"  `RestException` happen.


### Modifications

double check from zookeeper if availableBrokers is empty
上级 18a54c41
......@@ -28,6 +28,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.apache.bookkeeper.common.util.OrderedScheduler;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.pulsar.common.util.FutureUtil;
import org.apache.pulsar.common.util.ObjectMapperFactory;
import org.apache.pulsar.policies.data.loadbalancer.LoadManagerReport;
......@@ -124,6 +125,13 @@ public class ZookeeperCacheLoader implements Closeable {
}
public List<LoadManagerReport> getAvailableBrokers() {
if (CollectionUtils.isEmpty(availableBrokers)) {
try {
updateBrokerList(availableBrokersCache.get());
} catch (Exception e) {
log.warn("Error updating broker from zookeeper.", e);
}
}
return availableBrokers;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册