Skip to content

Commit

Permalink
Merge pull request apolloconfig#1949 from nobodyiam/fix-1885
Browse files Browse the repository at this point in the history
add rate limter for no app id warning log
  • Loading branch information
nobodyiam authored Feb 6, 2019
2 parents ecfb400 + 005f445 commit c8f84a6
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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();
Expand All @@ -55,8 +58,10 @@ public String getAppId() {
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;
}
Expand Down

0 comments on commit c8f84a6

Please sign in to comment.