Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
S
stockPriceTack
Project
Project
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
刘长帅
stockPriceTack
Commits
e1f5d8cd
Commit
e1f5d8cd
authored
Oct 13, 2022
by
“dujiuxin”
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加监控
parent
851fd3f5
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
8 deletions
+43
-8
ExecutorConfig.java
.../com/zfxftech/telmarket/common/config/ExecutorConfig.java
+5
-2
TemplateTaskPoolConfig.java
...ftech/telmarket/common/config/TemplateTaskPoolConfig.java
+2
-2
MonitorTask.java
...java/com/zfxftech/telmarket/task/monitor/MonitorTask.java
+32
-0
AsyncExecturConfig.java
...xftech/telmarket/websocket/config/AsyncExecturConfig.java
+4
-4
No files found.
src/main/java/com/zfxftech/telmarket/common/config/ExecutorConfig.java
View file @
e1f5d8cd
...
...
@@ -6,6 +6,7 @@ import org.springframework.scheduling.annotation.EnableAsync;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
import
java.util.concurrent.Executor
;
import
java.util.concurrent.ThreadPoolExecutor
;
@Configuration
//@EnableAsync
...
...
@@ -17,13 +18,14 @@ public class ExecutorConfig {
//线程池维护线程的最少数量
taskExecutor
.
setCorePoolSize
(
10
);
//线程池维护线程的最大数量
taskExecutor
.
setMaxPoolSize
(
2
0
);
taskExecutor
.
setMaxPoolSize
(
10
0
);
//线程池所使用的缓冲队列
taskExecutor
.
setQueueCapacity
(
50
);
taskExecutor
.
setQueueCapacity
(
50
0
);
//线程池维护线程所允许的空闲时间
taskExecutor
.
setKeepAliveSeconds
(
60
);
taskExecutor
.
setAllowCoreThreadTimeOut
(
true
);
taskExecutor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
taskExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
taskExecutor
.
setAwaitTerminationSeconds
(
60
);
return
taskExecutor
;
}
...
...
@@ -41,6 +43,7 @@ public class ExecutorConfig {
taskExecutor
.
setKeepAliveSeconds
(
60
);
taskExecutor
.
setAllowCoreThreadTimeOut
(
true
);
taskExecutor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
taskExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
taskExecutor
.
setAwaitTerminationSeconds
(
60
);
return
taskExecutor
;
}
...
...
src/main/java/com/zfxftech/telmarket/common/config/TemplateTaskPoolConfig.java
View file @
e1f5d8cd
...
...
@@ -26,7 +26,7 @@ public class TemplateTaskPoolConfig {
executor
.
setThreadNamePrefix
(
"gt-tempmsg-exec"
);
//如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程)
//该策略就稍微复杂一些,在pool没有关闭的前提下首先丢掉缓存在队列中的最早的任务,然后重新尝试运行该任务。这个策略需要适当小心*/
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
DiscardOldest
Policy
());
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRuns
Policy
());
executor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
executor
.
setAwaitTerminationSeconds
(
60
);
return
executor
;
...
...
@@ -47,7 +47,7 @@ public class TemplateTaskPoolConfig {
executor
.
setThreadNamePrefix
(
"gt-pushmsg-exec"
);
//如果执行程序尚未关闭,则位于工作队列头部的任务将被删除,然后重试执行程序(如果再次失败,则重复此过程)
//该策略就稍微复杂一些,在pool没有关闭的前提下首先丢掉缓存在队列中的最早的任务,然后重新尝试运行该任务。这个策略需要适当小心*/
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
DiscardOldest
Policy
());
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRuns
Policy
());
executor
.
setWaitForTasksToCompleteOnShutdown
(
true
);
executor
.
setAwaitTerminationSeconds
(
60
);
return
executor
;
...
...
src/main/java/com/zfxftech/telmarket/task/monitor/MonitorTask.java
0 → 100644
View file @
e1f5d8cd
package
com
.
zfxftech
.
telmarket
.
task
.
monitor
;
import
com.zfxftech.telmarket.service.redis.RedisService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.util.Date
;
/**
* 处理委托单自动买入成交
* */
@Slf4j
@Component
public
class
MonitorTask
{
@Autowired
@Qualifier
(
"redisServiceNoWrapper"
)
private
RedisService
redisService
;
//@ApiOperation(value = "服务监控", notes = "服务监控", httpMethod = "GET")
@Scheduled
(
cron
=
"0/2 * * * * ? "
)
public
void
moniter
()
throws
IOException
{
String
key
=
"GT:MONITOR:INVEST:TASK:PRICE"
;
redisService
.
set
(
key
,
String
.
valueOf
((
new
Date
()).
getTime
()));
}
}
src/main/java/com/zfxftech/telmarket/websocket/config/AsyncExecturConfig.java
View file @
e1f5d8cd
...
...
@@ -46,7 +46,7 @@ public class AsyncExecturConfig implements SchedulingConfigurer, AsyncConfigurer
@Bean
(
destroyMethod
=
"shutdown"
)
public
ThreadPoolTaskScheduler
taskScheduler
()
{
ThreadPoolTaskScheduler
scheduler
=
new
ThreadPoolTaskScheduler
();
scheduler
.
setPoolSize
(
1
00
);
scheduler
.
setPoolSize
(
2
00
);
scheduler
.
setThreadNamePrefix
(
"sch-task-"
);
scheduler
.
setAwaitTerminationSeconds
(
60
);
scheduler
.
setWaitForTasksToCompleteOnShutdown
(
true
);
...
...
@@ -68,10 +68,10 @@ public class AsyncExecturConfig implements SchedulingConfigurer, AsyncConfigurer
public
Executor
getAsyncExecutor
()
{
ThreadPoolTaskExecutor
threadPoolTaskExecutor
=
new
ThreadPoolTaskExecutor
();
threadPoolTaskExecutor
.
setCorePoolSize
(
20
);
threadPoolTaskExecutor
.
setMaxPoolSize
(
5
0
);
threadPoolTaskExecutor
.
setQueueCapacity
(
100
);
threadPoolTaskExecutor
.
setMaxPoolSize
(
20
0
);
threadPoolTaskExecutor
.
setQueueCapacity
(
100
0
);
threadPoolTaskExecutor
.
setKeepAliveSeconds
(
300
);
threadPoolTaskExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
Abort
Policy
());
threadPoolTaskExecutor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRuns
Policy
());
threadPoolTaskExecutor
.
setThreadNamePrefix
(
"async-executor-"
);
threadPoolTaskExecutor
.
initialize
();
return
threadPoolTaskExecutor
;
...
...
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