|
@@ -1,5 +1,6 @@
|
|
|
package com.ctrip.framework.apollo.util;
|
|
|
|
|
|
+import com.google.common.util.concurrent.RateLimiter;
|
|
|
import java.io.File;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@@ -34,8 +35,10 @@ public class ConfigUtil {
|
|
|
private TimeUnit configCacheExpireTimeUnit = TimeUnit.MINUTES;//1 minute
|
|
|
private long longPollingInitialDelayInMills = 2000;//2 seconds
|
|
|
private boolean autoUpdateInjectedSpringProperties = true;
|
|
|
+ private final RateLimiter warnLogRateLimiter;
|
|
|
|
|
|
public ConfigUtil() {
|
|
|
+ warnLogRateLimiter = RateLimiter.create(0.017); // 1 warning log output per minute
|
|
|
initRefreshInterval();
|
|
|
initConnectTimeout();
|
|
|
initReadTimeout();
|
|
@@ -55,8 +58,10 @@ public class ConfigUtil {
|
|
|
String appId = Foundation.app().getAppId();
|
|
|
if (Strings.isNullOrEmpty(appId)) {
|
|
|
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 " +
|
|
|
- "will only load public namespace configurations!");
|
|
|
+ if (warnLogRateLimiter.tryAcquire()) {
|
|
|
+ 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;
|
|
|
}
|