opt threadPool name

This commit is contained in:
tjq 2020-04-29 22:40:21 +08:00
parent 1843dc8a60
commit 05206cd43d
8 changed files with 12 additions and 12 deletions

View File

@ -18,27 +18,27 @@ import java.util.concurrent.ThreadPoolExecutor;
@Configuration @Configuration
public class ThreadPoolConfig { public class ThreadPoolConfig {
@Bean("timingTaskExecutor") @Bean("omsTimingPool")
public Executor getTimingPool() { public Executor getTimingPool() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(Runtime.getRuntime().availableProcessors()); executor.setCorePoolSize(Runtime.getRuntime().availableProcessors());
executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors()); executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors());
executor.setQueueCapacity(1024); executor.setQueueCapacity(1024);
executor.setKeepAliveSeconds(60); executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("timingTaskExecutor-"); executor.setThreadNamePrefix("omsTimingPool-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
return executor; return executor;
} }
@Bean("commonTaskExecutor") @Bean("omsCommonPool")
public Executor taskExecutor() { public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(Runtime.getRuntime().availableProcessors()); executor.setCorePoolSize(Runtime.getRuntime().availableProcessors());
executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors()); executor.setMaxPoolSize(Runtime.getRuntime().availableProcessors());
executor.setQueueCapacity(1024); executor.setQueueCapacity(1024);
executor.setKeepAliveSeconds(60); executor.setKeepAliveSeconds(60);
executor.setThreadNamePrefix("commonTaskExecutor-"); executor.setThreadNamePrefix("omsCommonPool-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy()); executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
return executor; return executor;
} }

View File

@ -47,7 +47,7 @@ public class LocalJpaConfig {
jpaProperties.setShowSql(false); jpaProperties.setShowSql(false);
HibernateProperties hibernateProperties = new HibernateProperties(); HibernateProperties hibernateProperties = new HibernateProperties();
// 考虑要不要用 create 模式每次启动都删除数据 // 每次启动都删除数据重启后原来的Instance已经通过故障转移更换了Server老的日志数据也没什么意义了
hibernateProperties.setDdlAuto("create"); hibernateProperties.setDdlAuto("create");
return hibernateProperties.determineHibernateProperties(jpaProperties.getProperties(), new HibernateSettings()); return hibernateProperties.determineHibernateProperties(jpaProperties.getProperties(), new HibernateSettings());
} }

View File

@ -127,7 +127,7 @@ public class InstanceLogService {
* @param instanceId 任务实例ID * @param instanceId 任务实例ID
*/ */
@Transactional @Transactional
@Async("commonTaskExecutor") @Async("omsCommonPool")
public void sync(Long instanceId) { public void sync(Long instanceId) {
// 休眠10秒等待全部数据上报OmsLogHandler 每隔5秒上报数据 // 休眠10秒等待全部数据上报OmsLogHandler 每隔5秒上报数据
@ -205,7 +205,7 @@ public class InstanceLogService {
} }
} }
@Async("timingTaskExecutor") @Async("omsTimingPool")
@Scheduled(fixedDelay = 60000) @Scheduled(fixedDelay = 60000)
public void timingCheck() { public void timingCheck() {

View File

@ -50,7 +50,7 @@ public class InstanceStatusCheckService {
@Resource @Resource
private JobInfoRepository jobInfoRepository; private JobInfoRepository jobInfoRepository;
@Async("timingTaskExecutor") @Async("omsTimingPool")
@Scheduled(fixedRate = 10000) @Scheduled(fixedRate = 10000)
public void timingStatusCheck() { public void timingStatusCheck() {
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();

View File

@ -63,7 +63,7 @@ public class JobScheduleService {
private static final long SCHEDULE_RATE = 15000; private static final long SCHEDULE_RATE = 15000;
@Async("timingTaskExecutor") @Async("omsTimingPool")
@Scheduled(fixedRate = SCHEDULE_RATE) @Scheduled(fixedRate = SCHEDULE_RATE)
public void timingSchedule() { public void timingSchedule() {

View File

@ -83,7 +83,7 @@ public class InstanceController {
String targetServer = appInfoOpt.get().getCurrentServer(); String targetServer = appInfoOpt.get().getCurrentServer();
// 转发HTTP请求 // 转发HTTP请求如果使用Akka则需要传输两次而转发HTTP请求只需要传输一次""数据包
if (!OhMyServer.getActorSystemAddress().equals(targetServer)) { if (!OhMyServer.getActorSystemAddress().equals(targetServer)) {
String ip = targetServer.split(":")[0]; String ip = targetServer.split(":")[0];
String url = "http://" + ip + ":" + port + "/instance/log?instanceId=" + instanceId; String url = "http://" + ip + ":" + port + "/instance/log?instanceId=" + instanceId;

View File

@ -14,4 +14,4 @@ spring.data.mongodb.uri=mongodb://remotehost:27017/oms
####### jpa config ####### ####### jpa config #######
spring.jpa.open-in-view=false spring.jpa.open-in-view=false
spring.jpa.hibernate.ddl-auto=update spring.data.mongodb.repositories.type=none

View File

@ -35,7 +35,7 @@ public class StandaloneProcessorDemo implements BasicProcessor {
try { try {
Collections.emptyList().add("277"); Collections.emptyList().add("277");
}catch (Exception e) { }catch (Exception e) {
context.getOmsLogger().error("[StandaloneProcessorDemo] process failed.", e); context.getOmsLogger().error("[StandaloneProcessorDemo] test exception log.", e);
} }