gpt4 book ai didi

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

转载 作者:知者 更新时间:2024-03-13 12:58:13 28 4
gpt4 key购买 nike

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

ZookeeperGroupRepository介绍

暂无

代码示例

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

@Override
public GroupRepository provide() {
  return new ZookeeperGroupRepository(zookeeper, mapper, paths);
}

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

@Override
public List<String> listGroupNames() {
  ensureConnected();
  return childrenOf(paths.groupsPath());
}

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

@Override
public void removeGroup(String groupName) {
  ensureConnected();
  ensureGroupExists(groupName);
  ensureGroupIsEmpty(groupName);
  logger.info("Removing group: {}", groupName);
  remove(paths.groupPath(groupName));
}

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

private Optional<Group> getGroupDetails(String groupName, boolean quiet) {
    ensureConnected();
    ensureGroupExists(groupName);

    String path = paths.groupPath(groupName);
    return readFrom(path, Group.class, quiet);
  }
}

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

@Override
public void updateGroup(Group group) {
  ensureConnected();
  ensureGroupExists(group.getGroupName());
  logger.info("Updating group {}", group.getGroupName());
  overwrite(paths.groupPath(group.getGroupName()), group);
}

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

@Override
public boolean groupExists(String groupName) {
  ensureConnected();
  return pathExists(paths.groupPath(groupName));
}

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

@Override
public List<Group> listGroups() {
  return listGroupNames().stream()
      .map(n -> getGroupDetails(n, true))
      .filter(Optional::isPresent)
      .map(Optional::get)
      .collect(Collectors.toList());
}

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

@Override
public Group getGroupDetails(String groupName) {
  return getGroupDetails(groupName, false).get();
}

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

@Override
public void ensureGroupExists(String groupName) {
  if (!groupExists(groupName)) {
    throw new GroupNotExistsException(groupName);
  }
}

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

private void ensureGroupIsEmpty(String groupName) {
  if (!childrenOf(paths.topicsPath(groupName)).isEmpty()) {
    throw new GroupNotEmptyException(groupName);
  }
}

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

@Override
public void createGroup(Group group) {
  ensureConnected();
  String groupPath = paths.groupPath(group.getGroupName());
  logger.info("Creating group {} for path {}", group.getGroupName(), groupPath);
  try {
    zookeeper.inTransaction()
        .create().forPath(groupPath, mapper.writeValueAsBytes(group))
        .and()
        .create().forPath(paths.topicsPath(group.getGroupName()))
        .and().commit();
  } catch (KeeperException.NodeExistsException ex) {
    throw new GroupAlreadyExistsException(group.getGroupName(), ex);
  } catch (Exception ex) {
    throw new InternalProcessingException(ex);
  }
}

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

@Bean
GroupRepository groupRepository() {
  return new ZookeeperGroupRepository(storageZookeeper(), objectMapper, zookeeperPaths());
}

代码示例来源: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);
  }
}

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