gpt4 book ai didi

com.eudemon.ratelimiter.env.ZookeeperConfig类的使用及代码示例

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

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

ZookeeperConfig介绍

[英]Zookeeper configuration.
[中]Zookeeper配置。

代码示例

代码示例来源:origin: wangzheng0822/ratelimiter4j

public void testBuildFromProperties_withEmptyProperties() {
 PropertySource propertySource = new PropertySource();
 ZookeeperConfig zkConfig = new ZookeeperConfig();
 zkConfig.buildFromProperties(propertySource);
 assertTrue(StringUtils.isEmpty(zkConfig.getAddress()));
 assertEquals(zkConfig.getPath(), ZookeeperConfig.DEFAULT_PATH);
}

代码示例来源:origin: wangzheng0822/ratelimiter4j

public MemoryUrlRateLimiter build() {
 RuleConfigParser parser = null;
 if (this.ruleParserType.equals("yaml")) {
  parser = new YamlRuleConfigParser();
 } else if (this.ruleParserType.equals("json")) {
  parser = new JsonRuleConfigParser();
 } else {
  throw new RuntimeException("Do not support the rule paser type: " + this.ruleParserType);
 }
 RuleConfigSource source = null;
 if (this.ruleSourceType.equals("file")) {
  source = new FileRuleConfigSource();
 } else if (this.ruleSourceType.equals("zookeeper")) {
  if (zookeeperConfig != null && StringUtils.isNoneBlank(zookeeperConfig.getAddress())
    && StringUtils.isNoneBlank(zookeeperConfig.getPath())) {
   source = new ZookeeperRuleConfigSource(zookeeperConfig.getAddress(),
     zookeeperConfig.getPath(), parser);
  } else {
   throw new RuntimeException("some zookeeper configuration is empty.");
  }
 } else {
  throw new RuntimeException("Do not support the rule source type: " + this.ruleSourceType);
 }
 MemoryUrlRateLimiter ratelimiter = new MemoryUrlRateLimiter(source);
 if (this.interceptors != null && !this.interceptors.isEmpty()) {
  ratelimiter.addInteceptors(interceptors);
 }
 return ratelimiter;
}

代码示例来源:origin: wangzheng0822/ratelimiter4j

private void mapPropertiesToConfigs(PropertySource propertySource) {
 String parserType =
   propertySource.getPropertyStringValue(PropertyConstants.PROPERTY_RULE_CONFIG_PARSER);
 if (StringUtils.isNotBlank(parserType)) {
  this.ruleConfigParserType = parserType;
 }
 String source =
   propertySource.getPropertyStringValue(PropertyConstants.PROPERTY_RULE_CONFIG_SOURCE);
 if (StringUtils.isNotBlank(source)) {
  this.ruleConfigSourceType = source;
 }
 redisConfig.buildFromProperties(propertySource);
 zookeeperConfig.buildFromProperties(propertySource);
}

代码示例来源:origin: wangzheng0822/ratelimiter4j

@BeforeClass
public void setup() {
 System.setProperty(PropertyConstants.PROPERTY_REDIS_ADDRESS, REDIS_IP_PORT);
 System.setProperty(PropertyConstants.PROPERTY_REDIS_TIMEOUT, String.valueOf(REDIS_TIMEOUT));
 System.setProperty(PropertyConstants.PROPERTY_ZOOKEEPER_ADDRESS, ZK_ADDR);
 System.setProperty(PropertyConstants.PROPERTY_ZOOKEEPER_RULE_PATH, ZK_PATH);
 redisConfig.setAddress(REDIS_IP_PORT);
 redisConfig.setTimeout(REDIS_TIMEOUT);
 zookeeperConfig.setAddress(ZK_ADDR);
 zookeeperConfig.setPath(ZK_PATH);
}

代码示例来源:origin: wangzheng0822/ratelimiter4j

public ZookeeperRuleConfigSource(String address, String path, RuleConfigParser ruleConfigParser) {
 RateLimiterConfig.instance().load();
 if (StringUtils.isEmpty(address)) {
  address = RateLimiterConfig.instance().getZookeeperConfig().getAddress();
 }
 if (StringUtils.isEmpty(path)) {
  path = RateLimiterConfig.instance().getZookeeperConfig().getPath();
 }
 this.address = address;
 this.path = path;
 this.ruleConfigParser = BEANS_CONTEXT.obtainRuleConfigParser(ruleConfigParser);
}

代码示例来源:origin: wangzheng0822/ratelimiter4j

public void testBuildFromProperties() {
 PropertySource propertySource = new PropertySource();
 Map<String, Object> properties = new LinkedHashMap<>();
 properties.put(PropertyConstants.PROPERTY_ZOOKEEPER_ADDRESS, "1.1.1.1:1212");
 properties.put(PropertyConstants.PROPERTY_ZOOKEEPER_RULE_PATH, "/com/eudemon/ratelimit");
 propertySource.addProperties(properties);
 ZookeeperConfig zkConfig = new ZookeeperConfig();
 zkConfig.buildFromProperties(propertySource);
 assertEquals(zkConfig.getAddress(), "1.1.1.1:1212");
 assertEquals(zkConfig.getPath(), "/com/eudemon/ratelimit");
}

代码示例来源:origin: wangzheng0822/ratelimiter4j

source = new FileRuleConfigSource();
} else if (this.ruleSourceType.equals("zookeeper")) {
 if (zookeeperConfig != null && StringUtils.isNoneBlank(zookeeperConfig.getAddress())
   && StringUtils.isNoneBlank(zookeeperConfig.getPath())) {
  source = new ZookeeperRuleConfigSource(zookeeperConfig.getAddress(),
    zookeeperConfig.getPath(), parser);
 } else {
  throw new RuntimeException("some zookeeper configuration is empty.");

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