Authored by hugufei

fix bug

... ... @@ -5,6 +5,11 @@ public class PersionalRateLimitConfig {
private int limit;
private int second;
public PersionalRateLimitConfig(int limit, int second) {
this.limit = limit;
this.second = second;
}
public PersionalRateLimitConfig(PersionalRateLimit rateLimit) {
super();
this.limit = rateLimit.limit();
... ... @@ -32,11 +37,11 @@ public class PersionalRateLimitConfig {
this.limit = Integer.valueOf(values[0]);
this.second = Integer.valueOf(values[1]);
}
public String toZkValue() {
return this.limit + ":" + this.second;
}
public String toLogInfo() {
StringBuilder sb = new StringBuilder();
sb.append(this.limit).append("c/").append(this.second).append("s");
... ...
package com.yoho.search.service.base;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -10,6 +12,8 @@ import com.yoho.search.common.downgrade.persional.PersionalRateLimitConfig;
@Service
public class SearchDynamicConfigService {
private static final Logger logger = LoggerFactory.getLogger(SearchDynamicConfigService.class);
@Autowired
private ConfigReader configReader;
... ... @@ -185,12 +189,17 @@ public class SearchDynamicConfigService {
}
/**
* 召回时是否使用全局品牌id
* 个性化降级配置
*/
public PersionalRateLimitConfig getPersionalRateLimitConfig(String rateLimitName,PersionalRateLimit persionalRateLimit){
String zkConfigKey = "search.persional.rateLimit" + rateLimitName.replaceAll("/", ".");
PersionalRateLimitConfig defalut = new PersionalRateLimitConfig(persionalRateLimit);
String zkConfigValue = configReader.getString(zkConfigKey, defalut.toZkValue());
return new PersionalRateLimitConfig(zkConfigValue);
try {
String zkConfigKey = "search.persional.rateLimit" + rateLimitName.replaceAll("/", ".");
PersionalRateLimitConfig defalut = new PersionalRateLimitConfig(persionalRateLimit);
String zkConfigValue = configReader.getString(zkConfigKey, defalut.toZkValue());
return new PersionalRateLimitConfig(zkConfigValue);
} catch (Exception e) {
logger.error(e.getMessage(),e);
return new PersionalRateLimitConfig(200,10);
}
}
}
... ...