Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
spring-boot-starter-dsp
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
shenjiaqing
spring-boot-starter-dsp
Commits
d174f578
Commit
d174f578
authored
Aug 04, 2021
by
shenjiaqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交代码
parent
6ea7012e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
build.gradle
build.gradle
+1
-1
CacheConfig.java
...com/duiba/spring/boot/starter/dsp/warmup/CacheConfig.java
+8
-8
No files found.
build.gradle
View file @
d174f578
...
@@ -38,7 +38,7 @@ allprojects {
...
@@ -38,7 +38,7 @@ allprojects {
}
}
group
=
"cn.com.duiba.boot"
group
=
"cn.com.duiba.boot"
version
=
"0.0.1
2-SNAPSHOT
"
version
=
"0.0.1
4
"
}
}
subprojects
{
subprojects
{
...
...
spring-boot-starter-dsp-warmup/src/main/java/cn/com/duiba/spring/boot/starter/dsp/warmup/CacheConfig.java
View file @
d174f578
...
@@ -72,7 +72,8 @@ public class CacheConfig {
...
@@ -72,7 +72,8 @@ public class CacheConfig {
String
packageName
=
pkg
.
getName
();
String
packageName
=
pkg
.
getName
();
if
(
packageName
.
startsWith
(
"springfox."
)
||
packageName
.
startsWith
(
"org."
)
if
(
packageName
.
startsWith
(
"springfox."
)
||
packageName
.
startsWith
(
"org."
)
||
packageName
.
startsWith
(
"io."
)
||
packageName
.
startsWith
(
"net."
)
||
packageName
.
startsWith
(
"io."
)
||
packageName
.
startsWith
(
"net."
)
||
packageName
.
startsWith
(
"cn.com.duibaboot"
)
||
packageName
.
startsWith
(
"com.netflix"
))
{
||
packageName
.
startsWith
(
"cn.com.duibaboot"
)
||
packageName
.
startsWith
(
"com.netflix"
)
||
packageName
.
startsWith
(
"cn.com.duiba.tuia.pangea"
)
)
{
continue
;
continue
;
}
}
Field
[]
fields
=
bean
.
getClass
().
getDeclaredFields
();
Field
[]
fields
=
bean
.
getClass
().
getDeclaredFields
();
...
@@ -84,7 +85,7 @@ public class CacheConfig {
...
@@ -84,7 +85,7 @@ public class CacheConfig {
boolean
isGuava
=
Cache
.
class
.
isAssignableFrom
(
field
.
getType
());
boolean
isGuava
=
Cache
.
class
.
isAssignableFrom
(
field
.
getType
());
boolean
isCaffeine
=
AsyncCache
.
class
.
isAssignableFrom
(
field
.
getType
());
boolean
isCaffeine
=
AsyncCache
.
class
.
isAssignableFrom
(
field
.
getType
());
if
(!
isCaffeine
)
{
if
(!
isCaffeine
&&
!
isGuava
)
{
continue
;
continue
;
}
}
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
...
@@ -109,7 +110,7 @@ public class CacheConfig {
...
@@ -109,7 +110,7 @@ public class CacheConfig {
}
}
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
logger
.
warn
(
"
缓存备份失败
"
,
e
);
logger
.
warn
(
"
cache实例获取异常
"
,
e
);
}
}
}
}
}
}
...
@@ -119,7 +120,6 @@ public class CacheConfig {
...
@@ -119,7 +120,6 @@ public class CacheConfig {
@Order
(
Ordered
.
LOWEST_PRECEDENCE
-
1
)
@Order
(
Ordered
.
LOWEST_PRECEDENCE
-
1
)
public
void
onServerCache
(){
public
void
onServerCache
(){
try
{
try
{
logger
.
info
(
"进来了"
);
// 本地缓存预热开关 : 默认关闭
// 本地缓存预热开关 : 默认关闭
if
(!
cacheEnable
)
{
if
(!
cacheEnable
)
{
logger
.
warn
(
"Cache preheating failed,because cacheEnable is false"
);
logger
.
warn
(
"Cache preheating failed,because cacheEnable is false"
);
...
@@ -130,9 +130,9 @@ public class CacheConfig {
...
@@ -130,9 +130,9 @@ public class CacheConfig {
logger
.
warn
(
"获取容器列表为空!"
);
logger
.
warn
(
"获取容器列表为空!"
);
return
;
return
;
}
}
logger
.
info
(
"container of all registered AppInfo
: {}"
,
instances
);
logger
.
info
(
"container of all registered AppInfo
size: {}"
,
instances
.
size
()
);
List
<
InstanceInfo
>
list
=
instances
.
stream
().
sorted
(
Comparator
.
comparing
(
InstanceInfo:
:
getLastUpdatedTimestamp
).
reversed
()).
collect
(
Collectors
.
toList
());
List
<
InstanceInfo
>
list
=
instances
.
stream
().
sorted
(
Comparator
.
comparing
(
InstanceInfo:
:
getLastUpdatedTimestamp
).
reversed
()).
collect
(
Collectors
.
toList
());
logger
.
info
(
"container of all registered AppInfo : {}"
,
list
);
logger
.
info
(
"container of all registered AppInfo : {}"
,
list
);
if
(
CollectionUtils
.
isEmpty
(
list
))
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
logger
.
warn
(
"Cache preheating failed,because 服务启动获取【"
+
appName
+
"】列表信息为空"
);
logger
.
warn
(
"Cache preheating failed,because 服务启动获取【"
+
appName
+
"】列表信息为空"
);
return
;
return
;
...
@@ -157,7 +157,7 @@ public class CacheConfig {
...
@@ -157,7 +157,7 @@ public class CacheConfig {
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
Object
obj
=
field
.
get
(
bean
);
Object
obj
=
field
.
get
(
bean
);
if
(!(
obj
instanceof
Cache
)
||
!(
obj
instanceof
AsyncCache
))
{
if
(!(
obj
instanceof
Cache
)
&&
!(
obj
instanceof
AsyncCache
))
{
continue
;
continue
;
}
}
...
@@ -197,7 +197,7 @@ public class CacheConfig {
...
@@ -197,7 +197,7 @@ public class CacheConfig {
field
.
setAccessible
(
false
);
field
.
setAccessible
(
false
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
warn
(
"this bean : {} , no have method : {}, Lead to it cannot be deserialized , cause: {}"
,
split
[
0
],
field
.
getName
()
+
"Serialize"
,
e
);
logger
.
warn
(
"this bean : {} , no have method : {}, Lead to it cannot be deserialized , cause: {}"
,
split
[
0
],
field
.
getName
()
+
"
Serialize"
,
e
);
}
}
}
}
}
}
...
...
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