Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
Overview
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
徐少华
midjourney-proxy
Commits
c611d8b9
Commit
c611d8b9
authored
Feb 01, 2021
by
李传峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:[none] 增加定时清理druid统计数据任务
parent
c0bc93e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
0 deletions
+35
-0
DataSourceConfig.java
...a/com/pcloud/common/core/datasource/DataSourceConfig.java
+3
-0
DruidStatsResetManager.java
...pcloud/common/core/datasource/DruidStatsResetManager.java
+32
-0
No files found.
pcloud-common-core/src/main/java/com/pcloud/common/core/datasource/DataSourceConfig.java
View file @
c611d8b9
...
@@ -113,6 +113,9 @@ public class DataSourceConfig {
...
@@ -113,6 +113,9 @@ public class DataSourceConfig {
ArrayList
<
String
>
arr
=
new
ArrayList
<>();
ArrayList
<
String
>
arr
=
new
ArrayList
<>();
arr
.
add
(
"set names utf8mb4;"
);
arr
.
add
(
"set names utf8mb4;"
);
datasource
.
setConnectionInitSqls
(
arr
);
datasource
.
setConnectionInitSqls
(
arr
);
// 定时清理druid统计数据,避免占用内存过大
DruidStatsResetManager
.
resetScheduledWithFixedDelay
();
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
logger
.
error
(
"druid configuration initialization filter"
,
e
);
logger
.
error
(
"druid configuration initialization filter"
,
e
);
}
}
...
...
pcloud-common-core/src/main/java/com/pcloud/common/core/datasource/DruidStatsResetManager.java
0 → 100644
View file @
c611d8b9
package
com
.
pcloud
.
common
.
core
.
datasource
;
import
com.alibaba.druid.stat.DruidStatManagerFacade
;
import
org.apache.commons.lang3.concurrent.BasicThreadFactory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
/**
* Druid统计数据重置
*/
class
DruidStatsResetManager
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DruidStatsResetManager
.
class
);
private
static
final
ScheduledThreadPoolExecutor
executor
=
new
ScheduledThreadPoolExecutor
(
1
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"druid-stats-reset-%d"
).
build
());
/**
* 定时重置
*/
static
void
resetScheduledWithFixedDelay
()
{
executor
.
scheduleWithFixedDelay
(()
->
{
DruidStatManagerFacade
.
getInstance
().
resetAll
();
LOGGER
.
info
(
"druid stats data reset all executed completed."
);
},
30
,
30
,
TimeUnit
.
MINUTES
);
}
}
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