本文整理了Java中com.yahoo.pulsar.zookeeper.ZooKeeperChildrenCache
类的一些代码示例,展示了ZooKeeperChildrenCache
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperChildrenCache
类的具体详情如下:
包路径:com.yahoo.pulsar.zookeeper.ZooKeeperChildrenCache
类名称:ZooKeeperChildrenCache
暂无
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker-common
this.clustersListCache = new ZooKeeperChildrenCache(cache, CLUSTERS_ROOT);
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
private Set<String> getAvailableBrokers() {
try {
return availableActiveBrokers.get();
} catch (Exception e) {
log.warn("Error when trying to get active brokers", e);
return loadData.getBrokerData().keySet();
}
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
@Override
public void stop() throws PulsarServerException {
loadReportCacheZk.close();
loadReportCacheZk.clear();
availableActiveBrokers.close();
scheduler.shutdown();
}
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-discovery-service
this.availableBrokersCache = new ZooKeeperChildrenCache(getLocalZkCache(), LOADBALANCE_BROKERS_ROOT);
this.availableBrokersCache.registerListener((path, brokerNodes, stat) -> {
try {
updateBrokerList(brokerNodes);
updateBrokerList(availableBrokersCache.get());
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
availableActiveBrokers = new ZooKeeperChildrenCache(pulsar.getLocalZkCache(), LOADBALANCE_BROKERS_ROOT);
availableActiveBrokers.registerListener(new ZooKeeperCacheListener<Set<String>>() {
@Override
public void onUpdate(String path, Set<String> data, Stat stat) {
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
availableActiveBrokers = new ZooKeeperChildrenCache(pulsar.getLocalZkCache(),
LoadManager.LOADBALANCE_BROKERS_ROOT);
availableActiveBrokers.registerListener(new ZooKeeperCacheListener<Set<String>>() {
@Override
public void onUpdate(String path, Set<String> data, Stat stat) {
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
@GET
@ApiOperation(value = "Get the list of all the Pulsar clusters.", response = String.class, responseContainer = "Set")
@ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission") })
public Set<String> getClusters() throws Exception {
try {
return clustersListCache().get();
} catch (Exception e) {
log.error("[{}] Failed to get clusters list", clientAppId(), e);
throw new RestException(e);
}
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
this.managedLedgerListCache = new ZooKeeperChildrenCache(cache, MANAGED_LEDGER_ROOT);
this.resourceQuotaCache = new ResourceQuotaCache(cache);
this.resourceQuotaCache.initZK();
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
/**
* As any broker, stop the load manager.
*
* @throws PulsarServerException
* If an unexpected error occurred when attempting to stop the load manager.
*/
@Override
public void stop() throws PulsarServerException {
availableActiveBrokers.close();
brokerDataCache.close();
brokerDataCache.clear();
scheduler.shutdown();
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
private Map<Long, Set<ResourceUnit>> getAvailableBrokers(ServiceUnitId serviceUnitId) throws Exception {
Map<Long, Set<ResourceUnit>> availableBrokers = sortedRankings.get();
// Normal case: we are the leader and we do have load reports information available
if (availableBrokers.isEmpty()) {
// Create a map with all available brokers with no load information
Set<String> activeBrokers = availableActiveBrokers.get(LOADBALANCE_BROKERS_ROOT);
List<String> brokersToShuffle = new ArrayList<>(activeBrokers);
Collections.shuffle(brokersToShuffle);
activeBrokers = new HashSet<>(brokersToShuffle);
availableBrokers = Maps.newTreeMap();
for (String broker : activeBrokers) {
ResourceUnit resourceUnit = new SimpleResourceUnit(String.format("http://%s", broker),
new PulsarResourceDescription());
availableBrokers.computeIfAbsent(0L, key -> Sets.newTreeSet()).add(resourceUnit);
}
log.info("Choosing at random from broker list: [{}]", availableBrokers.values());
}
return availableBrokers;
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
public List<String> getListOfDestinations(String property, String cluster, String namespace) throws Exception {
List<String> destinations = Lists.newArrayList();
// For every topic there will be a managed ledger created.
try {
String path = String.format("/managed-ledgers/%s/%s/%s/persistent", property, cluster, namespace);
LOG.debug("Getting children from managed-ledgers now: {}", path);
for (String destination : pulsar.getLocalZkCacheService().managedLedgerListCache().get(path)) {
destinations.add(String.format("persistent://%s/%s/%s/%s", property, cluster, namespace,
Codec.decode(destination)));
}
} catch (KeeperException.NoNodeException e) {
// NoNode means there are no persistent topics for this namespace
}
destinations.sort(null);
return destinations;
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
activeBrokers = availableActiveBrokers.get();
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
private void updateRanking() {
try {
synchronized (currentLoadReports) {
currentLoadReports.clear();
Set<String> activeBrokers = availableActiveBrokers.get();
for (String broker : activeBrokers) {
try {
String key = String.format("%s/%s", LOADBALANCE_BROKERS_ROOT, broker);
LoadReport lr = loadReportCacheZk.get(key)
.orElseThrow(() -> new KeeperException.NoNodeException());
ResourceUnit ru = new SimpleResourceUnit(String.format("http://%s", lr.getName()),
fromLoadReport(lr));
this.currentLoadReports.put(ru, lr);
} catch (Exception e) {
log.warn("Error reading load report from Cache for broker - [{}], [{}]", broker, e);
}
}
updateRealtimeResourceQuota();
doLoadRanking();
}
} catch (Exception e) {
log.warn("Error reading active brokers list from zookeeper while re-ranking load reports [{}]", e);
}
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
Set<String> clusters() {
try {
return pulsar().getConfigurationCache().clustersListCache().get();
} catch (Exception e) {
throw new RestException(e);
}
}
代码示例来源:origin: com.yahoo.pulsar/pulsar-broker
for (String destination : managedLedgerListCache().get(path)) {
if (domain().equals(DestinationDomain.persistent.toString())) {
destinations.add(DestinationName
内容来源于网络,如有侵权,请联系作者删除!