gpt4 book ai didi

org.apache.pulsar.zookeeper.ZooKeeperDataCache.getAsync()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 00:21:31 27 4
gpt4 key购买 nike

本文整理了Java中org.apache.pulsar.zookeeper.ZooKeeperDataCache.getAsync()方法的一些代码示例,展示了ZooKeeperDataCache.getAsync()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeperDataCache.getAsync()方法的具体详情如下:
包路径:org.apache.pulsar.zookeeper.ZooKeeperDataCache
类名称:ZooKeeperDataCache
方法名:getAsync

ZooKeeperDataCache.getAsync介绍

暂无

代码示例

代码示例来源:origin: org.apache.pulsar/pulsar-zookeeper-utils

/**
 * Return an item from the cache
 *
 * If node doens't exist, the value will be not present.s
 *
 * @param path
 * @return
 * @throws Exception
 */
public Optional<T> get(final String path) throws Exception {
  return getAsync(path).get();
}

代码示例来源:origin: org.apache.pulsar/pulsar-broker

LOG.info("Failed to acquire ownership of {} -- Already owned by other broker", path);
ownershipReadOnlyCache.getAsync(path).thenAccept(ownerData -> {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Found owner for {} at {}", bundle, ownerData);

代码示例来源:origin: org.apache.pulsar/pulsar-broker

ZooKeeperDataCache<Policies> policiesCache = pulsar.getConfigurationCache().policiesCache();
policiesCache.getAsync(path(POLICIES, namespaceName)).thenAccept(policies -> {
  if (!policies.isPresent() || StringUtils.isBlank(policies.get().antiAffinityGroup)) {
    antiAffinityNsBrokersResult.complete(null);
      CompletableFuture<Void> future = new CompletableFuture<>();
      futures.add(future);
      policiesCache.getAsync(path(POLICIES, ns)).thenAccept(nsPolicies -> {
        if (nsPolicies.isPresent() && antiAffinityGroup.equalsIgnoreCase(nsPolicies.get().antiAffinityGroup)) {
          brokerToAntiAffinityNamespaceCount.compute(broker,

代码示例来源:origin: org.apache.pulsar/pulsar-broker

/**
 * Method to get the current owner of the <code>ServiceUnit</code>
 *
 * @param suId
 *            identifier of the <code>ServiceUnit</code>
 * @return The ephemeral node data showing the current ownership info in <code>ZooKeeper</code>
 * @throws Exception
 *             throws exception if no ownership info is found
 */
public CompletableFuture<Optional<NamespaceEphemeralData>> getOwnerAsync(NamespaceBundle suname) {
  String path = ServiceUnitZkUtils.path(suname);
  CompletableFuture<OwnedBundle> ownedBundleFuture = ownedBundlesCache.getIfPresent(path);
  if (ownedBundleFuture != null) {
    // Either we're the owners or we're trying to become the owner.
    return ownedBundleFuture.thenApply(serviceUnit -> {
      // We are the owner of the service unit
      return Optional.of(serviceUnit.isActive() ? selfOwnerInfo : selfOwnerInfoDisabled);
    });
  }
  // If we're not the owner, we need to check if anybody else is
  return ownershipReadOnlyCache.getAsync(path);
}

代码示例来源:origin: org.apache.pulsar/pulsar-broker-common

public CompletableFuture<Boolean> checkPermission(TopicName topicName, String role, AuthAction action) {
  CompletableFuture<Boolean> permissionFuture = new CompletableFuture<>();
  try {
    configCache.policiesCache().getAsync(POLICY_ROOT + topicName.getNamespace()).thenAccept(policies -> {
      if (!policies.isPresent()) {
        if (log.isDebugEnabled()) {

代码示例来源:origin: org.apache.pulsar/pulsar-broker-common

CompletableFuture<Boolean> permissionFuture = new CompletableFuture<>();
try {
  configCache.policiesCache().getAsync(POLICY_ROOT + topicName.getNamespace()).thenAccept(policies -> {
    if (!policies.isPresent()) {
      if (log.isDebugEnabled()) {

代码示例来源:origin: org.apache.pulsar/pulsar-broker

pulsar.getConfigurationCache().clustersCache().getAsync(path("clusters", cluster))
    .thenAccept(clusterDataResult -> {
      if (clusterDataResult.isPresent()) {

代码示例来源:origin: org.apache.pulsar/pulsar-broker

private CompletableFuture<Boolean> isDeduplicationEnabled() {
  TopicName name = TopicName.get(topic.getName());
  return pulsar.getConfigurationCache().policiesCache()
      .getAsync(AdminResource.path(POLICIES, name.getNamespace())).thenApply(policies -> {
        // If namespace policies have the field set, it will override the broker-level setting
        if (policies.isPresent() && policies.get().deduplicationEnabled != null) {
          return policies.get().deduplicationEnabled;
        }
        return pulsar.getConfiguration().isBrokerDeduplicationEnabled();
      });
}

代码示例来源:origin: org.apache.pulsar/pulsar-broker

checkNotNull(configurationCacheService);
checkNotNull(configurationCacheService.policiesCache());
checkNotNull(configurationCacheService.policiesCache().getAsync(globalPath));
configurationCacheService.policiesCache().getAsync(globalPath).thenAccept(policies -> {
  if (policies.isPresent()) {

代码示例来源:origin: org.apache.pulsar/pulsar-broker

final String path = AdminResource.path(POLICIES, namespace.toString());
pulsarService.getConfigurationCache().policiesCache().getAsync(path).thenAccept(policiesResult -> {
  if (policiesResult.isPresent()) {
    Policies policies = policiesResult.get();

代码示例来源:origin: org.apache.pulsar/pulsar-broker

/**
 * Gets configured dispatch-rate from namespace policies. Returns null if dispatch-rate is not configured
 *
 * @return
 */
public DispatchRate getPoliciesDispatchRate() {
  final NamespaceName namespace = TopicName.get(this.topicName).getNamespaceObject();
  final String cluster = brokerService.pulsar().getConfiguration().getClusterName();
  final String path = path(POLICIES, namespace.toString());
  Optional<Policies> policies = Optional.empty();
  try {
    policies = brokerService.pulsar().getConfigurationCache().policiesCache().getAsync(path)
        .get(cacheTimeOutInSec, SECONDS);
  } catch (Exception e) {
    log.warn("Failed to get message-rate for {} subscription {}", this.topicName, this.subscriptionName, e);
  }
  // return policy-dispatch rate only if it's enabled in policies
  return policies.map(p -> {
    DispatchRate dispatchRate;
    if (subscriptionName == null) {
      dispatchRate = p.clusterDispatchRate.get(cluster);
    } else {
      dispatchRate = p.subscriptionDispatchRate.get(cluster);
    }
    return isDispatchRateEnabled(dispatchRate) ? dispatchRate : null;
  }).orElse(null);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com