本文整理了Java中com.eudemon.ratelimiter.env.ZookeeperConfig.getPath()
方法的一些代码示例,展示了ZookeeperConfig.getPath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZookeeperConfig.getPath()
方法的具体详情如下:
包路径:com.eudemon.ratelimiter.env.ZookeeperConfig
类名称:ZookeeperConfig
方法名:getPath
暂无
代码示例来源: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
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
} 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.");
代码示例来源: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 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");
}
内容来源于网络,如有侵权,请联系作者删除!