gpt4 book ai didi

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

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

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

ZookeeperSubscriptionRepository介绍

暂无

代码示例

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

@Override
public SubscriptionRepository provide() {
  return new ZookeeperSubscriptionRepository(zookeeper, mapper, paths, topicRepository);
}

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

@Override
public List<String> listSubscriptionNames(TopicName topicName) {
  return childrenOf(paths.subscriptionsPath(topicName));
}

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

private Optional<Subscription> getSubscriptionDetails(TopicName topicName, String subscriptionName, boolean quiet) {
  ensureSubscriptionExists(topicName, subscriptionName);
  return readFrom(paths.subscriptionPath(topicName, subscriptionName), Subscription.class, quiet);
}

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

@Override
  public List<Subscription> listSubscriptions(TopicName topicName) {
    return listSubscriptionNames(topicName).stream()
        .map(subscription -> getSubscriptionDetails(topicName, subscription, true))
        .filter(Optional::isPresent)
        .map(Optional::get)
        .collect(Collectors.toList());
  }
}

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

@Override
public void updateSubscriptionState(TopicName topicName, String subscriptionName, Subscription.State state) {
  ensureSubscriptionExists(topicName, subscriptionName);
  logger.info("Changing subscription {} state to {}",
      new SubscriptionName(subscriptionName, topicName).getQualifiedName(), state.toString());
  Subscription modifiedSubscription = getSubscriptionDetails(topicName, subscriptionName);
  if (!modifiedSubscription.getState().equals(state)) {
    modifiedSubscription.setState(state);
    updateSubscription(modifiedSubscription);
  }
}

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

@Override
public void removeSubscription(TopicName topicName, String subscriptionName) {
  ensureSubscriptionExists(topicName, subscriptionName);
  logger.info("Removing subscription {}", new SubscriptionName(subscriptionName, topicName).getQualifiedName());
  remove(paths.subscriptionPath(topicName, subscriptionName));
}

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

@Override
public void updateSubscription(Subscription modifiedSubscription) {
  ensureSubscriptionExists(modifiedSubscription.getTopicName(), modifiedSubscription.getName());
  logger.info("Updating subscription {}", modifiedSubscription.getQualifiedName());
  overwrite(paths.subscriptionPath(modifiedSubscription), modifiedSubscription);
}

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

@Override
public Subscription getSubscriptionDetails(TopicName topicName, String subscriptionName) {
  return getSubscriptionDetails(topicName, subscriptionName, false).get();
}

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

@Override
public boolean subscriptionExists(TopicName topicName, String subscriptionName) {
  return pathExists(paths.subscriptionPath(topicName, subscriptionName));
}

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

@Override
public void createSubscription(Subscription subscription) {
  ensureConnected();
  topicRepository.ensureTopicExists(subscription.getTopicName());
  String subscriptionPath = paths.subscriptionPath(subscription);
  logger.info("Creating subscription {}", subscription.getQualifiedName());
  try {
    zookeeper.create().forPath(subscriptionPath, mapper.writeValueAsBytes(subscription));
  } catch (KeeperException.NodeExistsException ex) {
    throw new SubscriptionAlreadyExistsException(subscription, ex);
  } catch (Exception ex) {
    throw new InternalProcessingException(ex);
  }
}

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

@Override
public List<Subscription> getSubscriptionDetails(Collection<SubscriptionName> subscriptionNames) {
  return subscriptionNames.stream()
      .map(n -> getSubscriptionDetails(n.getTopicName(), n.getName()))
      .collect(Collectors.toList());
}

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

@Bean
SubscriptionRepository subscriptionRepository() {
  return new ZookeeperSubscriptionRepository(storageZookeeper(), objectMapper, zookeeperPaths(), topicRepository());
}

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

@Override
public Subscription getSubscriptionDetails(SubscriptionName name) {
  return getSubscriptionDetails(name.getTopicName(), name.getName());
}

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

ConsumerTestRuntimeEnvironment(Supplier<CuratorFramework> curatorSupplier) {
  this.paths = new ZookeeperPaths("/hermes");
  this.curatorSupplier = curatorSupplier;
  this.curator = curatorSupplier.get();
  this.groupRepository = new ZookeeperGroupRepository(curator, objectMapper, paths);
  this.topicRepository = new ZookeeperTopicRepository(curator, objectMapper, paths, groupRepository);
  this.subscriptionRepository = new ZookeeperSubscriptionRepository(
      curator, objectMapper, paths, topicRepository
  );
  this.configFactory = new MutableConfigFactory()
      .overrideProperty(CONSUMER_WORKLOAD_REBALANCE_INTERVAL, 1)
      .overrideProperty(CONSUMER_WORKLOAD_CONSUMERS_PER_SUBSCRIPTION, 2);
  this.consumersRegistry = new ConsumerNodesRegistry(
      curator, executorService, paths.consumersRegistryPath(CLUSTER_NAME), "id",
      DEATH_OF_CONSUMER_AFTER_SECONDS, Clock.systemDefaultZone());
  this.metricsSupplier = () -> new HermesMetrics(new MetricRegistry(), new PathsCompiler("localhost"));
  try {
    consumersRegistry.start();
  } catch (Exception e) {
    throw new InternalProcessingException(e);
  }
}

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