Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
ec8cffe1
提交
ec8cffe1
编写于
2月 16, 2023
作者:
xuhui961310148
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update:构建批次缓存清理调整
上级
94b52b8b
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
87 行增加
和
29 行删除
+87
-29
BaseEntityService.java
...cn/ibizlab/core/extensions/service/BaseEntityService.java
+2
-0
BaseEntityServiceImpl.java
...bizlab/core/extensions/service/BaseEntityServiceImpl.java
+65
-27
RuleEngineExService.java
.../ibizlab/core/extensions/service/RuleEngineExService.java
+12
-0
CleanExpirationKieContainerJobHandler.java
.../core/util/job/CleanExpirationKieContainerJobHandler.java
+8
-2
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BaseEntityService.java
浏览文件 @
ec8cffe1
...
@@ -17,4 +17,6 @@ public interface BaseEntityService {
...
@@ -17,4 +17,6 @@ public interface BaseEntityService {
ExecLog
processAll
(
BaseRequest
msg
);
ExecLog
processAll
(
BaseRequest
msg
);
void
saveResult
(
ModelObj
param
,
String
RULEID
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
FieldObj
BUSINESSCAT
,
Integer
RETVALUE
,
FieldObj
KEYVALUEFIELD
,
FieldObj
DOMAINSFIELD
,
FieldObj
DIMFIELD
,
void
saveResult
(
ModelObj
param
,
String
RULEID
,
String
RULECODE
,
String
RULENAME
,
String
RU_EXECRESULTNAME
,
FieldObj
BUSINESSCAT
,
Integer
RETVALUE
,
FieldObj
KEYVALUEFIELD
,
FieldObj
DOMAINSFIELD
,
FieldObj
DIMFIELD
,
FieldObj
METRICFIELD
,
FieldObj
TIMEFIELD
,
FieldObj
EXT1FIELD
,
FieldObj
EXT2FIELD
);
FieldObj
METRICFIELD
,
FieldObj
TIMEFIELD
,
FieldObj
EXT1FIELD
,
FieldObj
EXT2FIELD
);
void
cleanKieContainer
();
void
cleanExpirationKieContainer
();
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BaseEntityServiceImpl.java
浏览文件 @
ec8cffe1
...
@@ -643,37 +643,75 @@ public class BaseEntityServiceImpl implements BaseEntityService
...
@@ -643,37 +643,75 @@ public class BaseEntityServiceImpl implements BaseEntityService
/**
/**
* 清理过期的KieContainer,默认超过七天即认为过期失效
* 清理过期的KieContainer,默认超过七天即认为过期失效
*/
*/
public
void
cleanExpirationKieContainer
()
throws
ParseException
{
@Override
int
beforeSize
=
setKc
.
size
();
public
void
cleanExpirationKieContainer
(){
if
(
setKc
.
size
()
>
0
){
int
beforeSize
=
this
.
setKc
.
size
();
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
if
(
beforeSize
==
0
){
SimpleDateFormat
simpleDateFormat2
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
return
;
long
curTime
=
simpleDateFormat2
.
parse
(
LocalDate
.
now
().
toString
()).
getTime
();
}
long
timeDifference
=
this
.
expirationDays
*
24
*
60
*
60
*
1000
;
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyyMMdd"
);
Iterator
<
String
>
iterator
=
setKc
.
keySet
().
iterator
();
SimpleDateFormat
simpleDateFormat2
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
while
(
iterator
.
hasNext
())
{
long
curTime
=
0L
;
// 构建批次信息,如:20230214140921[高检-信访辅助(规则专用)]-cnt-10
try
{
String
bacth
=
iterator
.
next
();
curTime
=
simpleDateFormat2
.
parse
(
LocalDate
.
now
().
toString
()).
getTime
();
if
(!
StringUtils
.
isEmpty
(
bacth
)
&&
bacth
.
length
()
>
8
){
}
catch
(
ParseException
e
)
{
try
{
e
.
printStackTrace
();
String
strBatchTime
=
bacth
.
substring
(
0
,
8
);
log
.
error
(
String
.
format
(
"获取当前日期时间戳异常,原因:"
,
e
.
getMessage
()));
long
batchTime
=
simpleDateFormat
.
parse
(
strBatchTime
).
getTime
();
return
;
if
((
curTime
-
batchTime
)
>
timeDifference
){
}
iterator
.
remove
();
long
timeDifference
=
this
.
expirationDays
*
24
*
60
*
60
*
1000
;
log
.
info
(
String
.
format
(
"[batch]:%1$s,是否被清除:是"
,
bacth
));
Iterator
<
String
>
iterator
=
this
.
setKc
.
keySet
().
iterator
();
}
else
{
while
(
iterator
.
hasNext
())
{
log
.
info
(
String
.
format
(
"[batch]:%1$s,是否被清除:否"
,
bacth
));
// 构建批次信息,如:20230214140921[高检-信访辅助(规则专用)]-cnt-10
String
bacth
=
iterator
.
next
();
if
(!
StringUtils
.
isEmpty
(
bacth
)
&&
bacth
.
length
()
>
8
){
try
{
String
strBatchTime
=
bacth
.
substring
(
0
,
8
);
long
batchTime
=
simpleDateFormat
.
parse
(
strBatchTime
).
getTime
();
if
((
curTime
-
batchTime
)
>
timeDifference
){
try
{
this
.
setKc
.
get
(
bacth
).
dispose
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
log
.
error
(
String
.
format
(
"setKc.get(iterator).dispose()异常,原因:"
+
ex
.
getMessage
()));
}
}
}
catch
(
Exception
e
){
iterator
.
remove
();
e
.
printStackTrace
();
log
.
info
(
String
.
format
(
"[batch]:%1$s,是否被清除:是"
,
bacth
));
log
.
error
(
String
.
format
(
"比较构建批次[batch]:%1$s,是否过期异常,原因:%2$s"
,
bacth
,
e
.
getMessage
()));
}
else
{
}
log
.
info
(
String
.
format
(
"[batch]:%1$s,是否被清除:否"
,
bacth
));
}
else
{
}
log
.
info
(
String
.
format
(
"[batch]:%1$s,是否被清除:否"
,
bacth
));
}
catch
(
Exception
e
){
e
.
printStackTrace
();
log
.
error
(
String
.
format
(
"比较构建批次[batch]:%1$s,是否过期异常,原因:%2$s"
,
bacth
,
e
.
getMessage
()));
}
}
}
else
{
log
.
info
(
String
.
format
(
"[batch]:%1$s,是否被清除:否"
,
bacth
));
}
}
}
}
int
afterSize
=
setKc
.
size
();
int
afterSize
=
this
.
setKc
.
size
();
log
.
info
(
String
.
format
(
"清理过期setKc完成,过期时间(天):%1$s,清理前setKc大小:%2$s,清理后setKc大小:%3$s,清理setKc数:%4$s"
,
this
.
expirationDays
,
beforeSize
,
afterSize
,(
beforeSize
-
afterSize
)
));
log
.
info
(
String
.
format
(
"清理过期setKc完成,过期时间(天):%1$s,清理前setKc大小:%2$s,清理后setKc大小:%3$s,清理setKc数:%4$s"
,
this
.
expirationDays
,
beforeSize
,
afterSize
,(
beforeSize
-
afterSize
)
));
}
}
@Override
public
void
cleanKieContainer
()
{
int
beforeSize
=
this
.
setKc
.
size
();
if
(
beforeSize
==
0
){
return
;
}
Iterator
<
String
>
iterator
=
this
.
setKc
.
keySet
().
iterator
();
while
(
iterator
.
hasNext
())
{
// 构建批次信息,如:20230214140921[高检-信访辅助(规则专用)]-cnt-10
String
bacth
=
iterator
.
next
();
try
{
this
.
setKc
.
get
(
bacth
).
dispose
();
}
catch
(
Exception
ex
){
ex
.
printStackTrace
();
log
.
error
(
String
.
format
(
"--cleanKieContainer--setKc.get(iterator).dispose()异常,[batch]:%1$s,原因:%2$s"
,
bacth
,
ex
.
getMessage
()));
}
iterator
.
remove
();
log
.
info
(
String
.
format
(
"--cleanKieContainer--[batch]:%1$s,已被清除。"
,
bacth
));
}
int
afterSize
=
this
.
setKc
.
size
();
log
.
info
(
String
.
format
(
"--cleanKieContainer--执行完成,清理前setKc大小:%1$s,清理后setKc大小:%2$s,清理setKc数:%3$s"
,
beforeSize
,
afterSize
,(
beforeSize
-
afterSize
)
));
}
}
}
\ No newline at end of file
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/RuleEngineExService.java
浏览文件 @
ec8cffe1
...
@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
...
@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
...
@@ -80,6 +81,10 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
...
@@ -80,6 +81,10 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
@Autowired
@Autowired
private
ExecResultExService
execResultExService
;
private
ExecResultExService
execResultExService
;
@Autowired
@Qualifier
(
"AnalyseEntityServiceImpl"
)
private
BaseEntityService
analyseEntityServiceImpl
;
/**
/**
* [Run:运行] 行为扩展
* [Run:运行] 行为扩展
* @param et
* @param et
...
@@ -347,5 +352,12 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
...
@@ -347,5 +352,12 @@ public class RuleEngineExService extends RuleEngineServiceImpl {
}
}
return
super
.
check
(
et
);
return
super
.
check
(
et
);
}
}
@Override
public
RuleEngine
cleanKC
(
RuleEngine
et
)
{
baseEntityService
.
cleanKieContainer
();
analyseEntityServiceImpl
.
cleanKieContainer
();
return
et
;
}
}
}
ibzdst-core/src/main/java/cn/ibizlab/core/util/job/CleanExpirationKieContainerJobHandler.java
浏览文件 @
ec8cffe1
package
cn
.
ibizlab
.
core
.
util
.
job
;
package
cn
.
ibizlab
.
core
.
util
.
job
;
import
cn.ibizlab.core.extensions.service.BaseEntityService
Impl
;
import
cn.ibizlab.core.extensions.service.BaseEntityService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
...
@@ -18,7 +19,11 @@ public class CleanExpirationKieContainerJobHandler {
...
@@ -18,7 +19,11 @@ public class CleanExpirationKieContainerJobHandler {
@Autowired
@Autowired
@Lazy
@Lazy
private
BaseEntityServiceImpl
baseEntityService
;
private
BaseEntityService
baseEntityService
;
@Autowired
@Lazy
@Qualifier
(
"AnalyseEntityServiceImpl"
)
private
BaseEntityService
analyseEntityServiceImpl
;
/**
/**
* 默认每天凌晨6点开始执行
* 默认每天凌晨6点开始执行
...
@@ -29,6 +34,7 @@ public class CleanExpirationKieContainerJobHandler {
...
@@ -29,6 +34,7 @@ public class CleanExpirationKieContainerJobHandler {
log
.
info
(
"--cleanExpirationKieContainer--开始执行"
);
log
.
info
(
"--cleanExpirationKieContainer--开始执行"
);
try
{
try
{
baseEntityService
.
cleanExpirationKieContainer
();
baseEntityService
.
cleanExpirationKieContainer
();
analyseEntityServiceImpl
.
cleanExpirationKieContainer
();
log
.
info
(
"--cleanExpirationKieContainer--执行完成,耗时(毫秒):"
+
(
System
.
currentTimeMillis
()
-
start
));
log
.
info
(
"--cleanExpirationKieContainer--执行完成,耗时(毫秒):"
+
(
System
.
currentTimeMillis
()
-
start
));
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录