未验证 提交 c8f84a63 编写于 作者: J Jason Song 提交者: GitHub

Merge pull request #1949 from nobodyiam/fix-1885

add rate limter for no app id warning log
package com.ctrip.framework.apollo.util; package com.ctrip.framework.apollo.util;
import com.google.common.util.concurrent.RateLimiter;
import java.io.File; import java.io.File;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
...@@ -34,8 +35,10 @@ public class ConfigUtil { ...@@ -34,8 +35,10 @@ public class ConfigUtil {
private TimeUnit configCacheExpireTimeUnit = TimeUnit.MINUTES;//1 minute private TimeUnit configCacheExpireTimeUnit = TimeUnit.MINUTES;//1 minute
private long longPollingInitialDelayInMills = 2000;//2 seconds private long longPollingInitialDelayInMills = 2000;//2 seconds
private boolean autoUpdateInjectedSpringProperties = true; private boolean autoUpdateInjectedSpringProperties = true;
private final RateLimiter warnLogRateLimiter;
public ConfigUtil() { public ConfigUtil() {
warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute
initRefreshInterval(); initRefreshInterval();
initConnectTimeout(); initConnectTimeout();
initReadTimeout(); initReadTimeout();
...@@ -55,8 +58,10 @@ public class ConfigUtil { ...@@ -55,8 +58,10 @@ public class ConfigUtil {
String appId = Foundation.app().getAppId(); String appId = Foundation.app().getAppId();
if (Strings.isNullOrEmpty(appId)) { if (Strings.isNullOrEmpty(appId)) {
appId = ConfigConsts.NO_APPID_PLACEHOLDER; appId = ConfigConsts.NO_APPID_PLACEHOLDER;
logger.warn("app.id is not set, please make sure it is set in classpath:/META-INF/app.properties, now apollo " + if (warnLogRateLimiter.tryAcquire()) {
"will only load public namespace configurations!"); logger.warn(
"app.id is not set, please make sure it is set in classpath:/META-INF/app.properties, now apollo will only load public namespace configurations!");
}
} }
return appId; return appId;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册