fix:1.优化数据同步线程池
This commit is contained in:
parent
7d2846af18
commit
87e51675a3
|
|
@ -12,10 +12,6 @@ import org.springframework.stereotype.Component;
|
||||||
@ConfigurationProperties(prefix = "data-sync")
|
@ConfigurationProperties(prefix = "data-sync")
|
||||||
public class DataSyncProperties {
|
public class DataSyncProperties {
|
||||||
|
|
||||||
/**
|
|
||||||
* 最小间隔(分钟)
|
|
||||||
*/
|
|
||||||
private Integer minMinute;
|
|
||||||
/**
|
/**
|
||||||
* 同时最大执行数据表数量
|
* 同时最大执行数据表数量
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -147,11 +147,13 @@ public class SyncDataJob implements Job {
|
||||||
pstmt.setString(2, syncStrategy.getTableName().toUpperCase());
|
pstmt.setString(2, syncStrategy.getTableName().toUpperCase());
|
||||||
pstmt.setString(3, syncStrategy.getColumnName().toUpperCase());
|
pstmt.setString(3, syncStrategy.getColumnName().toUpperCase());
|
||||||
|
|
||||||
ResultSet rs = pstmt.executeQuery();
|
try(ResultSet rs = pstmt.executeQuery()){
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
String dataType = rs.getString("data_type").toUpperCase();
|
String dataType = rs.getString("data_type").toUpperCase();
|
||||||
return dataType.contains("DATE") || dataType.contains("TIME");
|
return dataType.contains("DATE") || dataType.contains("TIME");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -205,8 +207,7 @@ public class SyncDataJob implements Job {
|
||||||
int maximumPoolSize = Runtime.getRuntime().availableProcessors();
|
int maximumPoolSize = Runtime.getRuntime().availableProcessors();
|
||||||
int maxExecSize = Math.min(dataSyncProperties.getMaxExecNum(), maximumPoolSize);
|
int maxExecSize = Math.min(dataSyncProperties.getMaxExecNum(), maximumPoolSize);
|
||||||
String threadNamePrefix = "data_sync";
|
String threadNamePrefix = "data_sync";
|
||||||
int queueCapacity = maxExecSize * 2;
|
|
||||||
CustomThreadFactory threadFactory = new CustomThreadFactory(threadNamePrefix);
|
CustomThreadFactory threadFactory = new CustomThreadFactory(threadNamePrefix);
|
||||||
threadPoolExecutor = new ThreadPoolExecutor(maxExecSize,maximumPoolSize,5, TimeUnit.SECONDS,new LinkedBlockingQueue<>(queueCapacity),threadFactory);
|
threadPoolExecutor = new ThreadPoolExecutor(maxExecSize,(maxExecSize*2),maxExecSize, TimeUnit.SECONDS,new LinkedBlockingQueue<>(),threadFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user