Skip to content

Commit

Permalink
update from zookeeper for available broker one more time if available…
Browse files Browse the repository at this point in the history
…Brokers is empty (apache#7975)

Fixes apache#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
  • Loading branch information
aloyszhang authored Sep 8, 2020
1 parent 18a54c4 commit 9ddafdf
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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;
Expand Down Expand Up @@ -124,6 +125,13 @@ public LoadManagerReport deserialize(String key, byte[] content) throws Exceptio
}

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;
}

Expand Down

0 comments on commit 9ddafdf

Please sign in to comment.