Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
328eac81
Commit
328eac81
authored
Jul 30, 2017
by
nobodyiam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add rate limit control for no config warning
parent
dc3c2ba2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
DefaultConfig.java
...a/com/ctrip/framework/apollo/internals/DefaultConfig.java
+5
-3
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java
View file @
328eac81
...
...
@@ -20,6 +20,7 @@ import com.ctrip.framework.apollo.model.ConfigChangeEvent;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.util.ExceptionUtil
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.util.concurrent.RateLimiter
;
/**
...
...
@@ -31,6 +32,7 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis
private
Properties
m_resourceProperties
;
private
AtomicReference
<
Properties
>
m_configProperties
;
private
ConfigRepository
m_configRepository
;
private
RateLimiter
m_warnLogRateLimiter
;
/**
* Constructor.
...
...
@@ -43,6 +45,7 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis
m_resourceProperties
=
loadFromResource
(
m_namespace
);
m_configRepository
=
configRepository
;
m_configProperties
=
new
AtomicReference
<>();
m_warnLogRateLimiter
=
RateLimiter
.
create
(
0.017
);
// 1 warning log output per minute
initialize
();
}
...
...
@@ -84,9 +87,8 @@ public class DefaultConfig extends AbstractConfig implements RepositoryChangeLis
value
=
(
String
)
m_resourceProperties
.
get
(
key
);
}
if
(
value
==
null
&&
m_configProperties
.
get
()
==
null
)
{
logger
.
warn
(
"Could not load config for namespace {} from Apollo, please check whether the configs are released "
+
"in Apollo! Return default value now!"
,
m_namespace
);
if
(
value
==
null
&&
m_configProperties
.
get
()
==
null
&&
m_warnLogRateLimiter
.
tryAcquire
())
{
logger
.
warn
(
"Could not load config for namespace {} from Apollo, please check whether the configs are released in Apollo! Return default value now!"
,
m_namespace
);
}
return
value
==
null
?
defaultValue
:
value
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment