Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
215ebc70
Commit
215ebc70
authored
May 22, 2018
by
HuangSheng
Committed by
nobodyiam
Jul 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加localCacheDir本地缓存配置路径可配置项
parent
87c65bfe
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
...framework/apollo/internals/LocalFileConfigRepository.java
+1
-1
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
...main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
+20
-1
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
.../java/com/ctrip/framework/apollo/BaseIntegrationTest.java
+1
-1
No files found.
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java
View file @
215ebc70
...
...
@@ -65,7 +65,7 @@ public class LocalFileConfigRepository extends AbstractConfigRepository
private
File
findLocalCacheDir
()
{
try
{
String
defaultCacheDir
=
m_configUtil
.
get
Default
LocalCacheDir
();
String
defaultCacheDir
=
m_configUtil
.
getLocalCacheDir
();
Path
path
=
Paths
.
get
(
defaultCacheDir
);
if
(!
Files
.
exists
(
path
))
{
Files
.
createDirectories
(
path
);
...
...
apollo-client/src/main/java/com/ctrip/framework/apollo/util/ConfigUtil.java
View file @
215ebc70
package
com
.
ctrip
.
framework
.
apollo
.
util
;
import
java.io.File
;
import
java.util.concurrent.TimeUnit
;
import
org.slf4j.Logger
;
...
...
@@ -34,6 +35,7 @@ public class ConfigUtil {
private
TimeUnit
configCacheExpireTimeUnit
=
TimeUnit
.
MINUTES
;
//1 minute
private
long
longPollingInitialDelayInMills
=
2000
;
//2 seconds
private
boolean
autoUpdateInjectedSpringProperties
=
true
;
private
String
localCacheDir
=
this
.
getDefaultLocalCacheDir
();
public
ConfigUtil
()
{
initRefreshInterval
();
...
...
@@ -44,6 +46,7 @@ public class ConfigUtil {
initMaxConfigCacheSize
();
initLongPollingInitialDelayInMills
();
initAutoUpdateInjectedSpringProperties
();
initLocalCacheDir
();
}
/**
...
...
@@ -205,11 +208,27 @@ public class ConfigUtil {
return
onErrorRetryIntervalTimeUnit
;
}
p
ublic
String
getDefaultLocalCacheDir
()
{
p
rivate
String
getDefaultLocalCacheDir
()
{
String
cacheRoot
=
isOSWindows
()
?
"C:\\opt\\data\\%s"
:
"/opt/data/%s"
;
return
String
.
format
(
cacheRoot
,
getAppId
());
}
private
void
initLocalCacheDir
()
{
// 1. Get from System Property
String
cacheRoot
=
System
.
getProperty
(
"apollo.localCacheDir"
);
if
(
Strings
.
isNullOrEmpty
(
cacheRoot
))
{
// 2. Get from app.properties
cacheRoot
=
Foundation
.
app
().
getProperty
(
"apollo.localCacheDir"
,
null
);
}
if
(!
Strings
.
isNullOrEmpty
(
cacheRoot
))
{
this
.
localCacheDir
=
String
.
format
(
cacheRoot
+
File
.
separator
+
"%s"
,
getAppId
());
}
}
public
String
getLocalCacheDir
()
{
return
this
.
localCacheDir
;
}
public
boolean
isInLocalMode
()
{
try
{
Env
env
=
getApolloEnv
();
...
...
apollo-client/src/test/java/com/ctrip/framework/apollo/BaseIntegrationTest.java
View file @
215ebc70
...
...
@@ -178,7 +178,7 @@ public abstract class BaseIntegrationTest{
}
@Override
public
String
get
Default
LocalCacheDir
()
{
public
String
getLocalCacheDir
()
{
return
ClassLoaderUtil
.
getClassPath
();
}
...
...
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