gpt4 book ai didi

pl.allegro.tech.hermes.infrastructure.zookeeper.ZookeeperPaths类的使用及代码示例

转载 作者:知者 更新时间:2024-03-14 11:21:31 26 4
gpt4 key购买 nike

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

ZookeeperPaths介绍

暂无

代码示例

代码示例来源:origin: allegro/hermes

private static ConsumerNodesRegistry createConsumersRegistry(ConfigFactory configs, CuratorFramework curator, Clock clock) {
  ThreadFactory threadFactory = new ThreadFactoryBuilder()
      .setNameFormat("ConsumerRegistryExecutor-%d").build();
  return new ConsumerNodesRegistry(curator,
      newSingleThreadExecutor(threadFactory),
      new ZookeeperPaths(configs.getStringProperty(Configs.ZOOKEEPER_ROOT)).consumersRegistryPath(configs.getStringProperty(Configs.KAFKA_CLUSTER_NAME)),
      configs.getStringProperty(Configs.CONSUMER_WORKLOAD_NODE_ID),
      configs.getIntProperty(CONSUMER_WORKLOAD_DEAD_AFTER_SECONDS),
      clock);
}

代码示例来源:origin: allegro/hermes

void update(SubscriptionName subscriptionName, Map<String, MaxRate> newMaxRates) {
  try {
    for (Map.Entry<String, MaxRate> entry : newMaxRates.entrySet()) {
      String maxRatePath = zookeeperPaths.consumersMaxRatePath(cluster, subscriptionName, entry.getKey());
      writeOrCreate(maxRatePath, objectMapper.writeValueAsBytes(entry.getValue()));
    }
  } catch (Exception e) {
    throw new InternalProcessingException(e);
  }
}

代码示例来源:origin: allegro/hermes

public String consumersMaxRatePath(String cluster, SubscriptionName subscription, String consumerId) {
  return Joiner.on(URL_SEPARATOR).join(consumersRateRuntimePath(cluster), subscription, consumerId,
      MAX_RATE_PATH);
}

代码示例来源:origin: allegro/hermes

@Override
public SubscriptionAssignmentRegistry provide() {
  ZookeeperPaths paths = new ZookeeperPaths(configFactory.getStringProperty(Configs.ZOOKEEPER_ROOT));
  String cluster = configFactory.getStringProperty(KAFKA_CLUSTER_NAME);
  String consumersRuntimePath = paths.consumersRuntimePath(cluster);
  return new SubscriptionAssignmentRegistry(
      curatorClient,
      subscriptionAssignmentCache,
      new SubscriptionAssignmentPathSerializer(consumersRuntimePath, AUTO_ASSIGNED_MARKER)
  );
}

代码示例来源:origin: allegro/hermes

@Test
public void shouldRemoveInactiveConsumerEntries() throws Exception {
  // given
  ConsumerInstance consumer1 = consumer("consumer1");
  ConsumerInstance consumer2 = consumer("consumer2");
  maxRateRegistry.ensureCorrectAssignments(subscription, Sets.newHashSet("consumer1", "consumer2"));
  maxRateRegistry.update(subscription, ImmutableMap.of(
      "consumer1", new MaxRate(350.0),
      "consumer2", new MaxRate(0.5)
  ));
  wait.untilZookeeperPathIsCreated(
      zookeeperPaths.consumersMaxRatePath(cluster, consumer1.getSubscription(), consumer1.getConsumerId()));
  wait.untilZookeeperPathIsCreated(
      zookeeperPaths.consumersMaxRatePath(cluster, consumer2.getSubscription(), consumer2.getConsumerId()));
  // when
  maxRateRegistry.ensureCorrectAssignments(subscription, Sets.newHashSet("consumer1", "consumer3"));
  wait.untilZookeeperPathNotExists(
      zookeeperPaths.consumersRatePath(cluster, consumer2.getSubscription(), consumer2.getConsumerId()));
  // then
  assertEquals(Optional.empty(), maxRateRegistry.getMaxRate(consumer2));
}

代码示例来源:origin: allegro/hermes

@Override
public ZookeeperPaths provide() {
  return new ZookeeperPaths(config.getStringProperty(Configs.ZOOKEEPER_ROOT));
}

代码示例来源:origin: allegro/hermes

public String oAuthProviderPath(String oAuthProviderName) {
    return Joiner.on(URL_SEPARATOR).join(oAuthProvidersPath(), oAuthProviderName);
  }
}

代码示例来源:origin: allegro/hermes

void writeRateHistory(ConsumerInstance consumer, RateHistory rateHistory) {
  String path = zookeeperPaths.consumersRateHistoryPath(cluster, consumer.getSubscription(), consumer.getConsumerId());
  try {
    byte[] serialized = objectMapper.writeValueAsBytes(rateHistory);
    writeOrCreate(path, serialized);
  } catch (Exception e) {
    throw new InternalProcessingException(e);
  }
}

