Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mica
mica
提交
748554e3
mica
项目概览
mica
/
mica
通知
10
Star
2
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
mica
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
748554e3
编写于
4月 22, 2021
作者:
如梦技术
🐛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
添加 mica-jetcache 待完善。
上级
c8efa2c1
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
300 addition
and
0 deletion
+300
-0
build.gradle
build.gradle
+1
-0
mica-bom/build.gradle
mica-bom/build.gradle
+1
-0
mica-jetcache/README.md
mica-jetcache/README.md
+21
-0
mica-jetcache/build.gradle
mica-jetcache/build.gradle
+8
-0
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/config/JetCacheConfiguration.java
...t/dreamlu/mica/jetcache/config/JetCacheConfiguration.java
+50
-0
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/jackson/JacksonKeyConvertor.java
...et/dreamlu/mica/jetcache/jackson/JacksonKeyConvertor.java
+43
-0
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/metrics/JetCacheMetricsManager.java
...dreamlu/mica/jetcache/metrics/JetCacheMetricsManager.java
+48
-0
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/metrics/JetCacheMonitorManager.java
...dreamlu/mica/jetcache/metrics/JetCacheMonitorManager.java
+76
-0
mica-jetcache/src/main/resources/META-INF/spring-configuration-metadata.json
...ain/resources/META-INF/spring-configuration-metadata.json
+51
-0
settings.gradle
settings.gradle
+1
-0
未找到文件。
build.gradle
浏览文件 @
748554e3
...
...
@@ -18,6 +18,7 @@ ext {
findbugsVersion
=
"3.0.2"
logstashVersion
=
"6.6"
zxingVersion
=
"3.4.1"
jetCacheVersion
=
"2.6.0"
}
configure
(
subprojects
)
{
...
...
mica-bom/build.gradle
浏览文件 @
748554e3
...
...
@@ -31,6 +31,7 @@ dependencyManagement {
dependency
"net.dreamlu:mica-caffeine:${VERSION}"
dependency
"net.dreamlu:mica-logging:${VERSION}"
dependency
"net.dreamlu:mica-qrcode:${VERSION}"
dependency
"net.dreamlu:mica-jetcache:${VERSION}"
dependency
"net.dreamlu:mica-lite:${VERSION}"
// commons
dependency
"com.google.code.findbugs:jsr305:${findbugsVersion}"
...
...
mica-jetcache/README.md
0 → 100644
浏览文件 @
748554e3
# mica-jetcache
## 功能扩展
-
扩展 metrics 打通 micrometer
-
jackson KeyConvertorParser
-
添加 spring-configuration-metadata.json
## 使用
### maven
```
xml
<dependency>
<groupId>
net.dreamlu
</groupId>
<artifactId>
mica-jetcache
</artifactId>
<version>
${version}
</version>
</dependency>
```
### gradle
```
groovy
compile
(
"net.dreamlu:mica-jetcache:${version}"
)
```
mica-jetcache/build.gradle
0 → 100644
浏览文件 @
748554e3
dependencies
{
api
project
(
":mica-core"
)
api
(
"com.alicp.jetcache:jetcache-autoconfigure:${jetCacheVersion}"
)
{
exclude
group:
"com.alibaba"
,
module:
"fastjson"
}
implementation
"io.micrometer:micrometer-core"
annotationProcessor
"net.dreamlu:mica-auto:${micaAutoVersion}"
}
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/config/JetCacheConfiguration.java
0 → 100644
浏览文件 @
748554e3
/*
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
net.dreamlu.mica.jetcache.config
;
import
com.alicp.jetcache.anno.support.GlobalCacheConfig
;
import
com.alicp.jetcache.support.StatInfo
;
import
com.alicp.jetcache.support.StatInfoLogger
;
import
net.dreamlu.mica.jetcache.jackson.JacksonKeyConvertor
;
import
net.dreamlu.mica.jetcache.metrics.JetCacheMonitorManager
;
import
org.springframework.beans.factory.ObjectProvider
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.function.Consumer
;
/**
* jetcache 配置
*
* @author L.cm
*/
@Configuration
(
proxyBeanMethods
=
false
)
public
class
JetCacheConfiguration
{
@Bean
public
JacksonKeyConvertor
jacksonKeyConvertor
()
{
return
new
JacksonKeyConvertor
();
}
@Bean
public
JetCacheMonitorManager
jetCacheMonitorManager
(
GlobalCacheConfig
globalCacheConfig
,
ObjectProvider
<
Consumer
<
StatInfo
>>
metricsProvide
)
{
Consumer
<
StatInfo
>
metricsCallback
=
metricsProvide
.
getIfAvailable
(()
->
new
StatInfoLogger
(
false
));
return
new
JetCacheMonitorManager
(
globalCacheConfig
,
metricsCallback
);
}
}
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/jackson/JacksonKeyConvertor.java
0 → 100644
浏览文件 @
748554e3
/*
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
net.dreamlu.mica.jetcache.jackson
;
import
net.dreamlu.mica.core.utils.JsonUtil
;
import
java.util.function.Function
;
/**
* JacksonKey Convertor
*
* @author L.cm
*/
public
class
JacksonKeyConvertor
implements
Function
<
Object
,
Object
>
{
@Override
public
Object
apply
(
Object
originalKey
)
{
if
(
originalKey
==
null
)
{
return
null
;
}
if
(
originalKey
instanceof
String
)
{
return
originalKey
;
}
return
JsonUtil
.
toJson
(
originalKey
);
}
}
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/metrics/JetCacheMetricsManager.java
0 → 100644
浏览文件 @
748554e3
/*
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
net.dreamlu.mica.jetcache.metrics
;
import
com.alicp.jetcache.support.DefaultCacheMonitor
;
import
com.alicp.jetcache.support.DefaultMetricsManager
;
import
com.alicp.jetcache.support.StatInfo
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Consumer
;
/**
* JetCache MetricsManager
*
* @author L.cm
*/
public
class
JetCacheMetricsManager
extends
DefaultMetricsManager
{
public
JetCacheMetricsManager
(
int
resetTime
,
TimeUnit
resetTimeUnit
,
Consumer
<
StatInfo
>
metricsCallback
)
{
super
(
resetTime
,
resetTimeUnit
,
metricsCallback
);
}
/**
* 获取监控数据
*
* @return DefaultCacheMonitor 集合
*/
public
List
<
DefaultCacheMonitor
>
getMonitorList
()
{
return
new
ArrayList
<>(
monitorList
);
}
}
mica-jetcache/src/main/java/net/dreamlu/mica/jetcache/metrics/JetCacheMonitorManager.java
0 → 100644
浏览文件 @
748554e3
/*
* Copyright (c) 2019-2029, Dreamlu 卢春梦 (596392912@qq.com & www.dreamlu.net).
* <p>
* Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.gnu.org/licenses/lgpl.html
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
net.dreamlu.mica.jetcache.metrics
;
import
com.alicp.jetcache.Cache
;
import
com.alicp.jetcache.CacheUtil
;
import
com.alicp.jetcache.MultiLevelCache
;
import
com.alicp.jetcache.anno.support.CacheMonitorManager
;
import
com.alicp.jetcache.anno.support.GlobalCacheConfig
;
import
com.alicp.jetcache.support.DefaultCacheMonitor
;
import
com.alicp.jetcache.support.DefaultMetricsManager
;
import
com.alicp.jetcache.support.StatInfo
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.InitializingBean
;
import
java.util.concurrent.TimeUnit
;
import
java.util.function.Consumer
;
/**
* JetCache CacheMonitorManager
*
* @author L.cm
*/
public
class
JetCacheMonitorManager
implements
CacheMonitorManager
,
InitializingBean
,
DisposableBean
{
private
final
DefaultMetricsManager
defaultMetricsManager
;
public
JetCacheMonitorManager
(
GlobalCacheConfig
globalCacheConfig
,
Consumer
<
StatInfo
>
metricsCallback
)
{
this
.
defaultMetricsManager
=
new
JetCacheMetricsManager
(
globalCacheConfig
.
getStatIntervalMinutes
(),
TimeUnit
.
MINUTES
,
metricsCallback
);
}
@Override
public
void
addMonitors
(
String
area
,
String
cacheName
,
Cache
cache
)
{
cache
=
CacheUtil
.
getAbstractCache
(
cache
);
if
(
cache
instanceof
MultiLevelCache
)
{
MultiLevelCache
mc
=
(
MultiLevelCache
)
cache
;
if
(
mc
.
caches
().
length
==
2
)
{
Cache
local
=
mc
.
caches
()[
0
];
Cache
remote
=
mc
.
caches
()[
1
];
DefaultCacheMonitor
localMonitor
=
new
DefaultCacheMonitor
(
cacheName
+
"_local"
);
local
.
config
().
getMonitors
().
add
(
localMonitor
);
DefaultCacheMonitor
remoteMonitor
=
new
DefaultCacheMonitor
(
cacheName
+
"_remote"
);
remote
.
config
().
getMonitors
().
add
(
remoteMonitor
);
defaultMetricsManager
.
add
(
localMonitor
,
remoteMonitor
);
}
}
DefaultCacheMonitor
monitor
=
new
DefaultCacheMonitor
(
cacheName
);
cache
.
config
().
getMonitors
().
add
(
monitor
);
defaultMetricsManager
.
add
(
monitor
);
}
@Override
public
void
destroy
()
throws
Exception
{
defaultMetricsManager
.
stop
();
}
@Override
public
void
afterPropertiesSet
()
throws
Exception
{
defaultMetricsManager
.
start
();
}
}
mica-jetcache/src/main/resources/META-INF/spring-configuration-metadata.json
0 → 100644
浏览文件 @
748554e3
{
"groups"
:
[
{
"name"
:
"jetcache"
,
"type"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
}
],
"properties"
:
[
{
"name"
:
"jetcache.area-in-cache-name"
,
"type"
:
"java.lang.Boolean"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
,
"defaultValue"
:
true
},
{
"name"
:
"jetcache.enable-method-cache"
,
"type"
:
"java.lang.Boolean"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
,
"defaultValue"
:
true
},
{
"name"
:
"jetcache.hidden-packages"
,
"type"
:
"java.lang.String[]"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
},
{
"name"
:
"jetcache.local"
,
"type"
:
"java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
},
{
"name"
:
"jetcache.penetration-protect"
,
"type"
:
"java.lang.Boolean"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
,
"defaultValue"
:
false
},
{
"name"
:
"jetcache.remote"
,
"type"
:
"java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>>"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
},
{
"name"
:
"jetcache.stat-interval-minutes"
,
"type"
:
"java.lang.Integer"
,
"sourceType"
:
"com.alicp.jetcache.autoconfigure.JetCacheProperties"
,
"defaultValue"
:
0
}
],
"hints"
:
[]
}
\ No newline at end of file
settings.gradle
浏览文件 @
748554e3
...
...
@@ -15,4 +15,5 @@ include "mica-metrics"
include
"mica-caffeine"
include
"mica-logging"
include
"mica-qrcode"
include
"mica-jetcache"
include
"mica-lite"
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录