代码示例来源:origin: allegro/hermes

public String blacklistedTopicPath(String qualifiedTopicName) {
  return Joiner.on(URL_SEPARATOR).join(topicsBlacklistPath(), qualifiedTopicName);
}

代码示例来源:origin: allegro/hermes

private String assignmentPath(String subscription, String supervisorId) {
  return paths.consumersRuntimePath(CLUSTER_NAME) + "/" + subscription + "/" + supervisorId;
}

代码示例来源:origin: allegro/hermes

private void removeConsumerEntries(SubscriptionName subscriptionName, String consumerId) {
  try {
    curator.delete().deletingChildrenIfNeeded()
        .forPath(zookeeperPaths.consumersRatePath(cluster, subscriptionName, consumerId));
  } catch (KeeperException.NoNodeException e) {
    // ignore
  } catch (Exception e) {
    throw new InternalProcessingException(e);
  }
}

代码示例来源:origin: allegro/hermes

curator,
executorService,
paths.consumersRegistryPath(CLUSTER_NAME),
consumerId,
DEATH_OF_CONSUMER_AFTER_SECONDS,

代码示例来源:origin: allegro/hermes

private List<String> consumersInRegistry(SubscriptionName subscriptionName) throws Exception {
  String subscriptionConsumersPath = zookeeperPaths.consumersRateSubscriptionPath(cluster, subscriptionName);
  return curator.getChildren().forPath(subscriptionConsumersPath);
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-consumers

@Override
public SubscriptionAssignmentRegistry provide() {
  ZookeeperPaths paths = new ZookeeperPaths(configFactory.getStringProperty(Configs.ZOOKEEPER_ROOT));
  String cluster = configFactory.getStringProperty(KAFKA_CLUSTER_NAME);
  String consumersRuntimePath = paths.consumersRuntimePath(cluster);
  return new SubscriptionAssignmentRegistry(
      curatorClient,
      subscriptionAssignmentCache,
      new SubscriptionAssignmentPathSerializer(consumersRuntimePath, AUTO_ASSIGNED_MARKER)
  );
}

代码示例来源:origin: allegro/hermes

@Bean
ZookeeperPaths zookeeperPaths() {
  return new ZookeeperPaths(storageProperties.getPathPrefix());
}

代码示例来源:origin: allegro/hermes

@Override
public List<String> listOAuthProviderNames() {
  ensurePathExists(paths.oAuthProvidersPath());
  return childrenOf(paths.oAuthProvidersPath());
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-consumers

void writeRateHistory(ConsumerInstance consumer, RateHistory rateHistory) {
  String path = zookeeperPaths.consumersRateHistoryPath(cluster, consumer.getSubscription(), consumer.getConsumerId());
  try {
    byte[] serialized = objectMapper.writeValueAsBytes(rateHistory);
    writeOrCreate(path, serialized);
  } catch (Exception e) {
    throw new InternalProcessingException(e);
  }
}

代码示例来源:origin: allegro/hermes

@Override
  public List<String> list() {
    return childrenOf(paths.topicsBlacklistPath());
  }
}

代码示例来源:origin: allegro/hermes

@Inject
public SubscriptionAssignmentCache(CuratorFramework curator,
                  ConfigFactory configFactory,
                  ZookeeperPaths zookeeperPaths,
                  SubscriptionsCache subscriptionsCache) {
  this.curator = curator;
  this.basePath = zookeeperPaths.consumersRuntimePath(configFactory.getStringProperty(KAFKA_CLUSTER_NAME));
  this.subscriptionsCache = subscriptionsCache;
  this.pathSerializer = new SubscriptionAssignmentPathSerializer(basePath, AUTO_ASSIGNED_MARKER);
  this.cache = new HierarchicalCache(
      curator, Executors.newSingleThreadScheduledExecutor(), basePath, 2, Collections.emptyList()
  );
  cache.registerCallback(ASSIGNMENT_LEVEL, (e) -> {
    SubscriptionAssignment assignment =
        pathSerializer.deserialize(e.getData().getPath(), e.getData().getData());
    switch (e.getType()) {
      case CHILD_ADDED:
        onAssignmentAdded(assignment);
        break;
      case CHILD_REMOVED:
        onAssignmentRemoved(assignment);
        break;
    }
  });
}

代码示例来源:origin: pl.allegro.tech.hermes/hermes-consumers

private void removeConsumerEntries(SubscriptionName subscriptionName, String consumerId) {
  try {
    curator.delete().deletingChildrenIfNeeded()
        .forPath(zookeeperPaths.consumersRatePath(cluster, subscriptionName, consumerId));
  } catch (KeeperException.NoNodeException e) {
    // ignore
  } catch (Exception e) {
    throw new InternalProcessingException(e);
  }
}

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